Contract 0xc9e112A58ae290058084F2b773c3c81f35517306

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

Contract Overview

Balance:
Txn Hash Method
Block
From
To
Value
0x87ea60b5017e245f2333246d3bdbd5c9b46326f9485e0e3b7d1f8e7fc080ce930x60806040182145192023-12-06 10:05:06135 days 18 hrs ago0xd866b2332d4383c1bf719732177e2d9109c99dbc IN  Create: SportPositionalMarketManager0 ETH0.0000000505390.00001
[ Download CSV Export 
Parent Txn Hash Block From To Value
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
SportPositionalMarketManager

Compiler Version
v0.8.4+commit.c7e474f2

Optimization Enabled:
Yes with 200 runs

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

// Inheritance
import "../../utils/proxy/solidity-0.8.0/ProxyOwned.sol";
import "../../utils/proxy/solidity-0.8.0/ProxyPausable.sol";

// Libraries
import "../../utils/libraries/AddressSetLib.sol";
import "@openzeppelin/contracts-4.4.1/utils/math/SafeMath.sol";

// Internal references
import "./SportPositionalMarketFactory.sol";
import "./SportPositionalMarket.sol";
import "./SportPosition.sol";
import "../../interfaces/ISportPositionalMarketManager.sol";
import "../../interfaces/ISportPositionalMarket.sol";
import "../../interfaces/ITherundownConsumer.sol";

import "@openzeppelin/contracts-4.4.1/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "../../interfaces/IGamesOddsObtainer.sol";
import "../../interfaces/IGamesPlayerProps.sol";

import "../../interfaces/IGameChildMarket.sol";

contract SportPositionalMarketManager is Initializable, ProxyOwned, ProxyPausable, ISportPositionalMarketManager {
    /* ========== LIBRARIES ========== */
    using SafeMath for uint;
    using AddressSetLib for AddressSetLib.AddressSet;

    /* ========== STATE VARIABLES ========== */

    uint public override expiryDuration;

    bool public override marketCreationEnabled;
    bool public customMarketCreationEnabled;

    uint public override totalDeposited;

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

    SportPositionalMarketManager internal _migratingManager;

    IERC20 public sUSD;

    address public theRundownConsumer;
    address public sportPositionalMarketFactory;
    bool public needsTransformingCollateral;
    mapping(address => bool) public whitelistedAddresses;
    address private apexConsumer; // deprecated
    uint public cancelTimeout;
    mapping(address => bool) public whitelistedCancelAddresses;
    address public oddsObtainer;

    mapping(address => bool) public isDoubleChance;
    bool public override isDoubleChanceSupported;
    mapping(address => address[]) public doubleChanceMarketsByParent;
    mapping(uint => bool) public override doesSportSupportDoubleChance;
    address public playerProps;

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

    function initialize(address _owner, IERC20 _sUSD) external initializer {
        setOwner(_owner);
        sUSD = _sUSD;

        // Temporarily change the owner so that the setters don't revert.
        owner = msg.sender;

        marketCreationEnabled = true;
        customMarketCreationEnabled = false;
    }

    /* ========== SETTERS ========== */
    function setSportPositionalMarketFactory(address _sportPositionalMarketFactory) external onlyOwner {
        sportPositionalMarketFactory = _sportPositionalMarketFactory;
        emit SetSportPositionalMarketFactory(_sportPositionalMarketFactory);
    }

    function setTherundownConsumer(address _theRundownConsumer) external onlyOwner {
        theRundownConsumer = _theRundownConsumer;
        emit SetTherundownConsumer(_theRundownConsumer);
    }

    function setOddsObtainer(address _oddsObtainer) external onlyOwner {
        oddsObtainer = _oddsObtainer;
        emit SetObtainerAddress(_oddsObtainer);
    }

    function setPlayerProps(address _playerProps) external onlyOwner {
        playerProps = _playerProps;
        emit SetPlayerPropsAddress(_playerProps);
    }

    function getOddsObtainer() external view override returns (address obtainer) {
        obtainer = oddsObtainer;
    }

    /// @notice setNeedsTransformingCollateral sets needsTransformingCollateral value
    /// @param _needsTransformingCollateral boolen value to be set
    function setNeedsTransformingCollateral(bool _needsTransformingCollateral) external onlyOwner {
        needsTransformingCollateral = _needsTransformingCollateral;
    }

    /// @notice setWhitelistedAddresses enables whitelist addresses of given array
    /// @param _whitelistedAddresses array of whitelisted addresses
    /// @param _flag adding or removing from whitelist (true: add, false: remove)
    function setWhitelistedAddresses(
        address[] calldata _whitelistedAddresses,
        bool _flag,
        uint8 _group
    ) external onlyOwner {
        require(_whitelistedAddresses.length > 0, "Whitelisted addresses cannot be empty");
        for (uint256 index = 0; index < _whitelistedAddresses.length; index++) {
            // only if current flag is different, if same skip it
            if (_group == 1) {
                if (whitelistedAddresses[_whitelistedAddresses[index]] != _flag) {
                    whitelistedAddresses[_whitelistedAddresses[index]] = _flag;
                    emit AddedIntoWhitelist(_whitelistedAddresses[index], _flag);
                }
            }
            if (_group == 2) {
                if (whitelistedCancelAddresses[_whitelistedAddresses[index]] != _flag) {
                    whitelistedCancelAddresses[_whitelistedAddresses[index]] = _flag;
                    emit AddedIntoWhitelist(_whitelistedAddresses[index], _flag);
                }
            }
        }
    }

    /* ========== VIEWS ========== */

    /* ---------- Market Information ---------- */

    function isKnownMarket(address candidate) public view override returns (bool) {
        return _activeMarkets.contains(candidate) || _maturedMarkets.contains(candidate);
    }

    function isActiveMarket(address candidate) public view override returns (bool) {
        return _activeMarkets.contains(candidate) && !ISportPositionalMarket(candidate).paused();
    }

    function isDoubleChanceMarket(address candidate) public view override returns (bool) {
        return isDoubleChance[candidate];
    }

    function numActiveMarkets() external view override returns (uint) {
        return _activeMarkets.elements.length;
    }

    function activeMarkets(uint index, uint pageSize) external view override returns (address[] memory) {
        return _activeMarkets.getPage(index, pageSize);
    }

    function numMaturedMarkets() external view override returns (uint) {
        return _maturedMarkets.elements.length;
    }

    function getActiveMarketAddress(uint _index) external view override returns (address) {
        if (_index < _activeMarkets.elements.length) {
            return _activeMarkets.elements[_index];
        } else {
            return address(0);
        }
    }

    function getDoubleChanceMarketsByParentMarket(address market) external view returns (address[] memory) {
        if (doubleChanceMarketsByParent[market].length > 0) {
            address[] memory markets = new address[](3);
            for (uint i = 0; i < doubleChanceMarketsByParent[market].length; i++) {
                markets[i] = doubleChanceMarketsByParent[market][i];
            }
            return markets;
        }
    }

    function maturedMarkets(uint index, uint pageSize) external view override returns (address[] memory) {
        return _maturedMarkets.getPage(index, pageSize);
    }

    function setMarketPaused(address _market, bool _paused) external override {
        require(
            msg.sender == owner ||
                msg.sender == theRundownConsumer ||
                msg.sender == oddsObtainer ||
                msg.sender == playerProps ||
                whitelistedAddresses[msg.sender],
            "Invalid caller"
        );
        require(ISportPositionalMarket(_market).paused() != _paused, "No state change");
        ISportPositionalMarket(_market).setPaused(_paused);
    }

    function updateDatesForMarket(address _market, uint256 _newStartTime) external override {
        require(msg.sender == owner || msg.sender == theRundownConsumer, "Invalid caller");

        uint expiry = _newStartTime.add(expiryDuration);

        // Update main market
        _updateDatesForMarket(_market, _newStartTime, expiry);

        // Update child markets
        _updateDatesForChildMarkets(_market, _newStartTime, expiry, oddsObtainer);
        _updateDatesForChildMarkets(_market, _newStartTime, expiry, playerProps);
    }

    function _updateDatesForChildMarkets(
        address _market,
        uint256 _newStartTime,
        uint256 _expiry,
        address _childMarketContract
    ) internal {
        uint numberOfChildMarkets = IGameChildMarket(_childMarketContract).numberOfChildMarkets(_market);

        for (uint i = 0; i < numberOfChildMarkets; i++) {
            address child = IGameChildMarket(_childMarketContract).mainMarketChildMarketIndex(_market, i);
            _updateDatesForMarket(child, _newStartTime, _expiry);
        }
    }

    function isMarketPaused(address _market) external view override returns (bool) {
        return ISportPositionalMarket(_market).paused();
    }

    function queryMintsAndMaturityStatusForParents(address[] memory _parents)
        external
        view
        returns (
            bool[] memory _hasAnyMintsArray,
            bool[] memory _isMaturedArray,
            bool[] memory _isResolvedArray
        )
    {
        _hasAnyMintsArray = new bool[](_parents.length);
        _isMaturedArray = new bool[](_parents.length);
        _isResolvedArray = new bool[](_parents.length);
        for (uint i = 0; i < _parents.length; i++) {
            (bool _hasAnyMints, uint _maturity) = _hasAnyMintsAndMaturityDatesForMarket(_parents[i]);
            _isResolvedArray[i] = _isResolvedMarket(_parents[i]);
            _hasAnyMintsArray[i] = _hasAnyMints;
            _isMaturedArray[i] = _maturity <= block.timestamp;
        }
    }

    function queryMintsAndMaturityStatusForPlayerProps(address[] memory _playerPropsMarkets)
        external
        view
        override
        returns (
            bool[] memory _hasAnyMintsArray,
            bool[] memory _isMaturedArray,
            bool[] memory _isResolvedArray,
            uint[] memory _maturities
        )
    {
        _hasAnyMintsArray = new bool[](_playerPropsMarkets.length);
        _isMaturedArray = new bool[](_playerPropsMarkets.length);
        _isResolvedArray = new bool[](_playerPropsMarkets.length);
        _maturities = new uint[](_playerPropsMarkets.length);
        for (uint i = 0; i < _playerPropsMarkets.length; i++) {
            (bool _hasAnyMints, uint _maturity) = _hasAnyMintsAndMaturityDatesForPP(_playerPropsMarkets[i]);
            _isResolvedArray[i] = _isResolvedMarket(_playerPropsMarkets[i]);
            _hasAnyMintsArray[i] = _hasAnyMints;
            _isMaturedArray[i] = _maturity <= block.timestamp;
            _maturities[i] = _maturity;
        }
    }

    function _hasAnyMintsAndMaturityDatesForMarket(address _parent)
        internal
        view
        returns (bool _hasAnyMints, uint _maturity)
    {
        ISportPositionalMarket marketContract = ISportPositionalMarket(_parent);
        (uint maturity, ) = marketContract.times();
        _hasAnyMints = marketContract.optionsInitialized() || _hasAnyMintsForChildren(_parent);
        _maturity = maturity;
    }

    function _hasAnyMintsAndMaturityDatesForPP(address _market) internal view returns (bool _hasAnyMints, uint _maturity) {
        ISportPositionalMarket marketContract = ISportPositionalMarket(_market);
        (uint maturity, ) = marketContract.times();
        _hasAnyMints = marketContract.optionsInitialized();
        _maturity = maturity;
    }

    function _isResolvedMarket(address _market) internal view returns (bool _flag) {
        return ISportPositionalMarket(_market).resolved();
    }

    /* ========== MUTATIVE FUNCTIONS ========== */

    /* ---------- Setters ---------- */

    function setExpiryDuration(uint _expiryDuration) public onlyOwner {
        expiryDuration = _expiryDuration;
        emit ExpiryDurationUpdated(_expiryDuration);
    }

    function setsUSD(address _address) external onlyOwner {
        sUSD = IERC20(_address);
        emit SetsUSD(_address);
    }

    /* ---------- Deposit Management ---------- */

    function incrementTotalDeposited(uint delta) external onlyActiveMarkets notPaused {
        totalDeposited = totalDeposited.add(delta);
    }

    function decrementTotalDeposited(uint delta) external onlyKnownMarkets notPaused {
        // NOTE: As individual market debt is not tracked here, the underlying markets
        //       need to be careful never to subtract more debt than they added.
        //       This can't be enforced without additional state/communication overhead.
        totalDeposited = totalDeposited.sub(delta);
    }

    /* ---------- Market Lifecycle ---------- */

    function createMarket(
        bytes32 gameId,
        string memory gameLabel,
        uint maturity,
        uint initialMint, // initial sUSD to mint options for,
        uint positionCount,
        uint[] memory tags,
        bool isChild,
        address parentMarket
    )
        external
        override
        notPaused
        returns (
            ISportPositionalMarket // no support for returning PositionalMarket polymorphically given the interface
        )
    {
        require(marketCreationEnabled, "Market creation is disabled");
        require(
            msg.sender == theRundownConsumer || msg.sender == oddsObtainer || msg.sender == playerProps,
            "Invalid creator"
        );

        uint expiry = maturity.add(expiryDuration);

        require(block.timestamp < maturity, "Maturity has to be in the future");
        // We also require maturity < expiry. But there is no need to check this.
        // The market itself validates the capital and skew requirements.

        ISportPositionalMarket market = _createMarket(
            SportPositionalMarketFactory.SportPositionCreationMarketParameters(
                msg.sender,
                gameId,
                gameLabel,
                [maturity, expiry],
                positionCount,
                tags,
                isChild,
                parentMarket,
                false
            )
        );

        if (positionCount > 2 && isDoubleChanceSupported) {
            _createDoubleChanceMarkets(msg.sender, gameId, maturity, expiry, address(market), tags[0]);
        }

        return market;
    }

    function createDoubleChanceMarketsForParent(address market) external notPaused onlyOwner {
        require(marketCreationEnabled, "Market creation is disabled");
        require(isDoubleChanceSupported, "Double chance not supported");
        ISportPositionalMarket marketContract = ISportPositionalMarket(market);

        require(marketContract.optionsCount() > 2, "Not supported for 2 options market");

        (uint maturity, uint expiry) = marketContract.times();
        _createDoubleChanceMarkets(
            marketContract.creator(),
            marketContract.getGameId(),
            maturity,
            expiry,
            market,
            marketContract.tags(0)
        );
    }

    function _createMarket(SportPositionalMarketFactory.SportPositionCreationMarketParameters memory parameters)
        internal
        returns (ISportPositionalMarket)
    {
        SportPositionalMarket market = SportPositionalMarketFactory(sportPositionalMarketFactory).createMarket(parameters);

        _activeMarkets.add(address(market));

        (IPosition up, IPosition down, IPosition draw) = market.getOptions();

        emit MarketCreated(
            address(market),
            parameters.creator,
            parameters.gameId,
            parameters.times[0],
            parameters.times[1],
            address(up),
            address(down),
            address(draw)
        );
        emit MarketLabel(address(market), parameters.gameLabel);
        return market;
    }

    function _createDoubleChanceMarkets(
        address creator,
        bytes32 gameId,
        uint maturity,
        uint expiry,
        address market,
        uint tag
    ) internal onlySupportedGameId(gameId) {
        string[3] memory labels = ["HomeTeamNotToLose", "AwayTeamNotToLose", "NoDraw"];
        uint[] memory tagsDoubleChance = new uint[](2);
        tagsDoubleChance[0] = tag;
        tagsDoubleChance[1] = 10003;
        for (uint i = 0; i < 3; i++) {
            ISportPositionalMarket doubleChanceMarket = _createMarket(
                SportPositionalMarketFactory.SportPositionCreationMarketParameters(
                    creator,
                    gameId,
                    labels[i],
                    [maturity, expiry],
                    2,
                    tagsDoubleChance,
                    false,
                    address(market),
                    true
                )
            );
            _activeMarkets.add(address(doubleChanceMarket));

            doubleChanceMarketsByParent[address(market)].push(address(doubleChanceMarket));
            isDoubleChance[address(doubleChanceMarket)] = true;

            IGamesOddsObtainer(oddsObtainer).setChildMarketGameId(gameId, address(doubleChanceMarket));

            emit DoubleChanceMarketCreated(address(market), address(doubleChanceMarket), tagsDoubleChance[1], labels[i]);
        }
    }

    function transferSusdTo(
        address sender,
        address receiver,
        uint amount
    ) external override {
        //only to be called by markets themselves
        require(isKnownMarket(address(msg.sender)), "Market unknown.");
        amount = _transformCollateral(amount);
        amount = needsTransformingCollateral ? amount + 1 : amount;
        bool success = sUSD.transferFrom(sender, receiver, amount);
        if (!success) {
            revert("TransferFrom function failed");
        }
    }

    function resolveMarket(address market, uint _outcome) external override {
        require(
            msg.sender == theRundownConsumer ||
                msg.sender == owner ||
                msg.sender == oddsObtainer ||
                msg.sender == playerProps ||
                whitelistedCancelAddresses[msg.sender],
            "Invalid resolver"
        );
        require(_activeMarkets.contains(market), "Not an active market");
        require(!isDoubleChance[market], "Not supported for double chance markets");
        // unpause if paused
        if (ISportPositionalMarket(market).paused()) {
            ISportPositionalMarket(market).setPaused(false);
        }
        SportPositionalMarket(market).resolve(_outcome);
        _activeMarkets.remove(market);
        _maturedMarkets.add(market);

        if (doubleChanceMarketsByParent[market].length > 0) {
            if (_outcome == 1) {
                // HomeTeamNotLose, NoDraw
                SportPositionalMarket(doubleChanceMarketsByParent[market][0]).resolve(1);
                SportPositionalMarket(doubleChanceMarketsByParent[market][1]).resolve(2);
                SportPositionalMarket(doubleChanceMarketsByParent[market][2]).resolve(1);
            } else if (_outcome == 2) {
                // AwayTeamNotLose, NoDraw
                SportPositionalMarket(doubleChanceMarketsByParent[market][0]).resolve(2);
                SportPositionalMarket(doubleChanceMarketsByParent[market][1]).resolve(1);
                SportPositionalMarket(doubleChanceMarketsByParent[market][2]).resolve(1);
            } else if (_outcome == 3) {
                // HomeTeamNotLose, AwayTeamNotLose
                SportPositionalMarket(doubleChanceMarketsByParent[market][0]).resolve(1);
                SportPositionalMarket(doubleChanceMarketsByParent[market][1]).resolve(1);
                SportPositionalMarket(doubleChanceMarketsByParent[market][2]).resolve(2);
            } else {
                // cancelled
                SportPositionalMarket(doubleChanceMarketsByParent[market][0]).resolve(0);
                SportPositionalMarket(doubleChanceMarketsByParent[market][1]).resolve(0);
                SportPositionalMarket(doubleChanceMarketsByParent[market][2]).resolve(0);
            }
            for (uint i = 0; i < doubleChanceMarketsByParent[market].length; i++) {
                _activeMarkets.remove(doubleChanceMarketsByParent[market][i]);
                _maturedMarkets.add(doubleChanceMarketsByParent[market][i]);
            }
        }
    }

    function resolveMarketWithResult(
        address _market,
        uint _outcome,
        uint8 _homeScore,
        uint8 _awayScore,
        address _consumer,
        bool _useBackupOdds
    ) external {
        require(msg.sender == owner || whitelistedCancelAddresses[msg.sender], "Invalid resolver");
        require(!isDoubleChance[_market], "Not supported for double chance markets");

        if (_outcome != 0) {
            require(!_useBackupOdds, "Only use backup odds on cancelation, if needed!");
        }

        if (_consumer == theRundownConsumer) {
            ITherundownConsumer(theRundownConsumer).resolveMarketManually(
                _market,
                _outcome,
                _homeScore,
                _awayScore,
                _useBackupOdds
            );
        }
    }

    function cancelMarketsForParents(address[] memory _parents) external {
        for (uint i = 0; i < _parents.length; i++) {
            require(!isDoubleChance[_parents[i]], "Not supported for double chance markets");
            (bool _hasAnyMints, uint _maturity) = _hasAnyMintsAndMaturityDatesForMarket(_parents[i]);
            if (!_hasAnyMints && _maturity <= block.timestamp && !_isResolvedMarket(_parents[i])) {
                ITherundownConsumer(theRundownConsumer).resolveMarketManually(_parents[i], 0, 0, 0, false);
            }
        }
    }

    function cancelMarketsForPlayerProps(address[] memory _playerPropsMarkets) external {
        for (uint i = 0; i < _playerPropsMarkets.length; i++) {
            require(!isDoubleChance[_playerPropsMarkets[i]], "Not supported for double chance markets");
            (bool _hasAnyMints, uint _maturity) = _hasAnyMintsAndMaturityDatesForPP(_playerPropsMarkets[i]);
            if (!_hasAnyMints && _maturity <= block.timestamp && !_isResolvedMarket(_playerPropsMarkets[i])) {
                IGamesPlayerProps(playerProps).cancelMarketFromManager(_playerPropsMarkets[i]);
            }
        }
    }

    function overrideResolveWithCancel(address market, uint _outcome) external {
        require(msg.sender == owner || whitelistedCancelAddresses[msg.sender], "Invalid resolver");
        require(_outcome == 0, "Can only set 0 outcome");
        require(SportPositionalMarket(market).resolved(), "Market not resolved");
        require(!_activeMarkets.contains(market), "Active market");
        require(!isDoubleChance[market], "Not supported for double chance markets");
        // unpause if paused
        if (ISportPositionalMarket(market).paused()) {
            ISportPositionalMarket(market).setPaused(false);
        }
        SportPositionalMarket(market).resolve(_outcome);

        if (doubleChanceMarketsByParent[market].length > 0) {
            SportPositionalMarket(doubleChanceMarketsByParent[market][0]).resolve(0);
            SportPositionalMarket(doubleChanceMarketsByParent[market][1]).resolve(0);
            SportPositionalMarket(doubleChanceMarketsByParent[market][2]).resolve(0);
        }
    }

    function expireMarkets(address[] calldata markets) external override notPaused onlyOwner {
        for (uint i = 0; i < markets.length; i++) {
            address market = markets[i];

            require(isKnownMarket(address(market)), "Market unknown.");

            // The market itself handles decrementing the total deposits.
            SportPositionalMarket(market).expire(payable(msg.sender));

            // Note that we required that the market is known, which guarantees
            // its index is defined and that the list of markets is not empty.
            _maturedMarkets.remove(market);

            emit MarketExpired(market);
        }
    }

    function restoreInvalidOddsForMarket(
        address _market,
        uint _homeOdds,
        uint _awayOdds,
        uint _drawOdds
    ) external onlyOwner {
        require(isKnownMarket(address(_market)), "Market unknown.");
        require(SportPositionalMarket(_market).cancelled(), "Market not cancelled.");
        SportPositionalMarket(_market).restoreInvalidOdds(_homeOdds, _awayOdds, _drawOdds);
        emit OddsForMarketRestored(_market, _homeOdds, _awayOdds, _drawOdds);
    }

    function setMarketCreationEnabled(bool enabled) external onlyOwner {
        if (enabled != marketCreationEnabled) {
            marketCreationEnabled = enabled;
            emit MarketCreationEnabledUpdated(enabled);
        }
    }

    function setCancelTimeout(uint _cancelTimeout) external onlyOwner {
        cancelTimeout = _cancelTimeout;
    }

    function setIsDoubleChanceSupported(bool _isDoubleChanceSupported) external onlyOwner {
        isDoubleChanceSupported = _isDoubleChanceSupported;
        emit DoubleChanceSupportChanged(_isDoubleChanceSupported);
    }

    function setSupportedSportForDoubleChance(uint[] memory _sportIds, bool _isSupported) external onlyOwner {
        for (uint256 index = 0; index < _sportIds.length; index++) {
            // only if current flag is different, if same skip it
            if (doesSportSupportDoubleChance[_sportIds[index]] != _isSupported) {
                doesSportSupportDoubleChance[_sportIds[index]] = _isSupported;
                emit SupportedSportForDoubleChanceAdded(_sportIds[index], _isSupported);
            }
        }
    }

    // support USDC with 6 decimals
    function transformCollateral(uint value) external view override returns (uint) {
        return _transformCollateral(value);
    }

    function _transformCollateral(uint value) internal view returns (uint) {
        if (needsTransformingCollateral) {
            return value / 1e12;
        } else {
            return value;
        }
    }

    function _updateDatesForMarket(
        address _market,
        uint256 _newStartTime,
        uint256 _expiry
    ) internal {
        ISportPositionalMarket(_market).updateDates(_newStartTime, _expiry);

        emit DatesUpdatedForMarket(_market, _newStartTime, _expiry);
    }

    function _hasAnyMintsForChildren(address _market) internal view returns (bool) {
        return _hasAnyMints(_market, true) || _hasAnyMints(_market, false);
    }

    function _hasAnyMints(address _market, bool checkPlayerProps) internal view returns (bool) {
        uint numberOfChildMarkets;
        address childMarketContract;

        if (checkPlayerProps) {
            numberOfChildMarkets = IGameChildMarket(playerProps).numberOfChildMarkets(_market);
            childMarketContract = playerProps;
        } else {
            numberOfChildMarkets = IGameChildMarket(oddsObtainer).numberOfChildMarkets(_market);
            childMarketContract = oddsObtainer;
        }

        for (uint i = 0; i < numberOfChildMarkets; i++) {
            address child = IGameChildMarket(childMarketContract).mainMarketChildMarketIndex(_market, i);
            if (ISportPositionalMarket(child).optionsInitialized()) {
                return true;
            }
        }

        return false;
    }

    function reverseTransformCollateral(uint value) external view override returns (uint) {
        if (needsTransformingCollateral) {
            return value * 1e12;
        } else {
            return value;
        }
    }

    function isWhitelistedAddress(address _address) external view override returns (bool) {
        return whitelistedAddresses[_address];
    }

    /* ========== MODIFIERS ========== */

    modifier onlyActiveMarkets() {
        require(_activeMarkets.contains(msg.sender), "Permitted only for active markets.");
        _;
    }

    modifier onlyKnownMarkets() {
        require(isKnownMarket(msg.sender), "Permitted only for known markets.");
        _;
    }

    modifier onlySupportedGameId(bytes32 gameId) {
        uint sportId = ITherundownConsumer(theRundownConsumer).sportsIdPerGame(gameId);
        if (doesSportSupportDoubleChance[sportId] && isDoubleChanceSupported) {
            _;
        }
    }

    /* ========== EVENTS ========== */

    event MarketCreated(
        address market,
        address indexed creator,
        bytes32 indexed gameId,
        uint maturityDate,
        uint expiryDate,
        address up,
        address down,
        address draw
    );
    event MarketLabel(address market, string gameLabel);
    event MarketExpired(address market);
    event MarketCreationEnabledUpdated(bool enabled);
    event MarketsMigrated(SportPositionalMarketManager receivingManager, SportPositionalMarket[] markets);
    event MarketsReceived(SportPositionalMarketManager migratingManager, SportPositionalMarket[] markets);
    event SetMigratingManager(address migratingManager);
    event ExpiryDurationUpdated(uint duration);
    event MaxTimeToMaturityUpdated(uint duration);
    event CreatorCapitalRequirementUpdated(uint value);
    event SetSportPositionalMarketFactory(address _sportPositionalMarketFactory);
    event SetsUSD(address _address);
    event SetTherundownConsumer(address theRundownConsumer);
    event SetObtainerAddress(address _obratiner);
    event SetPlayerPropsAddress(address _playerProps);
    event OddsForMarketRestored(address _market, uint _homeOdds, uint _awayOdds, uint _drawOdds);
    event AddedIntoWhitelist(address _whitelistAddress, bool _flag);
    event DatesUpdatedForMarket(address _market, uint256 _newStartTime, uint256 _expiry);
    event DoubleChanceMarketCreated(address _parentMarket, address _doubleChanceMarket, uint tag, string label);
    event DoubleChanceSupportChanged(bool _isDoubleChanceSupported);
    event SupportedSportForDoubleChanceAdded(uint _sportId, bool _isSupported);
}

File 2 of 27 : 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 3 of 27 : 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 4 of 27 : 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 5 of 27 : SafeMath.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (utils/math/SafeMath.sol)

pragma solidity ^0.8.0;

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

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

    /**
     * @dev Returns the subtraction 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 6 of 27 : SportPositionalMarketFactory.sol
pragma solidity ^0.8.0;

// Inheritance
import "../../utils/proxy/solidity-0.8.0/ProxyOwned.sol";

// Internal references
import "./SportPosition.sol";
import "./SportPositionalMarket.sol";
import "./SportPositionalMarketFactory.sol";
import "@openzeppelin/contracts-4.4.1/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts-4.4.1/proxy/Clones.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";

contract SportPositionalMarketFactory is Initializable, ProxyOwned {
    /* ========== STATE VARIABLES ========== */
    address public positionalMarketManager;

    address public positionalMarketMastercopy;
    address public positionMastercopy;

    address public sportsAMM;

    struct SportPositionCreationMarketParameters {
        address creator;
        bytes32 gameId;
        string gameLabel;
        uint[2] times; // [maturity, expiry]
        uint positionCount;
        uint[] tags;
        bool isChild;
        address parentMarket;
        bool isDoubleChance;
    }

    /* ========== INITIALIZER ========== */

    function initialize(address _owner) external initializer {
        setOwner(_owner);
    }

    /* ========== MUTATIVE FUNCTIONS ========== */

    function createMarket(SportPositionCreationMarketParameters calldata _parameters)
        external
        returns (SportPositionalMarket)
    {
        require(positionalMarketManager == msg.sender, "Only permitted by the manager.");

        SportPositionalMarket pom = SportPositionalMarket(Clones.clone(positionalMarketMastercopy));
        address[] memory positions = new address[](_parameters.positionCount);

        pom.initialize(
            SportPositionalMarket.SportPositionalMarketParameters(
                positionalMarketManager,
                _parameters.creator,
                _parameters.gameId,
                _parameters.gameLabel,
                _parameters.times,
                _parameters.positionCount,
                positions,
                _parameters.tags,
                _parameters.isChild,
                _parameters.parentMarket,
                _parameters.isDoubleChance,
                address(this)
            )
        );
        emit MarketCreated(
            address(pom),
            _parameters.gameId,
            _parameters.gameLabel,
            _parameters.times[0],
            _parameters.times[1],
            0,
            _parameters.positionCount,
            _parameters.tags,
            _parameters.isChild,
            _parameters.parentMarket
        );
        return pom;
    }

    /* ========== SETTERS ========== */
    function setSportPositionalMarketManager(address _positionalMarketManager) external onlyOwner {
        positionalMarketManager = _positionalMarketManager;
        emit SportPositionalMarketManagerChanged(_positionalMarketManager);
    }

    function setSportPositionalMarketMastercopy(address _positionalMarketMastercopy) external onlyOwner {
        positionalMarketMastercopy = _positionalMarketMastercopy;
        emit SportPositionalMarketMastercopyChanged(_positionalMarketMastercopy);
    }

    function setSportPositionMastercopy(address _positionMastercopy) external onlyOwner {
        positionMastercopy = _positionMastercopy;
        emit SportPositionMastercopyChanged(_positionMastercopy);
    }

    function setSportsAMM(address _sportsAMM) external onlyOwner {
        sportsAMM = _sportsAMM;
        emit SetSportsAMM(_sportsAMM);
    }

    event SportPositionalMarketManagerChanged(address _positionalMarketManager);
    event SportPositionalMarketMastercopyChanged(address _positionalMarketMastercopy);
    event SportPositionMastercopyChanged(address _positionMastercopy);
    event SetSportsAMM(address _sportsAMM);
    event SetLimitOrderProvider(address _limitOrderProvider);
    event MarketCreated(
        address market,
        bytes32 indexed gameId,
        string gameLabel,
        uint maturityDate,
        uint expiryDate,
        uint initialMint,
        uint positionCount,
        uint[] tags,
        bool isChild,
        address parent
    );
}

File 7 of 27 : SportPositionalMarket.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

// Inheritance
import "../../OwnedWithInit.sol";
import "../../interfaces/ISportPositionalMarket.sol";
import "../../interfaces/ITherundownConsumer.sol";
import "../../interfaces/ISportsAMM.sol";
import "../../interfaces/ISportPositionalMarketFactory.sol";

// Libraries
import "@openzeppelin/contracts-4.4.1/utils/math/SafeMath.sol";

// Internal references
import "./SportPositionalMarketManager.sol";
import "./SportPosition.sol";
import "@openzeppelin/contracts-4.4.1/token/ERC20/IERC20.sol";

contract SportPositionalMarket is OwnedWithInit, ISportPositionalMarket {
    /* ========== LIBRARIES ========== */

    using SafeMath for uint;

    /* ========== TYPES ========== */

    struct Options {
        SportPosition home;
        SportPosition away;
        SportPosition draw;
    }

    struct Times {
        uint maturity;
        uint expiry;
    }

    struct GameDetails {
        bytes32 gameId;
        string gameLabel;
    }

    struct SportPositionalMarketParameters {
        address owner;
        address creator;
        bytes32 gameId;
        string gameLabel;
        uint[2] times; // [maturity, expiry]
        uint positionCount;
        address[] positions;
        uint[] tags;
        bool isChild;
        address parentMarket;
        bool isDoubleChance;
        address factory;
    }

    /* ========== STATE VARIABLES ========== */

    Options public options;
    uint public override optionsCount;
    Times public parentTimes;
    GameDetails private gameDetails;
    string private childGameLabel;
    uint[] public override tags;
    uint public finalResult;

    // `deposited` tracks the sum of all deposits.
    // This must explicitly be kept, in case tokens are transferred to the contract directly.
    uint public override deposited;
    address public override creator;
    bool public override resolved;
    bool public override cancelled;
    uint public cancelTimestamp;
    uint public homeOddsOnCancellation;
    uint public awayOddsOnCancellation;
    uint public drawOddsOnCancellation;

    bool public invalidOdds;
    bool public initialized = false;
    bool public override paused;
    bool public override isChild;
    ISportPositionalMarket public override parentMarket;

    bool public override isDoubleChance;
    bool public override optionsInitialized;
    address public factory;

    /* ========== CONSTRUCTOR ========== */
    function initialize(SportPositionalMarketParameters calldata _parameters) external {
        require(!initialized, "Positional Market already initialized");
        initialized = true;
        initOwner(_parameters.owner);

        optionsCount = _parameters.positionCount;
        require(optionsCount == _parameters.positions.length, "Position count mismatch");

        creator = _parameters.creator;
        if (_parameters.isChild || _parameters.isDoubleChance) {
            isChild = _parameters.isChild;
            isDoubleChance = _parameters.isDoubleChance;
            parentMarket = ISportPositionalMarket(_parameters.parentMarket);
            childGameLabel = _parameters.gameLabel;
        } else {
            parentTimes = Times(_parameters.times[0], _parameters.times[1]);
            gameDetails = GameDetails(_parameters.gameId, _parameters.gameLabel);
        }

        tags = _parameters.tags;
        factory = _parameters.factory;
    }

    /* ---------- External Contracts ---------- */

    function _manager() internal view returns (SportPositionalMarketManager) {
        return SportPositionalMarketManager(owner);
    }

    /* ---------- Phases ---------- */

    function _times() internal view returns (Times memory) {
        if (isChild || isDoubleChance) {
            (uint maturity, uint expiry) = parentMarket.times();
            return Times(maturity, expiry);
        }
        return parentTimes;
    }

    function _matured() internal view returns (bool) {
        return _times().maturity < block.timestamp;
    }

    function _expired() internal view returns (bool) {
        return resolved && (_times().expiry < block.timestamp || deposited == 0);
    }

    function _isPaused() internal view returns (bool) {
        return isDoubleChance ? parentMarket.paused() : paused;
    }

    function getTags() external view override returns (uint tag1, uint tag2) {
        if (tags.length > 1) {
            tag1 = tags[0];
            tag2 = tags[1];
        } else {
            tag1 = tags[0];
        }
    }

    function getTagsLength() external view override returns (uint tagsLength) {
        return tags.length;
    }

    function times() external view override returns (uint maturity, uint destruction) {
        Times memory time = _times();
        return (time.maturity, time.expiry);
    }

    function phase() external view override returns (Phase) {
        if (!_matured()) {
            return Phase.Trading;
        }
        if (!_expired()) {
            return Phase.Maturity;
        }
        return Phase.Expiry;
    }

    function setPaused(bool _paused) external override onlyOwner managerNotPaused {
        require(paused != _paused, "State not changed");
        paused = _paused;
        emit PauseUpdated(_paused);
    }

    function updateDates(uint256 _maturity, uint256 _expiry) external override onlyOwner managerNotPaused noDoubleChance {
        require(_maturity > block.timestamp, "Maturity must be in a future");
        if (!isChild) {
            parentTimes = Times(_maturity, _expiry);
        }
        emit DatesUpdated(_maturity, _expiry);
    }

    /* ---------- Market Resolution ---------- */

    function canResolve() public view override returns (bool) {
        return !resolved && _matured() && !paused;
    }

    function getGameDetails() external view override returns (bytes32 gameId, string memory gameLabel) {
        return (_getDetails().gameId, _getDetails().gameLabel);
    }

    function getParentMarketPositionsUint() public view override returns (uint position1, uint position2) {
        if (isDoubleChance) {
            (IPosition home, , ) = parentMarket.getOptions();
            if (_hasNotBeenInitialized(home)) {
                if (
                    keccak256(abi.encodePacked(_getDetails().gameLabel)) == keccak256(abi.encodePacked("HomeTeamNotToLose"))
                ) {
                    (position1, position2) = (0, 2);
                } else if (
                    keccak256(abi.encodePacked(_getDetails().gameLabel)) == keccak256(abi.encodePacked("AwayTeamNotToLose"))
                ) {
                    (position1, position2) = (1, 2);
                } else {
                    (position1, position2) = (0, 1);
                }
            }
        }
    }

    function getParentMarketPositions() public view override returns (IPosition position1, IPosition position2) {
        if (isDoubleChance) {
            (IPosition home, IPosition away, IPosition draw) = parentMarket.getOptions();
            if (keccak256(abi.encodePacked(_getDetails().gameLabel)) == keccak256(abi.encodePacked("HomeTeamNotToLose"))) {
                (position1, position2) = (home, draw);
            } else if (
                keccak256(abi.encodePacked(_getDetails().gameLabel)) == keccak256(abi.encodePacked("AwayTeamNotToLose"))
            ) {
                (position1, position2) = (away, draw);
            } else {
                (position1, position2) = (home, away);
            }
        }
    }

    function _result() internal view returns (Side) {
        if (!resolved || cancelled) {
            return Side.Cancelled;
        } else if (finalResult == 3 && optionsCount > 2) {
            return Side.Draw;
        } else {
            return finalResult == 1 ? Side.Home : Side.Away;
        }
    }

    function result() external view override returns (Side) {
        return _result();
    }

    /* ---------- Option Balances and Mints ---------- */
    function getGameId() external view override returns (bytes32) {
        return _getDetails().gameId;
    }

    function getStampedOdds()
        public
        view
        override
        returns (
            uint,
            uint,
            uint
        )
    {
        if (cancelled) {
            if (isDoubleChance) {
                (uint position1Odds, uint position2Odds) = _getParentPositionOdds();

                return (position1Odds + position2Odds, 0, 0);
            }
            return (homeOddsOnCancellation, awayOddsOnCancellation, drawOddsOnCancellation);
        } else {
            return (0, 0, 0);
        }
    }

    function _getParentPositionOdds() internal view returns (uint odds1, uint odds2) {
        (uint homeOddsParent, uint awayOddsParent, uint drawOddsParent) = parentMarket.getStampedOdds();
        (IPosition position1, IPosition position2) = getParentMarketPositions();
        (IPosition home, IPosition away, ) = parentMarket.getOptions();

        if (_hasNotBeenInitialized(home)) {
            return (0, 0);
        }

        odds1 = position1 == home ? homeOddsParent : position1 == away ? awayOddsParent : drawOddsParent;
        odds2 = position2 == home ? homeOddsParent : position2 == away ? awayOddsParent : drawOddsParent;
    }

    function _balancesOf(address account)
        internal
        view
        returns (
            uint home,
            uint away,
            uint draw
        )
    {
        if (!optionsInitialized) {
            return (0, 0, 0);
        }
        if (optionsCount > 2) {
            return (
                options.home.getBalanceOf(account),
                options.away.getBalanceOf(account),
                options.draw.getBalanceOf(account)
            );
        }
        return (options.home.getBalanceOf(account), options.away.getBalanceOf(account), 0);
    }

    function balancesOf(address account)
        external
        view
        override
        returns (
            uint home,
            uint away,
            uint draw
        )
    {
        return _balancesOf(account);
    }

    function totalSupplies()
        external
        view
        override
        returns (
            uint home,
            uint away,
            uint draw
        )
    {
        if (optionsCount > 2) {
            return (options.home.totalSupply(), options.away.totalSupply(), options.draw.totalSupply());
        }
        return (options.home.totalSupply(), options.away.totalSupply(), 0);
    }

    function getOptions()
        external
        view
        override
        returns (
            IPosition home,
            IPosition away,
            IPosition draw
        )
    {
        home = options.home;
        away = options.away;
        draw = options.draw;
    }

    function _getMaximumBurnable(address account) internal view returns (uint amount) {
        (uint homeBalance, uint awayBalance, uint drawBalance) = _balancesOf(account);
        uint min = homeBalance;
        if (min > awayBalance) {
            min = awayBalance;
            if (optionsCount > 2 && drawBalance < min) {
                min = drawBalance;
            }
        } else {
            if (optionsCount > 2 && drawBalance < min) {
                min = drawBalance;
            }
        }
        return min;
    }

    function _getDetails() internal view returns (GameDetails memory) {
        if (isChild || isDoubleChance) {
            (bytes32 gameId, ) = parentMarket.getGameDetails();
            return GameDetails(gameId, childGameLabel);
        }
        return gameDetails;
    }

    /* ---------- Utilities ---------- */

    function _incrementDeposited(uint value) internal returns (uint _deposited) {
        _deposited = deposited.add(value);
        deposited = _deposited;
        _manager().incrementTotalDeposited(value);
    }

    function _decrementDeposited(uint value) internal returns (uint _deposited) {
        _deposited = deposited.sub(value);
        deposited = _deposited;
        _manager().decrementTotalDeposited(value);
    }

    function _requireManagerNotPaused() internal view {
        require(!_manager().paused(), "This action cannot be performed while the contract is paused");
    }

    function requireUnpaused() external view {
        _requireManagerNotPaused();
    }

    /* ========== MUTATIVE FUNCTIONS ========== */

    /* ---------- Minting ---------- */

    function mint(uint value) external override {
        require(!_matured() && !_isPaused(), "Minting inactive");
        require(msg.sender == ISportPositionalMarketFactory(factory).sportsAMM(), "Invalid minter");
        if (value == 0) {
            return;
        }

        _mint(msg.sender, value);

        if (!isDoubleChance) {
            _incrementDeposited(value);
            _manager().transferSusdTo(msg.sender, address(this), value);
        }
    }

    function _mint(address minter, uint amount) internal {
        if (!optionsInitialized) {
            _initializeOptions();
        }
        if (isDoubleChance) {
            options.home.mint(minter, amount);
            emit Mint(Side.Home, minter, amount);
        } else {
            options.home.mint(minter, amount);
            options.away.mint(minter, amount);
            emit Mint(Side.Home, minter, amount);
            emit Mint(Side.Away, minter, amount);
            if (optionsCount > 2) {
                options.draw.mint(minter, amount);
                emit Mint(Side.Draw, minter, amount);
            }
        }
    }

    function initializeOptions() external override {
        _initializeOptions();
    }

    function _initializeOptions() internal {
        require(!optionsInitialized, "already initialized");
        address[] memory positions = new address[](optionsCount);
        for (uint i = 0; i < optionsCount; i++) {
            positions[i] = address(SportPosition(Clones.clone(ISportPositionalMarketFactory(factory).positionMastercopy())));
        }

        // Instantiate the options themselves
        options.home = SportPosition(positions[0]);
        options.away = SportPosition(positions[1]);
        if (isChild) {
            require(tags.length > 1, "Child markets must have more then one tag");
            if (tags[1] == 10001) {
                options.home.initialize(_getDetails().gameLabel, "HOME", ISportPositionalMarketFactory(factory).sportsAMM());
                options.away.initialize(_getDetails().gameLabel, "AWAY", ISportPositionalMarketFactory(factory).sportsAMM());
            } else if (tags[1] == 10002 || tags[1] == 10010) {
                options.home.initialize(_getDetails().gameLabel, "OVER", ISportPositionalMarketFactory(factory).sportsAMM());
                options.away.initialize(
                    _getDetails().gameLabel,
                    "UNDER",
                    ISportPositionalMarketFactory(factory).sportsAMM()
                );
            }
        } else {
            options.home.initialize(_getDetails().gameLabel, "HOME", ISportPositionalMarketFactory(factory).sportsAMM());
            options.away.initialize(_getDetails().gameLabel, "AWAY", ISportPositionalMarketFactory(factory).sportsAMM());
        }

        if (optionsCount > 2) {
            options.draw = SportPosition(positions[2]);
            options.draw.initialize(_getDetails().gameLabel, "DRAW", ISportPositionalMarketFactory(factory).sportsAMM());
        }
        optionsInitialized = true;
        emit PositionsInitialized(
            address(this),
            address(options.home),
            address(options.away),
            optionsCount > 2 ? address(options.draw) : address(0)
        );
    }

    function _hasNotBeenInitialized(IPosition home) internal view returns (bool) {
        return address(home) == address(0);
    }

    /* ---------- Market Resolution ---------- */

    function resolve(uint _outcome) external onlyOwner managerNotPaused {
        require(_outcome <= optionsCount, "Invalid outcome");
        if (_outcome == 0) {
            cancelled = true;
            cancelTimestamp = block.timestamp;
            if (!isDoubleChance) {
                stampOdds();
            }
        } else {
            require(canResolve(), "Can not resolve market");
        }
        finalResult = _outcome;
        resolved = true;
        emit MarketResolved(_result(), deposited, 0, 0);
    }

    function stampOdds() internal {
        uint[] memory odds = new uint[](optionsCount);
        odds = ITherundownConsumer(creator).getNormalizedOddsForMarket(address(this));
        if (odds[0] == 0 || odds[1] == 0) {
            invalidOdds = true;
        }
        homeOddsOnCancellation = odds[0];
        awayOddsOnCancellation = odds[1];
        drawOddsOnCancellation = optionsCount > 2 ? odds[2] : 0;
        emit StoredOddsOnCancellation(homeOddsOnCancellation, awayOddsOnCancellation, drawOddsOnCancellation);
    }

    /* ---------- Claiming and Exercising Options ---------- */

    function exerciseOptions() external override {
        // The market must be resolved if it has not been.
        require(resolved, "Unresolved");
        require(!_isPaused(), "Paused");
        // If the account holds no options, revert.
        (uint homeBalance, uint awayBalance, uint drawBalance) = _balancesOf(msg.sender);
        require(homeBalance != 0 || awayBalance != 0 || drawBalance != 0, "Nothing to exercise");

        if (isDoubleChance && _canExerciseParentOptions()) {
            parentMarket.exerciseOptions();
        }
        // Each option only needs to be exercised if the account holds any of it.
        if (homeBalance != 0) {
            options.home.exercise(msg.sender);
        }
        if (awayBalance != 0) {
            options.away.exercise(msg.sender);
        }
        if (drawBalance != 0) {
            options.draw.exercise(msg.sender);
        }
        uint payout = _getPayout(homeBalance, awayBalance, drawBalance);

        if (cancelled) {
            require(
                block.timestamp > cancelTimestamp.add(_manager().cancelTimeout()) && !invalidOdds,
                "Unexpired timeout/ invalid odds"
            );
            payout = calculatePayoutOnCancellation(homeBalance, awayBalance, drawBalance);
        }
        emit OptionsExercised(msg.sender, payout);
        if (payout != 0) {
            if (!isDoubleChance) {
                _decrementDeposited(payout);
            }
            payout = _manager().transformCollateral(payout);
            ISportsAMM(ISportPositionalMarketFactory(factory).sportsAMM()).sUSD().transfer(msg.sender, payout);
        }
    }

    function _canExerciseParentOptions() internal view returns (bool) {
        if (!parentMarket.resolved() && !parentMarket.canResolve()) {
            return false;
        }

        (uint homeBalance, uint awayBalance, uint drawBalance) = parentMarket.balancesOf(address(this));

        if (homeBalance == 0 && awayBalance == 0 && drawBalance == 0) {
            return false;
        }

        return true;
    }

    function _getPayout(
        uint homeBalance,
        uint awayBalance,
        uint drawBalance
    ) internal view returns (uint payout) {
        if (isDoubleChance) {
            if (_result() == Side.Home) {
                payout = homeBalance;
            }
        } else {
            payout = (_result() == Side.Home) ? homeBalance : awayBalance;

            if (optionsCount > 2 && _result() != Side.Home) {
                payout = _result() == Side.Away ? awayBalance : drawBalance;
            }
        }
    }

    function restoreInvalidOdds(
        uint _homeOdds,
        uint _awayOdds,
        uint _drawOdds
    ) external override onlyOwner {
        require(_homeOdds > 0 && _awayOdds > 0, "Invalid odd");
        homeOddsOnCancellation = _homeOdds;
        awayOddsOnCancellation = _awayOdds;
        drawOddsOnCancellation = optionsCount > 2 ? _drawOdds : 0;
        invalidOdds = false;
        emit StoredOddsOnCancellation(homeOddsOnCancellation, awayOddsOnCancellation, drawOddsOnCancellation);
    }

    function calculatePayoutOnCancellation(
        uint _homeBalance,
        uint _awayBalance,
        uint _drawBalance
    ) public view returns (uint payout) {
        if (!cancelled) {
            return 0;
        } else {
            if (isDoubleChance) {
                (uint position1Odds, uint position2Odds) = _getParentPositionOdds();
                payout = _homeBalance.mul(position1Odds).div(1e18);
                payout = payout.add(_homeBalance.mul(position2Odds).div(1e18));
            } else {
                payout = _homeBalance.mul(homeOddsOnCancellation).div(1e18);
                payout = payout.add(_awayBalance.mul(awayOddsOnCancellation).div(1e18));
                payout = payout.add(_drawBalance.mul(drawOddsOnCancellation).div(1e18));
            }
        }
    }

    /* ---------- Market Expiry ---------- */

    function _selfDestruct(address payable beneficiary) internal {
        uint _deposited = deposited;
        if (_deposited != 0) {
            _decrementDeposited(_deposited);
        }

        // Transfer the balance rather than the deposit value in case there are any synths left over
        // from direct transfers.
        uint balance = ISportsAMM(ISportPositionalMarketFactory(factory).sportsAMM()).sUSD().balanceOf(address(this));
        if (balance != 0) {
            ISportsAMM(ISportPositionalMarketFactory(factory).sportsAMM()).sUSD().transfer(beneficiary, balance);
        }

        // Destroy the option tokens before destroying the market itself.
        options.home.expire(beneficiary);
        options.away.expire(beneficiary);
        selfdestruct(beneficiary);
    }

    function expire(address payable beneficiary) external onlyOwner {
        require(_expired(), "Unexpired options remaining");
        emit Expired(beneficiary);
        _selfDestruct(beneficiary);
    }

    /* ========== MODIFIERS ========== */

    modifier managerNotPaused() {
        _requireManagerNotPaused();
        _;
    }

    modifier noDoubleChance() {
        require(!isDoubleChance, "Not supported for double chance markets");
        _;
    }

    /* ========== EVENTS ========== */

    event Mint(Side side, address indexed account, uint value);
    event MarketResolved(Side result, uint deposited, uint poolFees, uint creatorFees);

    event OptionsExercised(address indexed account, uint value);
    event OptionsBurned(address indexed account, uint value);
    event Expired(address beneficiary);
    event StoredOddsOnCancellation(uint homeOdds, uint awayOdds, uint drawOdds);
    event PauseUpdated(bool _paused);
    event DatesUpdated(uint256 _maturity, uint256 _expiry);
    event PositionsInitialized(address _market, address _home, address _away, address _draw);
}

File 8 of 27 : SportPosition.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

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

import "../../interfaces/IPosition.sol";

// Libraries
import "@openzeppelin/contracts-4.4.1/utils/math/SafeMath.sol";

// Internal references
import "./SportPositionalMarket.sol";

contract SportPosition is IERC20, IPosition {
    /* ========== LIBRARIES ========== */

    using SafeMath for uint;

    /* ========== STATE VARIABLES ========== */

    string public name;
    string public symbol;
    uint8 public constant decimals = 18;

    SportPositionalMarket public market;

    mapping(address => uint) public override balanceOf;
    uint public override totalSupply;

    // The argument order is allowance[owner][spender]
    mapping(address => mapping(address => uint)) private allowances;

    // Enforce a 1 cent minimum amount
    uint internal constant _MINIMUM_AMOUNT = 1e16;

    address public sportsAMM;
    /* ========== CONSTRUCTOR ========== */

    bool public initialized = false;

    function initialize(
        string calldata _name,
        string calldata _symbol,
        address _sportsAMM
    ) external {
        require(!initialized, "Positional Market already initialized");
        initialized = true;
        name = _name;
        symbol = _symbol;
        market = SportPositionalMarket(msg.sender);
        // add through constructor
        sportsAMM = _sportsAMM;
    }

    function allowance(address owner, address spender) external view override returns (uint256) {
        if (spender == sportsAMM) {
            return 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff;
        } else {
            return allowances[owner][spender];
        }
    }

    function _requireMinimumAmount(uint amount) internal pure returns (uint) {
        require(amount >= _MINIMUM_AMOUNT || amount == 0, "Balance < $0.01");
        return amount;
    }

    function mint(address minter, uint amount) external onlyMarket {
        _requireMinimumAmount(amount);
        totalSupply = totalSupply.add(amount);
        balanceOf[minter] = balanceOf[minter].add(amount); // Increment rather than assigning since a transfer may have occurred.

        emit Transfer(address(0), minter, amount);
        emit Issued(minter, amount);
    }

    // This must only be invoked after maturity.
    function exercise(address claimant) external onlyMarket {
        uint balance = balanceOf[claimant];

        if (balance == 0) {
            return;
        }

        balanceOf[claimant] = 0;
        totalSupply = totalSupply.sub(balance);

        emit Transfer(claimant, address(0), balance);
        emit Burned(claimant, balance);
    }

    // This must only be invoked after maturity.
    function exerciseWithAmount(address claimant, uint amount) external override onlyMarket {
        require(amount > 0, "Can not exercise zero amount!");

        require(balanceOf[claimant] >= amount, "Balance must be greather or equal amount that is burned");

        balanceOf[claimant] = balanceOf[claimant] - amount;
        totalSupply = totalSupply.sub(amount);

        emit Transfer(claimant, address(0), amount);
        emit Burned(claimant, amount);
    }

    // This must only be invoked after the exercise window is complete.
    // Note that any options which have not been exercised will linger.
    function expire(address payable beneficiary) external onlyMarket {
        selfdestruct(beneficiary);
    }

    /* ---------- ERC20 Functions ---------- */

    function _transfer(
        address _from,
        address _to,
        uint _value
    ) internal returns (bool success) {
        market.requireUnpaused();
        require(_to != address(0) && _to != address(this), "Invalid address");

        uint fromBalance = balanceOf[_from];
        require(_value <= fromBalance, "Insufficient balance");

        balanceOf[_from] = fromBalance.sub(_value);
        balanceOf[_to] = balanceOf[_to].add(_value);

        emit Transfer(_from, _to, _value);
        return true;
    }

    function transfer(address _to, uint _value) external override returns (bool success) {
        return _transfer(msg.sender, _to, _value);
    }

    function transferFrom(
        address _from,
        address _to,
        uint _value
    ) external override returns (bool success) {
        if (msg.sender != sportsAMM) {
            uint fromAllowance = allowances[_from][msg.sender];
            require(_value <= fromAllowance, "Insufficient allowance");
            allowances[_from][msg.sender] = fromAllowance.sub(_value);
        }
        return _transfer(_from, _to, _value);
    }

    function approve(address _spender, uint _value) external override returns (bool success) {
        require(_spender != address(0));
        allowances[msg.sender][_spender] = _value;
        emit Approval(msg.sender, _spender, _value);
        return true;
    }

    function getBalanceOf(address account) external view override returns (uint) {
        return balanceOf[account];
    }

    function getTotalSupply() external view override returns (uint) {
        return totalSupply;
    }

    /* ========== MODIFIERS ========== */

    modifier onlyMarket() {
        require(msg.sender == address(market), "Only market allowed");
        _;
    }

    /* ========== EVENTS ========== */

    event Issued(address indexed account, uint value);
    event Burned(address indexed account, uint value);
}

File 9 of 27 : ISportPositionalMarketManager.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "../interfaces/ISportPositionalMarket.sol";

interface ISportPositionalMarketManager {
    /* ========== VIEWS / VARIABLES ========== */

    function marketCreationEnabled() external view returns (bool);

    function totalDeposited() external view returns (uint);

    function numActiveMarkets() external view returns (uint);

    function activeMarkets(uint index, uint pageSize) external view returns (address[] memory);

    function numMaturedMarkets() external view returns (uint);

    function maturedMarkets(uint index, uint pageSize) external view returns (address[] memory);

    function isActiveMarket(address candidate) external view returns (bool);

    function isDoubleChanceMarket(address candidate) external view returns (bool);

    function doesSportSupportDoubleChance(uint _sport) external view returns (bool);

    function isDoubleChanceSupported() external view returns (bool);

    function isKnownMarket(address candidate) external view returns (bool);

    function getActiveMarketAddress(uint _index) external view returns (address);

    function transformCollateral(uint value) external view returns (uint);

    function reverseTransformCollateral(uint value) external view returns (uint);

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

    function expiryDuration() external view returns (uint);

    function isWhitelistedAddress(address _address) external view returns (bool);

    function getOddsObtainer() external view returns (address obtainer);

    /* ========== MUTATIVE FUNCTIONS ========== */

    function createMarket(
        bytes32 gameId,
        string memory gameLabel,
        uint maturity,
        uint initialMint, // initial sUSD to mint options for,
        uint positionCount,
        uint[] memory tags,
        bool isChild,
        address parentMarket
    ) external returns (ISportPositionalMarket);

    function setMarketPaused(address _market, bool _paused) external;

    function updateDatesForMarket(address _market, uint256 _newStartTime) external;

    function resolveMarket(address market, uint outcome) external;

    function expireMarkets(address[] calldata market) external;

    function transferSusdTo(
        address sender,
        address receiver,
        uint amount
    ) external;

    function queryMintsAndMaturityStatusForPlayerProps(address[] memory _playerPropsMarkets)
        external
        view
        returns (
            bool[] memory _hasAnyMintsArray,
            bool[] memory _isMaturedArray,
            bool[] memory _isResolvedArray,
            uint[] memory _maturities
        );
}

File 10 of 27 : ISportPositionalMarket.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.5.16;

import "../interfaces/IPositionalMarketManager.sol";
import "../interfaces/IPosition.sol";
import "../interfaces/IPriceFeed.sol";

interface ISportPositionalMarket {
    /* ========== TYPES ========== */

    enum Phase {
        Trading,
        Maturity,
        Expiry
    }
    enum Side {
        Cancelled,
        Home,
        Away,
        Draw
    }

    /* ========== VIEWS / VARIABLES ========== */

    function getOptions()
        external
        view
        returns (
            IPosition home,
            IPosition away,
            IPosition draw
        );

    function times() external view returns (uint maturity, uint destruction);

    function getGameDetails() external view returns (bytes32 gameId, string memory gameLabel);

    function getGameId() external view returns (bytes32);

    function deposited() external view returns (uint);

    function optionsCount() external view returns (uint);

    function creator() external view returns (address);

    function resolved() external view returns (bool);

    function cancelled() external view returns (bool);

    function paused() external view returns (bool);

    function phase() external view returns (Phase);

    function canResolve() external view returns (bool);

    function result() external view returns (Side);

    function isChild() external view returns (bool);

    function optionsInitialized() external view returns (bool);

    function tags(uint idx) external view returns (uint);

    function getTags() external view returns (uint tag1, uint tag2);

    function getTagsLength() external view returns (uint tagsLength);

    function getParentMarketPositions() external view returns (IPosition position1, IPosition position2);

    function getParentMarketPositionsUint() external view returns (uint position1, uint position2);

    function getStampedOdds()
        external
        view
        returns (
            uint,
            uint,
            uint
        );

    function balancesOf(address account)
        external
        view
        returns (
            uint home,
            uint away,
            uint draw
        );

    function totalSupplies()
        external
        view
        returns (
            uint home,
            uint away,
            uint draw
        );

    function isDoubleChance() external view returns (bool);

    function parentMarket() external view returns (ISportPositionalMarket);

    /* ========== MUTATIVE FUNCTIONS ========== */

    function setPaused(bool _paused) external;

    function updateDates(uint256 _maturity, uint256 _expiry) external;

    function mint(uint value) external;

    function exerciseOptions() external;

    function restoreInvalidOdds(
        uint _homeOdds,
        uint _awayOdds,
        uint _drawOdds
    ) external;

    function initializeOptions() external;
}

File 11 of 27 : ITherundownConsumer.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

interface ITherundownConsumer {
    struct GameCreate {
        bytes32 gameId;
        uint256 startTime;
        int24 homeOdds;
        int24 awayOdds;
        int24 drawOdds;
        string homeTeam;
        string awayTeam;
    }

    // view functions
    function supportedSport(uint _sportId) external view returns (bool);

    function gameOnADate(bytes32 _gameId) external view returns (uint);

    function isGameResolvedOrCanceled(bytes32 _gameId) external view returns (bool);

    function getNormalizedOddsForMarket(address _market) external view returns (uint[] memory);

    function getGamesPerDatePerSport(uint _sportId, uint _date) external view returns (bytes32[] memory);

    function getGamePropsForOdds(address _market)
        external
        view
        returns (
            uint,
            uint,
            bytes32
        );

    function gameIdPerMarket(address _market) external view returns (bytes32);

    function getGameCreatedById(bytes32 _gameId) external view returns (GameCreate memory);

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

    function gameFulfilledCreated(bytes32 _gameId) external view returns (bool);

    function playerProps() external view returns (address);

    function oddsObtainer() external view returns (address);

    // write functions
    function fulfillGamesCreated(
        bytes32 _requestId,
        bytes[] memory _games,
        uint _sportsId,
        uint _date
    ) external;

    function fulfillGamesResolved(
        bytes32 _requestId,
        bytes[] memory _games,
        uint _sportsId
    ) external;

    function fulfillGamesOdds(bytes32 _requestId, bytes[] memory _games) external;

    function setPausedByCanceledStatus(address _market, bool _flag) external;

    function setGameIdPerChildMarket(bytes32 _gameId, address _child) external;

    function pauseOrUnpauseMarket(address _market, bool _pause) external;

    function pauseOrUnpauseMarketForPlayerProps(
        address _market,
        bool _pause,
        bool _invalidOdds,
        bool _circuitBreakerMain
    ) external;

    function setChildMarkets(
        bytes32 _gameId,
        address _main,
        address _child,
        bool _isSpread,
        int16 _spreadHome,
        uint24 _totalOver
    ) external;

    function resolveMarketManually(
        address _market,
        uint _outcome,
        uint8 _homeScore,
        uint8 _awayScore,
        bool _usebackupOdds
    ) external;

    function getOddsForGame(bytes32 _gameId)
        external
        view
        returns (
            int24,
            int24,
            int24
        );

    function sportsIdPerGame(bytes32 _gameId) external view returns (uint);

    function getGameStartTime(bytes32 _gameId) external view returns (uint256);

    function getLastUpdatedFromGameResolve(bytes32 _gameId) external view returns (uint40);

    function marketPerGameId(bytes32 _gameId) external view returns (address);

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

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

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

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

    function isSportOnADate(uint _date, uint _sportId) external view returns (bool);

    function isSportTwoPositionsSport(uint _sportsId) external view returns (bool);
}

File 12 of 27 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

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

    /**
     * @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 `to`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address to, 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 `from` to `to` 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 from,
        address to,
        uint256 amount
    ) external returns (bool);
}

File 13 of 27 : 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 14 of 27 : IGamesOddsObtainer.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

interface IGamesOddsObtainer {
    struct GameOdds {
        bytes32 gameId;
        int24 homeOdds;
        int24 awayOdds;
        int24 drawOdds;
        int16 spreadHome;
        int24 spreadHomeOdds;
        int16 spreadAway;
        int24 spreadAwayOdds;
        uint24 totalOver;
        int24 totalOverOdds;
        uint24 totalUnder;
        int24 totalUnderOdds;
    }

    // view

    function getActiveChildMarketsFromParent(address _parent) external view returns (address, address);

    function getSpreadTotalsChildMarketsFromParent(address _parent)
        external
        view
        returns (
            uint numOfSpreadMarkets,
            address[] memory spreadMarkets,
            uint numOfTotalsMarkets,
            address[] memory totalMarkets
        );

    function areOddsValid(bytes32 _gameId, bool _useBackup) external view returns (bool);

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

    function getNormalizedOdds(bytes32 _gameId) external view returns (uint[] memory);

    function getNormalizedOddsForMarket(address _market) external view returns (uint[] memory);

    function getOddsForGames(bytes32[] memory _gameIds) external view returns (int24[] memory odds);

    function mainMarketChildMarketIndex(address _main, uint _index) external view returns (address);

    function numberOfChildMarkets(address _main) external view returns (uint);

    function mainMarketSpreadChildMarket(address _main, int16 _spread) external view returns (address);

    function mainMarketTotalChildMarket(address _main, uint24 _total) external view returns (address);

    function childMarketMainMarket(address _market) external view returns (address);

    function childMarketTotal(address _market) external view returns (uint24);

    function currentActiveTotalChildMarket(address _main) external view returns (address);

    function currentActiveSpreadChildMarket(address _main) external view returns (address);

    function isSpreadChildMarket(address _child) external view returns (bool);

    function childMarketCreated(address _child) external view returns (bool);

    function getOddsForGame(bytes32 _gameId)
        external
        view
        returns (
            int24,
            int24,
            int24,
            int24,
            int24,
            int24,
            int24
        );

    function getLinesForGame(bytes32 _gameId)
        external
        view
        returns (
            int16,
            int16,
            uint24,
            uint24
        );

    // executable

    function obtainOdds(
        bytes32 requestId,
        GameOdds memory _game,
        uint _sportId
    ) external;

    function setFirstOdds(
        bytes32 _gameId,
        int24 _homeOdds,
        int24 _awayOdds,
        int24 _drawOdds
    ) external;

    function setFirstNormalizedOdds(bytes32 _gameId, address _market) external;

    function setBackupOddsAsMainOddsForGame(bytes32 _gameId) external;

    function pauseUnpauseChildMarkets(address _main, bool _flag) external;

    function pauseUnpauseCurrentActiveChildMarket(
        bytes32 _gameId,
        address _main,
        bool _flag
    ) external;

    function resolveChildMarkets(
        address _market,
        uint _outcome,
        uint8 _homeScore,
        uint8 _awayScore
    ) external;

    function setChildMarketGameId(bytes32 gameId, address market) external;
}

File 15 of 27 : IGamesPlayerProps.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

interface IGamesPlayerProps {
    struct PlayerProps {
        bytes32 gameId;
        bytes32 playerId;
        uint8 option;
        string playerName;
        uint16 line;
        int24 overOdds;
        int24 underOdds;
    }

    struct PlayerPropsResolver {
        bytes32 gameId;
        bytes32 playerId;
        uint8 option;
        uint16 score;
        uint8 statusId;
    }

    function obtainPlayerProps(PlayerProps memory _player, uint _sportId) external;

    function resolvePlayerProps(PlayerPropsResolver memory _result) external;

    function cancelMarketFromManager(address _market) external;

    function pauseAllPlayerPropsMarketForMain(
        address _main,
        bool _flag,
        bool _invalidOddsOnMain,
        bool _circuitBreakerMain
    ) external;

    function createFulfilledForPlayerProps(
        bytes32 gameId,
        bytes32 playerId,
        uint8 option
    ) external view returns (bool);

    function cancelPlayerPropsMarketForMain(address _main) external;

    function getNormalizedOddsForMarket(address _market) external view returns (uint[] memory);

    function mainMarketChildMarketIndex(address _main, uint _index) external view returns (address);

    function numberOfChildMarkets(address _main) external view returns (uint);

    function doesSportSupportPlayerProps(uint _sportId) external view returns (bool);

    function pausedByInvalidOddsOnMain(address _main) external view returns (bool);

    function pausedByCircuitBreakerOnMain(address _main) external view returns (bool);

    function playerIdPerChildMarket(address _market) external view returns (bytes32);

    function optionIdPerChildMarket(address _market) external view returns (uint8);

    function getAllOptionsWithPlayersForGameId(bytes32 _gameId)
        external
        view
        returns (
            bytes32[] memory _playerIds,
            uint8[] memory _options,
            bool[] memory _isResolved,
            address[][] memory _childMarketsPerOption
        );

    function getPlayerPropsDataForMarket(address _market)
        external
        view
        returns (
            address,
            bytes32,
            bytes32,
            uint8
        );

    function getPlayerPropForOption(
        bytes32 gameId,
        bytes32 playerId,
        uint8 option
    )
        external
        view
        returns (
            uint16,
            int24,
            int24,
            bool
        );

    function fulfillPlayerPropsCLResolved(bytes[] memory _playerProps) external;
}

File 16 of 27 : IGameChildMarket.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

interface IGameChildMarket {
    function mainMarketChildMarketIndex(address _main, uint _index) external view returns (address);

    function numberOfChildMarkets(address _main) external view returns (uint);
}

File 17 of 27 : 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 18 of 27 : IPosition.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.5.16;

import "./IPositionalMarket.sol";

interface IPosition {
    /* ========== VIEWS / VARIABLES ========== */

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

    function getTotalSupply() external view returns (uint);

    function exerciseWithAmount(address claimant, uint amount) external;
}

File 19 of 27 : IPositionalMarket.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.5.16;

import "../interfaces/IPositionalMarketManager.sol";
import "../interfaces/IPosition.sol";
import "../interfaces/IPriceFeed.sol";

interface IPositionalMarket {
    /* ========== TYPES ========== */

    enum Phase {
        Trading,
        Maturity,
        Expiry
    }
    enum Side {
        Up,
        Down
    }

    /* ========== VIEWS / VARIABLES ========== */

    function getOptions() external view returns (IPosition up, IPosition down);

    function times() external view returns (uint maturity, uint destructino);

    function getOracleDetails()
        external
        view
        returns (
            bytes32 key,
            uint strikePrice,
            uint finalPrice
        );

    function fees() external view returns (uint poolFee, uint creatorFee);

    function deposited() external view returns (uint);

    function creator() external view returns (address);

    function resolved() external view returns (bool);

    function phase() external view returns (Phase);

    function oraclePrice() external view returns (uint);

    function oraclePriceAndTimestamp() external view returns (uint price, uint updatedAt);

    function canResolve() external view returns (bool);

    function result() external view returns (Side);

    function balancesOf(address account) external view returns (uint up, uint down);

    function totalSupplies() external view returns (uint up, uint down);

    function getMaximumBurnable(address account) external view returns (uint amount);

    /* ========== MUTATIVE FUNCTIONS ========== */

    function mint(uint value) external;

    function exerciseOptions() external returns (uint);

    function burnOptions(uint amount) external;

    function burnOptionsMaximum() external;
}

File 20 of 27 : IPositionalMarketManager.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.5.16;

import "../interfaces/IPositionalMarket.sol";

interface IPositionalMarketManager {
    /* ========== VIEWS / VARIABLES ========== */

    function durations() external view returns (uint expiryDuration, uint maxTimeToMaturity);

    function capitalRequirement() external view returns (uint);

    function marketCreationEnabled() external view returns (bool);

    function onlyAMMMintingAndBurning() external view returns (bool);

    function transformCollateral(uint value) external view returns (uint);

    function reverseTransformCollateral(uint value) external view returns (uint);

    function totalDeposited() external view returns (uint);

    function numActiveMarkets() external view returns (uint);

    function activeMarkets(uint index, uint pageSize) external view returns (address[] memory);

    function numMaturedMarkets() external view returns (uint);

    function maturedMarkets(uint index, uint pageSize) external view returns (address[] memory);

    function isActiveMarket(address candidate) external view returns (bool);

    function isKnownMarket(address candidate) external view returns (bool);

    function getThalesAMM() external view returns (address);

    /* ========== MUTATIVE FUNCTIONS ========== */

    function createMarket(
        bytes32 oracleKey,
        uint strikePrice,
        uint maturity,
        uint initialMint // initial sUSD to mint options for,
    ) external returns (IPositionalMarket);

    function resolveMarket(address market) external;

    function expireMarkets(address[] calldata market) external;

    function transferSusdTo(
        address sender,
        address receiver,
        uint amount
    ) external;
}

File 21 of 27 : IPriceFeed.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.5.16;

interface IPriceFeed {
    // Structs
    struct RateAndUpdatedTime {
        uint216 rate;
        uint40 time;
    }

    // Mutative functions
    function addAggregator(bytes32 currencyKey, address aggregatorAddress) external;

    function removeAggregator(bytes32 currencyKey) external;

    // Views

    function rateForCurrency(bytes32 currencyKey) external view returns (uint);

    function rateAndUpdatedTime(bytes32 currencyKey) external view returns (uint rate, uint time);

    function getRates() external view returns (uint[] memory);

    function getCurrencies() external view returns (bytes32[] memory);
}

File 22 of 27 : OwnedWithInit.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

contract OwnedWithInit {
    address public owner;
    address public nominatedOwner;

    constructor() {}

    function initOwner(address _owner) internal {
        require(owner == address(0), "Init can only be called when owner is 0");
        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);
    }

    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 23 of 27 : ISportsAMM.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

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

interface ISportsAMM {
    /* ========== VIEWS / VARIABLES ========== */

    enum Position {
        Home,
        Away,
        Draw
    }

    struct SellRequirements {
        address user;
        address market;
        Position position;
        uint amount;
        uint expectedPayout;
        uint additionalSlippage;
    }

    function theRundownConsumer() external view returns (address);

    function riskManager() external view returns (ISportAMMRiskManager riskManager);

    function getMarketDefaultOdds(address _market, bool isSell) external view returns (uint[] memory);

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

    function isMarketForSportOnePositional(uint _tag) external view returns (bool);

    function availableToBuyFromAMM(address market, Position position) external view returns (uint _available);

    function parlayAMM() external view returns (address);

    function minSupportedOdds() external view returns (uint);

    function maxSupportedOdds() external view returns (uint);

    function minSupportedOddsPerSport(uint) external view returns (uint);

    function min_spread() external view returns (uint);

    function max_spread() external view returns (uint);

    function minimalTimeLeftToMaturity() external view returns (uint);

    function getSpentOnGame(address market) external view returns (uint);

    function safeBoxImpact() external view returns (uint);

    function manager() external view returns (address);

    function getLiquidityPool() external view returns (address);

    function sUSD() external view returns (IERC20Upgradeable);

    function buyFromAMM(
        address market,
        Position position,
        uint amount,
        uint expectedPayout,
        uint additionalSlippage
    ) external;

    function buyFromAmmQuote(
        address market,
        Position position,
        uint amount
    ) external view returns (uint);

    function buyFromAmmQuoteForParlayAMM(
        address market,
        Position position,
        uint amount
    ) external view returns (uint);

    function updateParlayVolume(address _account, uint _amount) external;

    function buyPriceImpact(
        address market,
        ISportsAMM.Position position,
        uint amount
    ) external view returns (int impact);

    function obtainOdds(address _market, ISportsAMM.Position _position) external view returns (uint oddsToReturn);

    function buyFromAmmQuoteWithDifferentCollateral(
        address market,
        ISportsAMM.Position position,
        uint amount,
        address collateral
    ) external view returns (uint collateralQuote, uint sUSDToPay);

    function availableToBuyFromAMMWithBaseOdds(
        address market,
        ISportsAMM.Position position,
        uint baseOdds,
        uint balance,
        bool useBalance
    ) external view returns (uint availableAmount);

    function floorBaseOdds(uint baseOdds, address market) external view returns (uint);
}

File 24 of 27 : ISportPositionalMarketFactory.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface ISportPositionalMarketFactory {
    function sportsAMM() external view returns (address);

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

File 25 of 27 : ISportAMMRiskManager.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

interface ISportAMMRiskManager {
    function calculateCapToBeUsed(address _market) external view returns (uint toReturn);

    function isTotalSpendingLessThanTotalRisk(uint _totalSpent, address _market) external view returns (bool _isNotRisky);

    function isMarketForSportOnePositional(uint _tag) external view returns (bool);

    function isMarketForPlayerPropsOnePositional(uint _tag) external view returns (bool);

    function minSupportedOddsPerSport(uint tag) external view returns (uint);

    function minSpreadPerSport(uint tag1, uint tag2) external view returns (uint);

    function maxSpreadPerSport(uint tag) external view returns (uint);

    function getMinSpreadToUse(
        bool useDefaultMinSpread,
        address market,
        uint min_spread,
        uint min_spreadPerAddress
    ) external view returns (uint);

    function getMaxSpreadForMarket(address _market, uint max_spread) external view returns (uint);

    function getMinOddsForMarket(address _market, uint minSupportedOdds) external view returns (uint minOdds);

    function getCapAndMaxSpreadForMarket(address _market, uint max_spread) external view returns (uint, uint);

    function getCapMaxSpreadAndMinOddsForMarket(
        address _market,
        uint max_spread,
        uint minSupportedOdds
    )
        external
        view
        returns (
            uint cap,
            uint maxSpread,
            uint minOddsForMarket
        );
}

File 26 of 27 : 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 27 of 27 : 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);
            }
        }
    }
}

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":"_whitelistAddress","type":"address"},{"indexed":false,"internalType":"bool","name":"_flag","type":"bool"}],"name":"AddedIntoWhitelist","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"CreatorCapitalRequirementUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_market","type":"address"},{"indexed":false,"internalType":"uint256","name":"_newStartTime","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_expiry","type":"uint256"}],"name":"DatesUpdatedForMarket","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_parentMarket","type":"address"},{"indexed":false,"internalType":"address","name":"_doubleChanceMarket","type":"address"},{"indexed":false,"internalType":"uint256","name":"tag","type":"uint256"},{"indexed":false,"internalType":"string","name":"label","type":"string"}],"name":"DoubleChanceMarketCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"_isDoubleChanceSupported","type":"bool"}],"name":"DoubleChanceSupportChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"duration","type":"uint256"}],"name":"ExpiryDurationUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"market","type":"address"},{"indexed":true,"internalType":"address","name":"creator","type":"address"},{"indexed":true,"internalType":"bytes32","name":"gameId","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"maturityDate","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"expiryDate","type":"uint256"},{"indexed":false,"internalType":"address","name":"up","type":"address"},{"indexed":false,"internalType":"address","name":"down","type":"address"},{"indexed":false,"internalType":"address","name":"draw","type":"address"}],"name":"MarketCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"enabled","type":"bool"}],"name":"MarketCreationEnabledUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"market","type":"address"}],"name":"MarketExpired","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"market","type":"address"},{"indexed":false,"internalType":"string","name":"gameLabel","type":"string"}],"name":"MarketLabel","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract SportPositionalMarketManager","name":"receivingManager","type":"address"},{"indexed":false,"internalType":"contract SportPositionalMarket[]","name":"markets","type":"address[]"}],"name":"MarketsMigrated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract SportPositionalMarketManager","name":"migratingManager","type":"address"},{"indexed":false,"internalType":"contract SportPositionalMarket[]","name":"markets","type":"address[]"}],"name":"MarketsReceived","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"duration","type":"uint256"}],"name":"MaxTimeToMaturityUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_market","type":"address"},{"indexed":false,"internalType":"uint256","name":"_homeOdds","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_awayOdds","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_drawOdds","type":"uint256"}],"name":"OddsForMarketRestored","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":"migratingManager","type":"address"}],"name":"SetMigratingManager","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_obratiner","type":"address"}],"name":"SetObtainerAddress","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_playerProps","type":"address"}],"name":"SetPlayerPropsAddress","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_sportPositionalMarketFactory","type":"address"}],"name":"SetSportPositionalMarketFactory","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"theRundownConsumer","type":"address"}],"name":"SetTherundownConsumer","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_address","type":"address"}],"name":"SetsUSD","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_sportId","type":"uint256"},{"indexed":false,"internalType":"bool","name":"_isSupported","type":"bool"}],"name":"SupportedSportForDoubleChanceAdded","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":"address[]","name":"_parents","type":"address[]"}],"name":"cancelMarketsForParents","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_playerPropsMarkets","type":"address[]"}],"name":"cancelMarketsForPlayerProps","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"cancelTimeout","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"market","type":"address"}],"name":"createDoubleChanceMarketsForParent","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"gameId","type":"bytes32"},{"internalType":"string","name":"gameLabel","type":"string"},{"internalType":"uint256","name":"maturity","type":"uint256"},{"internalType":"uint256","name":"initialMint","type":"uint256"},{"internalType":"uint256","name":"positionCount","type":"uint256"},{"internalType":"uint256[]","name":"tags","type":"uint256[]"},{"internalType":"bool","name":"isChild","type":"bool"},{"internalType":"address","name":"parentMarket","type":"address"}],"name":"createMarket","outputs":[{"internalType":"contract ISportPositionalMarket","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"customMarketCreationEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"delta","type":"uint256"}],"name":"decrementTotalDeposited","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"doesSportSupportDoubleChance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"doubleChanceMarketsByParent","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"markets","type":"address[]"}],"name":"expireMarkets","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"expiryDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_index","type":"uint256"}],"name":"getActiveMarketAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"market","type":"address"}],"name":"getDoubleChanceMarketsByParentMarket","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getOddsObtainer","outputs":[{"internalType":"address","name":"obtainer","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"delta","type":"uint256"}],"name":"incrementTotalDeposited","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract IERC20","name":"_sUSD","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"candidate","type":"address"}],"name":"isActiveMarket","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"isDoubleChance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"candidate","type":"address"}],"name":"isDoubleChanceMarket","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isDoubleChanceSupported","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"candidate","type":"address"}],"name":"isKnownMarket","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_market","type":"address"}],"name":"isMarketPaused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"}],"name":"isWhitelistedAddress","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastPauseTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"marketCreationEnabled","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":[],"name":"needsTransformingCollateral","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":"numActiveMarkets","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"numMaturedMarkets","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"oddsObtainer","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"market","type":"address"},{"internalType":"uint256","name":"_outcome","type":"uint256"}],"name":"overrideResolveWithCancel","outputs":[],"stateMutability":"nonpayable","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":[],"name":"playerProps","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"_parents","type":"address[]"}],"name":"queryMintsAndMaturityStatusForParents","outputs":[{"internalType":"bool[]","name":"_hasAnyMintsArray","type":"bool[]"},{"internalType":"bool[]","name":"_isMaturedArray","type":"bool[]"},{"internalType":"bool[]","name":"_isResolvedArray","type":"bool[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"_playerPropsMarkets","type":"address[]"}],"name":"queryMintsAndMaturityStatusForPlayerProps","outputs":[{"internalType":"bool[]","name":"_hasAnyMintsArray","type":"bool[]"},{"internalType":"bool[]","name":"_isMaturedArray","type":"bool[]"},{"internalType":"bool[]","name":"_isResolvedArray","type":"bool[]"},{"internalType":"uint256[]","name":"_maturities","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"market","type":"address"},{"internalType":"uint256","name":"_outcome","type":"uint256"}],"name":"resolveMarket","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_market","type":"address"},{"internalType":"uint256","name":"_outcome","type":"uint256"},{"internalType":"uint8","name":"_homeScore","type":"uint8"},{"internalType":"uint8","name":"_awayScore","type":"uint8"},{"internalType":"address","name":"_consumer","type":"address"},{"internalType":"bool","name":"_useBackupOdds","type":"bool"}],"name":"resolveMarketWithResult","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_market","type":"address"},{"internalType":"uint256","name":"_homeOdds","type":"uint256"},{"internalType":"uint256","name":"_awayOdds","type":"uint256"},{"internalType":"uint256","name":"_drawOdds","type":"uint256"}],"name":"restoreInvalidOddsForMarket","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"value","type":"uint256"}],"name":"reverseTransformCollateral","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"sUSD","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_cancelTimeout","type":"uint256"}],"name":"setCancelTimeout","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_expiryDuration","type":"uint256"}],"name":"setExpiryDuration","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_isDoubleChanceSupported","type":"bool"}],"name":"setIsDoubleChanceSupported","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"enabled","type":"bool"}],"name":"setMarketCreationEnabled","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_market","type":"address"},{"internalType":"bool","name":"_paused","type":"bool"}],"name":"setMarketPaused","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_needsTransformingCollateral","type":"bool"}],"name":"setNeedsTransformingCollateral","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_oddsObtainer","type":"address"}],"name":"setOddsObtainer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"setOwner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_paused","type":"bool"}],"name":"setPaused","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_playerProps","type":"address"}],"name":"setPlayerProps","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_sportPositionalMarketFactory","type":"address"}],"name":"setSportPositionalMarketFactory","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_sportIds","type":"uint256[]"},{"internalType":"bool","name":"_isSupported","type":"bool"}],"name":"setSupportedSportForDoubleChance","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_theRundownConsumer","type":"address"}],"name":"setTherundownConsumer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_whitelistedAddresses","type":"address[]"},{"internalType":"bool","name":"_flag","type":"bool"},{"internalType":"uint8","name":"_group","type":"uint8"}],"name":"setWhitelistedAddresses","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"}],"name":"setsUSD","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"sportPositionalMarketFactory","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"theRundownConsumer","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalDeposited","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"proxyAddress","type":"address"}],"name":"transferOwnershipAtInit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferSusdTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"value","type":"uint256"}],"name":"transformCollateral","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_market","type":"address"},{"internalType":"uint256","name":"_newStartTime","type":"uint256"}],"name":"updateDatesForMarket","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"whitelistedAddresses","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"whitelistedCancelAddresses","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}]

608060405234801561001057600080fd5b50615a7280620000216000396000f3fe608060405234801561001057600080fd5b50600436106104075760003560e01c80637fdb733f11610220578063b91f5e3511610130578063e62b8889116100b8578063f65d145411610087578063f65d145414610937578063fab44cbb1461095a578063fb6cede61461096d578063ff50abdc1461098f578063ffbc538a1461099857600080fd5b8063e62b8889146108eb578063e73efc9b146108fe578063ed7afdec14610911578063edc892e11461092457600080fd5b8063c6e9e7d7116100ff578063c6e9e7d714610892578063cf7fb264146108a5578063dd5adfa3146108b8578063e116ee5a146108cb578063e28c130b146108d857600080fd5b8063b91f5e3514610846578063bb96af6514610859578063c014fb841461086c578063c3b83f5f1461087f57600080fd5b80639418f6c7116101b3578063aeab584911610182578063aeab5849146107f3578063b037c8e514610806578063b162e06114610819578063b3ee14241461082a578063b908feb21461083357600080fd5b80639418f6c7146107a25780639eb5d8b4146107c5578063ac60c486146107d8578063ad6b22ce146107e057600080fd5b80638da5cb5b116101ef5780638da5cb5b146107595780638fe812b41461077257806391b4ded9146107865780639324cac71461078f57600080fd5b80637fdb733f146106fd57806385f2a72e1461071057806389c6318d146107235780638d924e731461073657600080fd5b80633c5a2ef01161031b5780635fae0576116102ae5780636b3a09841161027d5780636b3a0984146106a95780636ec38a4e146106bc57806371943de3146106cf57806379ba5097146106e25780637f8c2d61146106ea57600080fd5b80635fae05761461063157806364af2d871461065d57806368c7f2161461066a5780636a5fd5661461067d57600080fd5b806355f14427116102ea57806355f14427146105db5780635c975abb146105ee5780635d7fb8e2146105fb5780635e7ba7101461060e57600080fd5b80633c5a2ef01461058f578063485cc955146105a25780634cde32ce146105b557806353a47bb7146105c857600080fd5b80631627540c1161039e57806317fd849a1161036d57806317fd849a1461053a57806321a92a271461054d57806327d31e3b146105605780633744734d1461057357806339ab4c411461057c57600080fd5b80631627540c146104c957806316c38b3c146104dc578063172653eb146104ef57806317eaaa4a1461050f57600080fd5b80630def299d116103da5780630def299d1461047e5780630e429aeb1461049157806313af4035146104a357806315502840146104b657600080fd5b806302610c501461040c57806306c933d8146104235780630b3be3f3146104565780630c863e061461046b575b600080fd5b6007545b6040519081526020015b60405180910390f35b61044661043136600461501f565b600f6020526000908152604090205460ff1681565b604051901515815260200161041a565b61046961046436600461501f565b6109ab565b005b61046961047936600461501f565b610a08565b61046961048c366004615277565b610a5e565b60055461044690610100900460ff1681565b6104696104b136600461501f565b610c14565b6104696104c43660046154ec565b610d48565b6104696104d736600461501f565b610d85565b6104696104ea366004615356565b610ddb565b6105026104fd36600461501f565b610e51565b60405161041a9190615682565b61052261051d3660046150fc565b610f64565b6040516001600160a01b03909116815260200161041a565b6104106105483660046154ec565b610f9c565b61046961055b36600461501f565b610fca565b61046961056e366004615214565b61134e565b61041060115481565b61046961058a366004615356565b611663565b600e54610522906001600160a01b031681565b6104696105b03660046150cf565b6116bc565b6105226105c33660046153a6565b6117c2565b600154610522906001600160a01b031681565b6104696105e93660046154ec565b6119ea565b6003546104469060ff1681565b601854610522906001600160a01b031681565b61044661061c36600461501f565b60126020526000908152604090205460ff1681565b61044661063f36600461501f565b6001600160a01b03166000908152600f602052604090205460ff1690565b6005546104469060ff1681565b61046961067836600461501f565b6119f7565b61044661068b36600461501f565b6001600160a01b031660009081526014602052604090205460ff1690565b6104696106b73660046154ec565b611a4d565b6104466106ca36600461501f565b611ae2565b6104696106dd36600461501f565b611b6e565b610469611bc4565b6104696106f8366004615097565b611cc1565b61046961070b366004615277565b611e81565b61046961071e36600461501f565b612038565b610502610731366004615504565b61208e565b610749610744366004615277565b6120a3565b60405161041a9493929190615708565b600054610522906201000090046001600160a01b031681565b600e5461044690600160a01b900460ff1681565b61041060025481565b600c54610522906001600160a01b031681565b6104466107b036600461501f565b60146020526000908152604090205460ff1681565b6104696107d33660046150fc565b612333565b600954610410565b601354610522906001600160a01b031681565b6104696108013660046154ec565b6123f3565b610469610814366004615161565b612485565b6013546001600160a01b0316610522565b61041060045481565b610469610841366004615057565b612611565b6104696108543660046150fc565b612747565b600d54610522906001600160a01b031681565b61046961087a3660046151d5565b613143565b61046961088d36600461501f565b613293565b6104696108a0366004615127565b6133ac565b6104466108b336600461501f565b61354e565b6105226108c63660046154ec565b6135c1565b6015546104469060ff1681565b6104696108e6366004615312565b613613565b6104466108f936600461501f565b613743565b61050261090c366004615504565b613761565b61046961091f3660046150fc565b61376f565b6104106109323660046154ec565b613c28565b6104466109453660046154ec565b60176020526000908152604090205460ff1681565b610469610968366004615356565b613c33565b61098061097b366004615277565b613c59565b60405161041a939291906156cf565b61041060065481565b6104696109a6366004615356565b613e66565b6109b3613eaf565b600c80546001600160a01b0319166001600160a01b0383169081179091556040519081527fbae3da9b16d7b09b9f1a0d00cb2fafc0f94895fde1e0e2d9e31529efa028da06906020015b60405180910390a150565b610a10613eaf565b601380546001600160a01b0319166001600160a01b0383169081179091556040519081527fabcd3d442bfb8eed13cda6bd397d12a7a75f9d4b9d85df42729d6470fab78503906020016109fd565b60005b8151811015610c105760146000838381518110610a8e57634e487b7160e01b600052603260045260246000fd5b6020908102919091018101516001600160a01b031682528101919091526040016000205460ff1615610adb5760405162461bcd60e51b8152600401610ad2906157b3565b60405180910390fd5b600080610b0e848481518110610b0157634e487b7160e01b600052603260045260246000fd5b6020026020010151613f29565b9150915081158015610b205750428111155b8015610b595750610b57848481518110610b4a57634e487b7160e01b600052603260045260246000fd5b6020026020010151614021565b155b15610bfb5760185484516001600160a01b0390911690635938541f90869086908110610b9557634e487b7160e01b600052603260045260246000fd5b60200260200101516040518263ffffffff1660e01b8152600401610bc891906001600160a01b0391909116815260200190565b600060405180830381600087803b158015610be257600080fd5b505af1158015610bf6573d6000803e3d6000fd5b505050505b50508080610c08906159d2565b915050610a61565b5050565b6001600160a01b038116610c6a5760405162461bcd60e51b815260206004820152601960248201527f4f776e657220616464726573732063616e6e6f742062652030000000000000006044820152606401610ad2565b600154600160a01b900460ff1615610cd65760405162461bcd60e51b815260206004820152602960248201527f416c726561647920696e697469616c697a65642c20757365206e6f6d696e617460448201526832a732bba7bbb732b960b91b6064820152608401610ad2565b6001805460ff60a01b1916600160a01b179055600080546001600160a01b03831662010000810262010000600160b01b03199092169190911782556040805192835260208301919091527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c91016109fd565b610d50613eaf565b60048190556040518181527ff378a0fd4ad3ffd9d7d50986f16b04acd2dc42691c4f412f34e8eefe883e6652906020016109fd565b610d8d613eaf565b600180546001600160a01b0319166001600160a01b0383169081179091556040519081527f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce22906020016109fd565b610de3613eaf565b60035460ff1615158115151415610df75750565b6003805460ff191682151590811790915560ff1615610e1557426002555b60035460405160ff909116151581527f8fb6c181ee25a520cf3dd6565006ef91229fcfe5a989566c2a3b8c115570cec5906020016109fd565b50565b6001600160a01b03811660009081526016602052604090205460609015610f5f57604080516003808252608082019092526000916020820160608036833701905050905060005b6001600160a01b038416600090815260166020526040902054811015610f58576001600160a01b0384166000908152601660205260409020805482908110610ef057634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b0316828281518110610f2e57634e487b7160e01b600052603260045260246000fd5b6001600160a01b039092166020928302919091019091015280610f50816159d2565b915050610e98565b5092915050565b919050565b60166020528160005260406000208181548110610f8057600080fd5b6000918252602090912001546001600160a01b03169150829050565b600e54600090600160a01b900460ff1615610fc657610fc08264e8d4a5100061599c565b92915050565b5090565b60035460ff1615610fed5760405162461bcd60e51b8152600401610ad2906157fa565b610ff5613eaf565b60055460ff166110475760405162461bcd60e51b815260206004820152601b60248201527f4d61726b6574206372656174696f6e2069732064697361626c656400000000006044820152606401610ad2565b60155460ff166110995760405162461bcd60e51b815260206004820152601b60248201527f446f75626c65206368616e6365206e6f7420737570706f7274656400000000006044820152606401610ad2565b60008190506002816001600160a01b0316631a1dbabb6040518163ffffffff1660e01b815260040160206040518083038186803b1580156110d957600080fd5b505afa1580156110ed573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611111919061538e565b116111695760405162461bcd60e51b815260206004820152602260248201527f4e6f7420737570706f7274656420666f722032206f7074696f6e73206d61726b604482015261195d60f21b6064820152608401610ad2565b600080826001600160a01b0316639e3b34bf6040518163ffffffff1660e01b8152600401604080518083038186803b1580156111a457600080fd5b505afa1580156111b8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111dc9190615525565b91509150611348836001600160a01b03166302d05d3f6040518163ffffffff1660e01b815260040160206040518083038186803b15801561121c57600080fd5b505afa158015611230573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611254919061503b565b846001600160a01b031663c0bd83516040518163ffffffff1660e01b815260040160206040518083038186803b15801561128d57600080fd5b505afa1580156112a1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112c5919061538e565b6040516308208aaf60e21b8152600060048201528590859089906001600160a01b038a16906320822abc9060240160206040518083038186803b15801561130b57600080fd5b505afa15801561131f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611343919061538e565b61405c565b50505050565b611356613eaf565b826113b15760405162461bcd60e51b815260206004820152602560248201527f57686974656c6973746564206164647265737365732063616e6e6f7420626520604482015264656d70747960d81b6064820152608401610ad2565b60005b8381101561165c578160ff166001141561150357821515600f60008787858181106113ef57634e487b7160e01b600052603260045260246000fd5b9050602002016020810190611404919061501f565b6001600160a01b0316815260208101919091526040016000205460ff161515146115035782600f600087878581811061144d57634e487b7160e01b600052603260045260246000fd5b9050602002016020810190611462919061501f565b6001600160a01b031681526020810191909152604001600020805460ff19169115159190911790557f58d7a3ccc34541e162fcfc87b84be7b78c34d1e1e7f15de6e4dd67d0fe70aecd8585838181106114cb57634e487b7160e01b600052603260045260246000fd5b90506020020160208101906114e0919061501f565b604080516001600160a01b03909216825285151560208301520160405180910390a15b8160ff166002141561164a578215156012600087878581811061153657634e487b7160e01b600052603260045260246000fd5b905060200201602081019061154b919061501f565b6001600160a01b0316815260208101919091526040016000205460ff1615151461164a57826012600087878581811061159457634e487b7160e01b600052603260045260246000fd5b90506020020160208101906115a9919061501f565b6001600160a01b031681526020810191909152604001600020805460ff19169115159190911790557f58d7a3ccc34541e162fcfc87b84be7b78c34d1e1e7f15de6e4dd67d0fe70aecd85858381811061161257634e487b7160e01b600052603260045260246000fd5b9050602002016020810190611627919061501f565b604080516001600160a01b03909216825285151560208301520160405180910390a15b80611654816159d2565b9150506113b4565b5050505050565b61166b613eaf565b60055460ff16151581151514610e4e576005805460ff19168215159081179091556040519081527fcc590b6309435383b617aaa0cae6aba938f2ee471cfb539201dd7655a23caff9906020016109fd565b600054610100900460ff166116d75760005460ff16156116db565b303b155b61173e5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610ad2565b600054610100900460ff16158015611760576000805461ffff19166101011790555b61176983610c14565b600c80546001600160a01b0319166001600160a01b0384161790556000805462010000600160b01b0319163362010000021790556005805461ffff1916600117905580156117bd576000805461ff00191690555b505050565b60035460009060ff16156117e85760405162461bcd60e51b8152600401610ad2906157fa565b60055460ff1661183a5760405162461bcd60e51b815260206004820152601b60248201527f4d61726b6574206372656174696f6e2069732064697361626c656400000000006044820152606401610ad2565b600d546001600160a01b031633148061185d57506013546001600160a01b031633145b8061187257506018546001600160a01b031633145b6118b05760405162461bcd60e51b815260206004820152600f60248201526e24b73b30b634b21031b932b0ba37b960891b6044820152606401610ad2565b60006118c76004548961441190919063ffffffff16565b90508742106119185760405162461bcd60e51b815260206004820181905260248201527f4d617475726974792068617320746f20626520696e20746865206675747572656044820152606401610ad2565b600061198d604051806101200160405280336001600160a01b031681526020018d81526020018c815260200160405180604001604052808d81526020018681525081526020018981526020018881526020018715158152602001866001600160a01b031681526020016000151581525061441d565b90506002871180156119a1575060155460ff165b156119dc576119dc338c8b85858b6000815181106119cf57634e487b7160e01b600052603260045260246000fd5b602002602001015161405c565b9a9950505050505050505050565b6119f2613eaf565b601155565b6119ff613eaf565b600d80546001600160a01b0319166001600160a01b0383169081179091556040519081527f82c2f8aad8de17db4e2115c03f9a95266ac400ef1f7c7895c5a6487e45bcb279906020016109fd565b611a5633613743565b611aac5760405162461bcd60e51b815260206004820152602160248201527f5065726d6974746564206f6e6c7920666f72206b6e6f776e206d61726b6574736044820152601760f91b6064820152608401610ad2565b60035460ff1615611acf5760405162461bcd60e51b8152600401610ad2906157fa565b600654611adc908261461f565b60065550565b6000611aef60078361462b565b8015610fc05750816001600160a01b0316635c975abb6040518163ffffffff1660e01b815260040160206040518083038186803b158015611b2f57600080fd5b505afa158015611b43573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b679190615372565b1592915050565b611b76613eaf565b600e80546001600160a01b0319166001600160a01b0383169081179091556040519081527f7860d99a18d1d40974259a27a70db54aed4b0ed3584556d2f266af2a0990be68906020016109fd565b6001546001600160a01b03163314611c3c5760405162461bcd60e51b815260206004820152603560248201527f596f75206d757374206265206e6f6d696e61746564206265666f726520796f7560448201527402063616e20616363657074206f776e65727368697605c1b6064820152608401610ad2565b60005460015460408051620100009093046001600160a01b03908116845290911660208301527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c910160405180910390a1600180546000805462010000600160b01b0319166001600160a01b03831662010000021790556001600160a01b0319169055565b6000546201000090046001600160a01b0316331480611cea5750600d546001600160a01b031633145b80611cff57506013546001600160a01b031633145b80611d1457506018546001600160a01b031633145b80611d2e5750336000908152600f602052604090205460ff165b611d6b5760405162461bcd60e51b815260206004820152600e60248201526d24b73b30b634b21031b0b63632b960911b6044820152606401610ad2565b801515826001600160a01b0316635c975abb6040518163ffffffff1660e01b815260040160206040518083038186803b158015611da757600080fd5b505afa158015611dbb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ddf9190615372565b15151415611e215760405162461bcd60e51b815260206004820152600f60248201526e4e6f207374617465206368616e676560881b6044820152606401610ad2565b6040516305b0e2cf60e21b815281151560048201526001600160a01b038316906316c38b3c906024015b600060405180830381600087803b158015611e6557600080fd5b505af1158015611e79573d6000803e3d6000fd5b505050505050565b60005b8151811015610c105760146000838381518110611eb157634e487b7160e01b600052603260045260246000fd5b6020908102919091018101516001600160a01b031682528101919091526040016000205460ff1615611ef55760405162461bcd60e51b8152600401610ad2906157b3565b600080611f28848481518110611f1b57634e487b7160e01b600052603260045260246000fd5b60200260200101516146ad565b9150915081158015611f3a5750428111155b8015611f665750611f64848481518110610b4a57634e487b7160e01b600052603260045260246000fd5b155b1561202357600d5484516001600160a01b039091169063099177e990869086908110611fa257634e487b7160e01b600052603260045260246000fd5b60209081029190910101516040516001600160e01b031960e084901b1681526001600160a01b0390911660048201526000602482018190526044820181905260648201819052608482015260a401600060405180830381600087803b15801561200a57600080fd5b505af115801561201e573d6000803e3d6000fd5b505050505b50508080612030906159d2565b915050611e84565b612040613eaf565b601880546001600160a01b0319166001600160a01b0383169081179091556040519081527fb29efe346fda749edc8ac04767e9facace07f2dd8deb4ad51a68f5cd887a57fd906020016109fd565b606061209c600984846147aa565b9392505050565b60608060608084516001600160401b038111156120d057634e487b7160e01b600052604160045260246000fd5b6040519080825280602002602001820160405280156120f9578160200160208202803683370190505b50935084516001600160401b0381111561212357634e487b7160e01b600052604160045260246000fd5b60405190808252806020026020018201604052801561214c578160200160208202803683370190505b50925084516001600160401b0381111561217657634e487b7160e01b600052604160045260246000fd5b60405190808252806020026020018201604052801561219f578160200160208202803683370190505b50915084516001600160401b038111156121c957634e487b7160e01b600052604160045260246000fd5b6040519080825280602002602001820160405280156121f2578160200160208202803683370190505b50905060005b855181101561232b57600080612227888481518110610b0157634e487b7160e01b600052603260045260246000fd5b9150915061224e888481518110610b4a57634e487b7160e01b600052603260045260246000fd5b85848151811061226e57634e487b7160e01b600052603260045260246000fd5b602002602001019015159081151581525050818784815181106122a157634e487b7160e01b600052603260045260246000fd5b602002602001019015159081151581525050428111158684815181106122d757634e487b7160e01b600052603260045260246000fd5b6020026020010190151590811515815250508084848151811061230a57634e487b7160e01b600052603260045260246000fd5b60200260200101818152505050508080612323906159d2565b9150506121f8565b509193509193565b6000546201000090046001600160a01b031633148061235c5750600d546001600160a01b031633145b6123995760405162461bcd60e51b815260206004820152600e60248201526d24b73b30b634b21031b0b63632b960911b6044820152606401610ad2565b60006123b06004548361441190919063ffffffff16565b90506123bd8383836148ee565b6013546123d8908490849084906001600160a01b031661499f565b6018546117bd908490849084906001600160a01b031661499f565b6123fe60073361462b565b6124555760405162461bcd60e51b815260206004820152602260248201527f5065726d6974746564206f6e6c7920666f7220616374697665206d61726b6574604482015261399760f11b6064820152608401610ad2565b60035460ff16156124785760405162461bcd60e51b8152600401610ad2906157fa565b600654611adc9082614411565b6000546201000090046001600160a01b03163314806124b357503360009081526012602052604090205460ff165b6124cf5760405162461bcd60e51b8152600401610ad290615760565b6001600160a01b03861660009081526014602052604090205460ff16156125085760405162461bcd60e51b8152600401610ad2906157b3565b84156125745780156125745760405162461bcd60e51b815260206004820152602f60248201527f4f6e6c7920757365206261636b7570206f646473206f6e2063616e63656c617460448201526e696f6e2c206966206e65656465642160881b6064820152608401610ad2565b600d546001600160a01b0383811691161415611e7957600d5460405163099177e960e01b81526001600160a01b0388811660048301526024820188905260ff80881660448401528616606483015283151560848301529091169063099177e99060a401600060405180830381600087803b1580156125f157600080fd5b505af1158015612605573d6000803e3d6000fd5b50505050505050505050565b61261a33613743565b6126365760405162461bcd60e51b8152600401610ad29061578a565b61263f81614acd565b600e54909150600160a01b900460ff166126595780612664565b612664816001615964565b600c546040516323b872dd60e01b81526001600160a01b038681166004830152858116602483015260448201849052929350600092909116906323b872dd90606401602060405180830381600087803b1580156126c057600080fd5b505af11580156126d4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126f89190615372565b9050806113485760405162461bcd60e51b815260206004820152601c60248201527f5472616e7366657246726f6d2066756e6374696f6e206661696c6564000000006044820152606401610ad2565b600d546001600160a01b031633148061277057506000546201000090046001600160a01b031633145b8061278557506013546001600160a01b031633145b8061279a57506018546001600160a01b031633145b806127b457503360009081526012602052604090205460ff165b6127d05760405162461bcd60e51b8152600401610ad290615760565b6127db60078361462b565b61281e5760405162461bcd60e51b8152602060048201526014602482015273139bdd08185b881858dd1a5d99481b585c9ad95d60621b6044820152606401610ad2565b6001600160a01b03821660009081526014602052604090205460ff16156128575760405162461bcd60e51b8152600401610ad2906157b3565b816001600160a01b0316635c975abb6040518163ffffffff1660e01b815260040160206040518083038186803b15801561289057600080fd5b505afa1580156128a4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128c89190615372565b15612928576040516305b0e2cf60e21b8152600060048201526001600160a01b038316906316c38b3c90602401600060405180830381600087803b15801561290f57600080fd5b505af1158015612923573d6000803e3d6000fd5b505050505b604051634f896d4f60e01b8152600481018290526001600160a01b03831690634f896d4f90602401600060405180830381600087803b15801561296a57600080fd5b505af115801561297e573d6000803e3d6000fd5b50505050612996826007614af190919063ffffffff16565b6129a1600983614c74565b6001600160a01b03821660009081526016602052604090205415610c10578060011415612bad576001600160a01b038216600090815260166020526040812080549091906129ff57634e487b7160e01b600052603260045260246000fd5b600091825260209091200154604051634f896d4f60e01b8152600160048201526001600160a01b0390911690634f896d4f90602401600060405180830381600087803b158015612a4e57600080fd5b505af1158015612a62573d6000803e3d6000fd5b505050506001600160a01b038216600090815260166020526040902080546001908110612a9f57634e487b7160e01b600052603260045260246000fd5b600091825260209091200154604051634f896d4f60e01b8152600260048201526001600160a01b0390911690634f896d4f906024015b600060405180830381600087803b158015612aef57600080fd5b505af1158015612b03573d6000803e3d6000fd5b505050506001600160a01b038216600090815260166020526040902080546002908110612b4057634e487b7160e01b600052603260045260246000fd5b600091825260209091200154604051634f896d4f60e01b8152600160048201526001600160a01b0390911690634f896d4f906024015b600060405180830381600087803b158015612b9057600080fd5b505af1158015612ba4573d6000803e3d6000fd5b5050505061305a565b8060021415612cc7576001600160a01b03821660009081526016602052604081208054909190612bed57634e487b7160e01b600052603260045260246000fd5b600091825260209091200154604051634f896d4f60e01b8152600260048201526001600160a01b0390911690634f896d4f90602401600060405180830381600087803b158015612c3c57600080fd5b505af1158015612c50573d6000803e3d6000fd5b505050506001600160a01b038216600090815260166020526040902080546001908110612c8d57634e487b7160e01b600052603260045260246000fd5b600091825260209091200154604051634f896d4f60e01b8152600160048201526001600160a01b0390911690634f896d4f90602401612ad5565b8060031415612e81576001600160a01b03821660009081526016602052604081208054909190612d0757634e487b7160e01b600052603260045260246000fd5b600091825260209091200154604051634f896d4f60e01b8152600160048201526001600160a01b0390911690634f896d4f90602401600060405180830381600087803b158015612d5657600080fd5b505af1158015612d6a573d6000803e3d6000fd5b505050506001600160a01b038216600090815260166020526040902080546001908110612da757634e487b7160e01b600052603260045260246000fd5b600091825260209091200154604051634f896d4f60e01b8152600160048201526001600160a01b0390911690634f896d4f90602401600060405180830381600087803b158015612df657600080fd5b505af1158015612e0a573d6000803e3d6000fd5b505050506001600160a01b038216600090815260166020526040902080546002908110612e4757634e487b7160e01b600052603260045260246000fd5b600091825260209091200154604051634f896d4f60e01b8152600260048201526001600160a01b0390911690634f896d4f90602401612b76565b6001600160a01b03821660009081526016602052604081208054909190612eb857634e487b7160e01b600052603260045260246000fd5b6000918252602082200154604051634f896d4f60e01b815260048101929092526001600160a01b031690634f896d4f90602401600060405180830381600087803b158015612f0557600080fd5b505af1158015612f19573d6000803e3d6000fd5b505050506001600160a01b038216600090815260166020526040902080546001908110612f5657634e487b7160e01b600052603260045260246000fd5b6000918252602082200154604051634f896d4f60e01b815260048101929092526001600160a01b031690634f896d4f90602401600060405180830381600087803b158015612fa357600080fd5b505af1158015612fb7573d6000803e3d6000fd5b505050506001600160a01b038216600090815260166020526040902080546002908110612ff457634e487b7160e01b600052603260045260246000fd5b6000918252602082200154604051634f896d4f60e01b815260048101929092526001600160a01b031690634f896d4f90602401600060405180830381600087803b15801561304157600080fd5b505af1158015613055573d6000803e3d6000fd5b505050505b60005b6001600160a01b0383166000908152601660205260409020548110156117bd576001600160a01b038316600090815260166020526040902080546130d79190839081106130ba57634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546007906001600160a01b0316614af1565b6001600160a01b0383166000908152601660205260409020805461313191908390811061311457634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546009906001600160a01b0316614c74565b8061313b816159d2565b91505061305d565b60035460ff16156131665760405162461bcd60e51b8152600401610ad2906157fa565b61316e613eaf565b60005b818110156117bd57600083838381811061319b57634e487b7160e01b600052603260045260246000fd5b90506020020160208101906131b0919061501f565b90506131bb81613743565b6131d75760405162461bcd60e51b8152600401610ad29061578a565b60405163646d919f60e11b81523360048201526001600160a01b0382169063c8db233e90602401600060405180830381600087803b15801561321857600080fd5b505af115801561322c573d6000803e3d6000fd5b50505050613244816009614af190919063ffffffff16565b6040516001600160a01b03821681527f16e62064e42f5aec62df22ae895ef539f153e0d4ea290e2cc4e0e8f708f2fbbc9060200160405180910390a1508061328b816159d2565b915050613171565b61329b613eaf565b6001600160a01b0381166132e35760405162461bcd60e51b815260206004820152600f60248201526e496e76616c6964206164647265737360881b6044820152606401610ad2565b600154600160a81b900460ff16156133335760405162461bcd60e51b8152602060048201526013602482015272105b1c9958591e481d1c985b9cd9995c9c9959606a1b6044820152606401610ad2565b600080546001600160a01b038381166201000081810262010000600160b01b031990941693909317938490556001805460ff60a81b1916600160a81b1790556040805193909404909116825260208201527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c91016109fd565b6133b4613eaf565b6133bd84613743565b6133d95760405162461bcd60e51b8152600401610ad29061578a565b836001600160a01b0316639a82a09a6040518163ffffffff1660e01b815260040160206040518083038186803b15801561341257600080fd5b505afa158015613426573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061344a9190615372565b61348e5760405162461bcd60e51b815260206004820152601560248201527426b0b935b2ba103737ba1031b0b731b2b63632b21760591b6044820152606401610ad2565b6040516364ee874960e11b81526004810184905260248101839052604481018290526001600160a01b0385169063c9dd0e9290606401600060405180830381600087803b1580156134de57600080fd5b505af11580156134f2573d6000803e3d6000fd5b5050604080516001600160a01b038816815260208101879052908101859052606081018490527f11b2eca36fe7a3aaee80f5737d95923d4ac267614f4de9a91e63b24baa2bc1cf9250608001905060405180910390a150505050565b6000816001600160a01b0316635c975abb6040518163ffffffff1660e01b815260040160206040518083038186803b15801561358957600080fd5b505afa15801561359d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fc09190615372565b60075460009082101561360b5760078054839081106135f057634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b031692915050565b506000919050565b61361b613eaf565b60005b82518110156117bd578115156017600085848151811061364e57634e487b7160e01b600052603260045260246000fd5b60209081029190910181015182528101919091526040016000205460ff1615151461373157816017600085848151811061369857634e487b7160e01b600052603260045260246000fd5b6020026020010151815260200190815260200160002060006101000a81548160ff0219169083151502179055507fe98ab4bde655ceada15ea801bef97987659458457b2f770527e7c9ed5aeac98483828151811061370657634e487b7160e01b600052603260045260246000fd5b6020026020010151836040516137289291909182521515602082015260400190565b60405180910390a15b8061373b816159d2565b91505061361e565b600061375060078361462b565b80610fc05750610fc060098361462b565b606061209c600784846147aa565b6000546201000090046001600160a01b031633148061379d57503360009081526012602052604090205460ff165b6137b95760405162461bcd60e51b8152600401610ad290615760565b80156138005760405162461bcd60e51b815260206004820152601660248201527543616e206f6e6c79207365742030206f7574636f6d6560501b6044820152606401610ad2565b816001600160a01b0316633f6fa6556040518163ffffffff1660e01b815260040160206040518083038186803b15801561383957600080fd5b505afa15801561384d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906138719190615372565b6138b35760405162461bcd60e51b815260206004820152601360248201527213585c9ad95d081b9bdd081c995cdbdb1d9959606a1b6044820152606401610ad2565b6138be60078361462b565b156138fb5760405162461bcd60e51b815260206004820152600d60248201526c1058dd1a5d99481b585c9ad95d609a1b6044820152606401610ad2565b6001600160a01b03821660009081526014602052604090205460ff16156139345760405162461bcd60e51b8152600401610ad2906157b3565b816001600160a01b0316635c975abb6040518163ffffffff1660e01b815260040160206040518083038186803b15801561396d57600080fd5b505afa158015613981573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906139a59190615372565b15613a05576040516305b0e2cf60e21b8152600060048201526001600160a01b038316906316c38b3c90602401600060405180830381600087803b1580156139ec57600080fd5b505af1158015613a00573d6000803e3d6000fd5b505050505b604051634f896d4f60e01b8152600481018290526001600160a01b03831690634f896d4f90602401600060405180830381600087803b158015613a4757600080fd5b505af1158015613a5b573d6000803e3d6000fd5b505050506001600160a01b03821660009081526016602052604090205415610c10576001600160a01b03821660009081526016602052604081208054909190613ab457634e487b7160e01b600052603260045260246000fd5b6000918252602082200154604051634f896d4f60e01b815260048101929092526001600160a01b031690634f896d4f90602401600060405180830381600087803b158015613b0157600080fd5b505af1158015613b15573d6000803e3d6000fd5b505050506001600160a01b038216600090815260166020526040902080546001908110613b5257634e487b7160e01b600052603260045260246000fd5b6000918252602082200154604051634f896d4f60e01b815260048101929092526001600160a01b031690634f896d4f90602401600060405180830381600087803b158015613b9f57600080fd5b505af1158015613bb3573d6000803e3d6000fd5b505050506001600160a01b038216600090815260166020526040902080546002908110613bf057634e487b7160e01b600052603260045260246000fd5b6000918252602082200154604051634f896d4f60e01b815260048101929092526001600160a01b031690634f896d4f90602401611e4b565b6000610fc082614acd565b613c3b613eaf565b600e8054911515600160a01b0260ff60a01b19909216919091179055565b606080606083516001600160401b03811115613c8557634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015613cae578160200160208202803683370190505b50925083516001600160401b03811115613cd857634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015613d01578160200160208202803683370190505b50915083516001600160401b03811115613d2b57634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015613d54578160200160208202803683370190505b50905060005b8451811015613e5e57600080613d89878481518110611f1b57634e487b7160e01b600052603260045260246000fd5b91509150613db0878481518110610b4a57634e487b7160e01b600052603260045260246000fd5b848481518110613dd057634e487b7160e01b600052603260045260246000fd5b60200260200101901515908115158152505081868481518110613e0357634e487b7160e01b600052603260045260246000fd5b60200260200101901515908115158152505042811115858481518110613e3957634e487b7160e01b600052603260045260246000fd5b9115156020928302919091019091015250819050613e56816159d2565b915050613d5a565b509193909250565b613e6e613eaf565b6015805460ff19168215159081179091556040519081527fafa98ec751b49f853d1a5f51c4b6df2a6248c9daa73a920ee644094abe32e41e906020016109fd565b6000546201000090046001600160a01b03163314613f275760405162461bcd60e51b815260206004820152602f60248201527f4f6e6c792074686520636f6e7472616374206f776e6572206d6179207065726660448201526e37b936903a3434b99030b1ba34b7b760891b6064820152608401610ad2565b565b60008060008390506000816001600160a01b0316639e3b34bf6040518163ffffffff1660e01b8152600401604080518083038186803b158015613f6b57600080fd5b505afa158015613f7f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613fa39190615525565b509050816001600160a01b031663ef83f7246040518163ffffffff1660e01b815260040160206040518083038186803b158015613fdf57600080fd5b505afa158015613ff3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906140179190615372565b9590945092505050565b6000816001600160a01b0316633f6fa6556040518163ffffffff1660e01b815260040160206040518083038186803b15801561358957600080fd5b600d54604051631c2ab73160e21b81526004810187905286916000916001600160a01b03909116906370aadcc49060240160206040518083038186803b1580156140a557600080fd5b505afa1580156140b9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906140dd919061538e565b60008181526017602052604090205490915060ff168015614100575060155460ff165b15614407576040805160a0810182526011606080830182815270486f6d655465616d4e6f74546f4c6f736560781b608085015283528351808501855291825270417761795465616d4e6f74546f4c6f736560781b602080840191909152808401929092528351808501855260068152654e6f4472617760d01b81840152838501528351600280825291810185529293600093928301908036833701905050905084816000815181106141c257634e487b7160e01b600052603260045260246000fd5b602002602001018181525050612713816001815181106141f257634e487b7160e01b600052603260045260246000fd5b60200260200101818152505060005b60038110156144035760006142a56040518061012001604052808e6001600160a01b031681526020018d815260200186856003811061425057634e487b7160e01b600052603260045260246000fd5b6020020151815260200160405180604001604052808e81526020018d8152508152602001600281526020018581526020016000151581526020018a6001600160a01b031681526020016001151581525061441d565b90506142b2600782614c74565b6001600160a01b0388811660009081526016602090815260408083208054600180820183559185528385200180546001600160a01b031916878716908117909155808552601490935292819020805460ff19169093179092556013549151631c71e4e760e31b8152600481018f9052602481019190915291169063e38f273890604401600060405180830381600087803b15801561434f57600080fd5b505af1158015614363573d6000803e3d6000fd5b505050507f0cf6abc895e0e76ef58c3555c8cd5ffca2afecb927fccd65c136122c0c39404f8882856001815181106143ab57634e487b7160e01b600052603260045260246000fd5b60200260200101518786600381106143d357634e487b7160e01b600052603260045260246000fd5b60200201516040516143e89493929190615621565b60405180910390a150806143fb816159d2565b915050614201565b5050505b5050505050505050565b600061209c8284615964565b600e54604051634f3565e360e01b815260009182916001600160a01b0390911690634f3565e390614452908690600401615857565b602060405180830381600087803b15801561446c57600080fd5b505af1158015614480573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906144a4919061503b565b90506144b1600782614c74565b6000806000836001600160a01b031663cc2ee1966040518163ffffffff1660e01b815260040160606040518083038186803b1580156144ef57600080fd5b505afa158015614503573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061452791906154a0565b925092509250856020015186600001516001600160a01b03167f5b94d36374b7499bec3849984d165c16e10e3ee59241963bd809a169d1a9cf2686896060015160006002811061458757634e487b7160e01b600052603260045260246000fd5b6020908102919091015160608c810151830151604080516001600160a01b039687168152948501939093528383015289841690830152878316608083015291861660a082015290519081900360c00190a37f319d1be996912ef0acee5fb7cc9b908129bf7bc7290609b7578839c4a1689bad84876040015160405161460d92919061565e565b60405180910390a15091949350505050565b600061209c82846159bb565b815460009061463c57506000610fc0565b6001600160a01b0382166000908152600184016020526040902054801515806146a55750826001600160a01b03168460000160008154811061468e57634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b0316145b949350505050565b60008060008390506000816001600160a01b0316639e3b34bf6040518163ffffffff1660e01b8152600401604080518083038186803b1580156146ef57600080fd5b505afa158015614703573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906147279190615525565b509050816001600160a01b031663ef83f7246040518163ffffffff1660e01b815260040160206040518083038186803b15801561476357600080fd5b505afa158015614777573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061479b9190615372565b80614017575061401785614cc6565b606060006147b88385615964565b85549091508111156147c8575083545b8381116147e557505060408051600081526020810190915261209c565b60006147f185836159bb565b90506000816001600160401b0381111561481b57634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015614844578160200160208202803683370190505b50905060005b828110156148e3578761485d8883615964565b8154811061487b57634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b03168282815181106148b957634e487b7160e01b600052603260045260246000fd5b6001600160a01b0390921660209283029190910190910152806148db816159d2565b91505061484a565b509695505050505050565b6040516339acb21f60e21b815260048101839052602481018290526001600160a01b0384169063e6b2c87c90604401600060405180830381600087803b15801561493757600080fd5b505af115801561494b573d6000803e3d6000fd5b5050604080516001600160a01b0387168152602081018690529081018490527f0915c734742076f135119aa0d73364ab8589b1a6d441c764678c275613a3c6e19250606001905060405180910390a1505050565b604051630ceda8e960e41b81526001600160a01b0385811660048301526000919083169063ceda8e909060240160206040518083038186803b1580156149e457600080fd5b505afa1580156149f8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614a1c919061538e565b905060005b81811015611e795760405163088f63ab60e31b81526001600160a01b038781166004830152602482018390526000919085169063447b1d589060440160206040518083038186803b158015614a7557600080fd5b505afa158015614a89573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614aad919061503b565b9050614aba8187876148ee565b5080614ac5816159d2565b915050614a21565b600e54600090600160a01b900460ff1615610fc657610fc064e8d4a510008361597c565b614afb828261462b565b614b3d5760405162461bcd60e51b815260206004820152601360248201527222b632b6b2b73a103737ba1034b71039b2ba1760691b6044820152606401610ad2565b6001600160a01b0381166000908152600180840160205260408220548454909291614b67916159bb565b9050808214614c0f576000846000018281548110614b9557634e487b7160e01b600052603260045260246000fd5b60009182526020909120015485546001600160a01b0390911691508190869085908110614bd257634e487b7160e01b600052603260045260246000fd5b600091825260208083209190910180546001600160a01b0319166001600160a01b0394851617905592909116815260018601909152604090208290555b8354849080614c2e57634e487b7160e01b600052603160045260246000fd5b60008281526020808220830160001990810180546001600160a01b03191690559092019092556001600160a01b0394909416815260019490940190925250506040812055565b614c7e828261462b565b610c105781546001600160a01b038216600081815260018086016020908152604083208590559084018655858252902090910180546001600160a01b03191690911790555050565b6000614cd3826001614ce0565b80610fc05750610fc08260005b60008060008315614d7e57601854604051630ceda8e960e41b81526001600160a01b0387811660048301529091169063ceda8e909060240160206040518083038186803b158015614d3057600080fd5b505afa158015614d44573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614d68919061538e565b6018549092506001600160a01b03169050614e0d565b601354604051630ceda8e960e41b81526001600160a01b0387811660048301529091169063ceda8e909060240160206040518083038186803b158015614dc357600080fd5b505afa158015614dd7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614dfb919061538e565b6013549092506001600160a01b031690505b60005b82811015614f345760405163088f63ab60e31b81526001600160a01b038781166004830152602482018390526000919084169063447b1d589060440160206040518083038186803b158015614e6457600080fd5b505afa158015614e78573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614e9c919061503b565b9050806001600160a01b031663ef83f7246040518163ffffffff1660e01b815260040160206040518083038186803b158015614ed757600080fd5b505afa158015614eeb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614f0f9190615372565b15614f21576001945050505050610fc0565b5080614f2c816159d2565b915050614e10565b50600095945050505050565b8035610f5f81615a19565b60008083601f840112614f5c578182fd5b5081356001600160401b03811115614f72578182fd5b6020830191508360208260051b8501011115614f8d57600080fd5b9250929050565b600082601f830112614fa4578081fd5b81356020614fb9614fb483615941565b615911565b80838252828201915082860187848660051b8901011115614fd8578586fd5b855b85811015614ff657813584529284019290840190600101614fda565b5090979650505050505050565b8035610f5f81615a2e565b803560ff81168114610f5f57600080fd5b600060208284031215615030578081fd5b813561209c81615a19565b60006020828403121561504c578081fd5b815161209c81615a19565b60008060006060848603121561506b578182fd5b833561507681615a19565b9250602084013561508681615a19565b929592945050506040919091013590565b600080604083850312156150a9578182fd5b82356150b481615a19565b915060208301356150c481615a2e565b809150509250929050565b600080604083850312156150e1578182fd5b82356150ec81615a19565b915060208301356150c481615a19565b6000806040838503121561510e578182fd5b823561511981615a19565b946020939093013593505050565b6000806000806080858703121561513c578081fd5b843561514781615a19565b966020860135965060408601359560600135945092505050565b60008060008060008060c08789031215615179578384fd5b863561518481615a19565b9550602087013594506151996040880161500e565b93506151a76060880161500e565b925060808701356151b781615a19565b915060a08701356151c781615a2e565b809150509295509295509295565b600080602083850312156151e7578182fd5b82356001600160401b038111156151fc578283fd5b61520885828601614f4b565b90969095509350505050565b60008060008060608587031215615229578182fd5b84356001600160401b0381111561523e578283fd5b61524a87828801614f4b565b909550935050602085013561525e81615a2e565b915061526c6040860161500e565b905092959194509250565b60006020808385031215615289578182fd5b82356001600160401b0381111561529e578283fd5b8301601f810185136152ae578283fd5b80356152bc614fb482615941565b80828252848201915084840188868560051b87010111156152db578687fd5b8694505b838510156153065780356152f281615a19565b8352600194909401939185019185016152df565b50979650505050505050565b60008060408385031215615324578182fd5b82356001600160401b03811115615339578283fd5b61534585828601614f94565b92505060208301356150c481615a2e565b600060208284031215615367578081fd5b813561209c81615a2e565b600060208284031215615383578081fd5b815161209c81615a2e565b60006020828403121561539f578081fd5b5051919050565b600080600080600080600080610100898b0312156153c2578586fd5b883597506020808a01356001600160401b03808211156153e0578889fd5b818c0191508c601f8301126153f3578889fd5b81358181111561540557615405615a03565b615417601f8201601f19168501615911565b8181528e8583860101111561542a578a8bfd5b81858501868301378a858383010152809b50505060408c0135985060608c0135975060808c0135965060a08c0135925080831115615466578485fd5b50506154748b828c01614f94565b93505061548360c08a01615003565b915061549160e08a01614f40565b90509295985092959890939650565b6000806000606084860312156154b4578081fd5b83516154bf81615a19565b60208501519093506154d081615a19565b60408501519092506154e181615a19565b809150509250925092565b6000602082840312156154fd578081fd5b5035919050565b60008060408385031215615516578182fd5b50508035926020909101359150565b60008060408385031215615537578182fd5b505080516020909101519092909150565b6000815180845260208085019450808401835b8381101561557957815115158752958201959082019060010161555b565b509495945050505050565b8060005b6002811015611348578151845260209384019390910190600101615588565b6000815180845260208085019450808401835b83811015615579578151875295820195908201906001016155ba565b60008151808452815b818110156155fb576020818501810151868301820152016155df565b8181111561560c5782602083870101525b50601f01601f19169290920160200192915050565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090615654908301846155d6565b9695505050505050565b6001600160a01b03831681526040602082018190526000906146a5908301846155d6565b6020808252825182820181905260009190848201906040850190845b818110156156c35783516001600160a01b03168352928401929184019160010161569e565b50909695505050505050565b6060815260006156e26060830186615548565b82810360208401526156f48186615548565b905082810360408401526156548185615548565b60808152600061571b6080830187615548565b828103602084015261572d8187615548565b905082810360408401526157418186615548565b9050828103606084015261575581856155a7565b979650505050505050565b60208082526010908201526f24b73b30b634b2103932b9b7b63b32b960811b604082015260600190565b6020808252600f908201526e26b0b935b2ba103ab735b737bbb71760891b604082015260600190565b60208082526027908201527f4e6f7420737570706f7274656420666f7220646f75626c65206368616e6365206040820152666d61726b65747360c81b606082015260800190565b6020808252603c908201527f5468697320616374696f6e2063616e6e6f7420626520706572666f726d65642060408201527f7768696c652074686520636f6e74726163742069732070617573656400000000606082015260800190565b602081526158716020820183516001600160a01b03169052565b60208201516040820152600060408301516101408060608501526158996101608501836155d6565b915060608501516158ad6080860182615584565b50608085015160c085015260a0850151848303601f190160e08601526158d383826155a7565b92505060c08501516101006158eb8187018315159052565b60e08701516001600160a01b031661012087015290950151151593019290925250919050565b604051601f8201601f191681016001600160401b038111828210171561593957615939615a03565b604052919050565b60006001600160401b0382111561595a5761595a615a03565b5060051b60200190565b60008219821115615977576159776159ed565b500190565b60008261599757634e487b7160e01b81526012600452602481fd5b500490565b60008160001904831182151516156159b6576159b66159ed565b500290565b6000828210156159cd576159cd6159ed565b500390565b60006000198214156159e6576159e66159ed565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114610e4e57600080fd5b8015158114610e4e57600080fdfea2646970667358221220c7e82e603ff7c7ab21419770bd77608e73c2251c8c07240f1750c390d885e52d64736f6c63430008040033

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106104075760003560e01c80637fdb733f11610220578063b91f5e3511610130578063e62b8889116100b8578063f65d145411610087578063f65d145414610937578063fab44cbb1461095a578063fb6cede61461096d578063ff50abdc1461098f578063ffbc538a1461099857600080fd5b8063e62b8889146108eb578063e73efc9b146108fe578063ed7afdec14610911578063edc892e11461092457600080fd5b8063c6e9e7d7116100ff578063c6e9e7d714610892578063cf7fb264146108a5578063dd5adfa3146108b8578063e116ee5a146108cb578063e28c130b146108d857600080fd5b8063b91f5e3514610846578063bb96af6514610859578063c014fb841461086c578063c3b83f5f1461087f57600080fd5b80639418f6c7116101b3578063aeab584911610182578063aeab5849146107f3578063b037c8e514610806578063b162e06114610819578063b3ee14241461082a578063b908feb21461083357600080fd5b80639418f6c7146107a25780639eb5d8b4146107c5578063ac60c486146107d8578063ad6b22ce146107e057600080fd5b80638da5cb5b116101ef5780638da5cb5b146107595780638fe812b41461077257806391b4ded9146107865780639324cac71461078f57600080fd5b80637fdb733f146106fd57806385f2a72e1461071057806389c6318d146107235780638d924e731461073657600080fd5b80633c5a2ef01161031b5780635fae0576116102ae5780636b3a09841161027d5780636b3a0984146106a95780636ec38a4e146106bc57806371943de3146106cf57806379ba5097146106e25780637f8c2d61146106ea57600080fd5b80635fae05761461063157806364af2d871461065d57806368c7f2161461066a5780636a5fd5661461067d57600080fd5b806355f14427116102ea57806355f14427146105db5780635c975abb146105ee5780635d7fb8e2146105fb5780635e7ba7101461060e57600080fd5b80633c5a2ef01461058f578063485cc955146105a25780634cde32ce146105b557806353a47bb7146105c857600080fd5b80631627540c1161039e57806317fd849a1161036d57806317fd849a1461053a57806321a92a271461054d57806327d31e3b146105605780633744734d1461057357806339ab4c411461057c57600080fd5b80631627540c146104c957806316c38b3c146104dc578063172653eb146104ef57806317eaaa4a1461050f57600080fd5b80630def299d116103da5780630def299d1461047e5780630e429aeb1461049157806313af4035146104a357806315502840146104b657600080fd5b806302610c501461040c57806306c933d8146104235780630b3be3f3146104565780630c863e061461046b575b600080fd5b6007545b6040519081526020015b60405180910390f35b61044661043136600461501f565b600f6020526000908152604090205460ff1681565b604051901515815260200161041a565b61046961046436600461501f565b6109ab565b005b61046961047936600461501f565b610a08565b61046961048c366004615277565b610a5e565b60055461044690610100900460ff1681565b6104696104b136600461501f565b610c14565b6104696104c43660046154ec565b610d48565b6104696104d736600461501f565b610d85565b6104696104ea366004615356565b610ddb565b6105026104fd36600461501f565b610e51565b60405161041a9190615682565b61052261051d3660046150fc565b610f64565b6040516001600160a01b03909116815260200161041a565b6104106105483660046154ec565b610f9c565b61046961055b36600461501f565b610fca565b61046961056e366004615214565b61134e565b61041060115481565b61046961058a366004615356565b611663565b600e54610522906001600160a01b031681565b6104696105b03660046150cf565b6116bc565b6105226105c33660046153a6565b6117c2565b600154610522906001600160a01b031681565b6104696105e93660046154ec565b6119ea565b6003546104469060ff1681565b601854610522906001600160a01b031681565b61044661061c36600461501f565b60126020526000908152604090205460ff1681565b61044661063f36600461501f565b6001600160a01b03166000908152600f602052604090205460ff1690565b6005546104469060ff1681565b61046961067836600461501f565b6119f7565b61044661068b36600461501f565b6001600160a01b031660009081526014602052604090205460ff1690565b6104696106b73660046154ec565b611a4d565b6104466106ca36600461501f565b611ae2565b6104696106dd36600461501f565b611b6e565b610469611bc4565b6104696106f8366004615097565b611cc1565b61046961070b366004615277565b611e81565b61046961071e36600461501f565b612038565b610502610731366004615504565b61208e565b610749610744366004615277565b6120a3565b60405161041a9493929190615708565b600054610522906201000090046001600160a01b031681565b600e5461044690600160a01b900460ff1681565b61041060025481565b600c54610522906001600160a01b031681565b6104466107b036600461501f565b60146020526000908152604090205460ff1681565b6104696107d33660046150fc565b612333565b600954610410565b601354610522906001600160a01b031681565b6104696108013660046154ec565b6123f3565b610469610814366004615161565b612485565b6013546001600160a01b0316610522565b61041060045481565b610469610841366004615057565b612611565b6104696108543660046150fc565b612747565b600d54610522906001600160a01b031681565b61046961087a3660046151d5565b613143565b61046961088d36600461501f565b613293565b6104696108a0366004615127565b6133ac565b6104466108b336600461501f565b61354e565b6105226108c63660046154ec565b6135c1565b6015546104469060ff1681565b6104696108e6366004615312565b613613565b6104466108f936600461501f565b613743565b61050261090c366004615504565b613761565b61046961091f3660046150fc565b61376f565b6104106109323660046154ec565b613c28565b6104466109453660046154ec565b60176020526000908152604090205460ff1681565b610469610968366004615356565b613c33565b61098061097b366004615277565b613c59565b60405161041a939291906156cf565b61041060065481565b6104696109a6366004615356565b613e66565b6109b3613eaf565b600c80546001600160a01b0319166001600160a01b0383169081179091556040519081527fbae3da9b16d7b09b9f1a0d00cb2fafc0f94895fde1e0e2d9e31529efa028da06906020015b60405180910390a150565b610a10613eaf565b601380546001600160a01b0319166001600160a01b0383169081179091556040519081527fabcd3d442bfb8eed13cda6bd397d12a7a75f9d4b9d85df42729d6470fab78503906020016109fd565b60005b8151811015610c105760146000838381518110610a8e57634e487b7160e01b600052603260045260246000fd5b6020908102919091018101516001600160a01b031682528101919091526040016000205460ff1615610adb5760405162461bcd60e51b8152600401610ad2906157b3565b60405180910390fd5b600080610b0e848481518110610b0157634e487b7160e01b600052603260045260246000fd5b6020026020010151613f29565b9150915081158015610b205750428111155b8015610b595750610b57848481518110610b4a57634e487b7160e01b600052603260045260246000fd5b6020026020010151614021565b155b15610bfb5760185484516001600160a01b0390911690635938541f90869086908110610b9557634e487b7160e01b600052603260045260246000fd5b60200260200101516040518263ffffffff1660e01b8152600401610bc891906001600160a01b0391909116815260200190565b600060405180830381600087803b158015610be257600080fd5b505af1158015610bf6573d6000803e3d6000fd5b505050505b50508080610c08906159d2565b915050610a61565b5050565b6001600160a01b038116610c6a5760405162461bcd60e51b815260206004820152601960248201527f4f776e657220616464726573732063616e6e6f742062652030000000000000006044820152606401610ad2565b600154600160a01b900460ff1615610cd65760405162461bcd60e51b815260206004820152602960248201527f416c726561647920696e697469616c697a65642c20757365206e6f6d696e617460448201526832a732bba7bbb732b960b91b6064820152608401610ad2565b6001805460ff60a01b1916600160a01b179055600080546001600160a01b03831662010000810262010000600160b01b03199092169190911782556040805192835260208301919091527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c91016109fd565b610d50613eaf565b60048190556040518181527ff378a0fd4ad3ffd9d7d50986f16b04acd2dc42691c4f412f34e8eefe883e6652906020016109fd565b610d8d613eaf565b600180546001600160a01b0319166001600160a01b0383169081179091556040519081527f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce22906020016109fd565b610de3613eaf565b60035460ff1615158115151415610df75750565b6003805460ff191682151590811790915560ff1615610e1557426002555b60035460405160ff909116151581527f8fb6c181ee25a520cf3dd6565006ef91229fcfe5a989566c2a3b8c115570cec5906020016109fd565b50565b6001600160a01b03811660009081526016602052604090205460609015610f5f57604080516003808252608082019092526000916020820160608036833701905050905060005b6001600160a01b038416600090815260166020526040902054811015610f58576001600160a01b0384166000908152601660205260409020805482908110610ef057634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b0316828281518110610f2e57634e487b7160e01b600052603260045260246000fd5b6001600160a01b039092166020928302919091019091015280610f50816159d2565b915050610e98565b5092915050565b919050565b60166020528160005260406000208181548110610f8057600080fd5b6000918252602090912001546001600160a01b03169150829050565b600e54600090600160a01b900460ff1615610fc657610fc08264e8d4a5100061599c565b92915050565b5090565b60035460ff1615610fed5760405162461bcd60e51b8152600401610ad2906157fa565b610ff5613eaf565b60055460ff166110475760405162461bcd60e51b815260206004820152601b60248201527f4d61726b6574206372656174696f6e2069732064697361626c656400000000006044820152606401610ad2565b60155460ff166110995760405162461bcd60e51b815260206004820152601b60248201527f446f75626c65206368616e6365206e6f7420737570706f7274656400000000006044820152606401610ad2565b60008190506002816001600160a01b0316631a1dbabb6040518163ffffffff1660e01b815260040160206040518083038186803b1580156110d957600080fd5b505afa1580156110ed573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611111919061538e565b116111695760405162461bcd60e51b815260206004820152602260248201527f4e6f7420737570706f7274656420666f722032206f7074696f6e73206d61726b604482015261195d60f21b6064820152608401610ad2565b600080826001600160a01b0316639e3b34bf6040518163ffffffff1660e01b8152600401604080518083038186803b1580156111a457600080fd5b505afa1580156111b8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111dc9190615525565b91509150611348836001600160a01b03166302d05d3f6040518163ffffffff1660e01b815260040160206040518083038186803b15801561121c57600080fd5b505afa158015611230573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611254919061503b565b846001600160a01b031663c0bd83516040518163ffffffff1660e01b815260040160206040518083038186803b15801561128d57600080fd5b505afa1580156112a1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112c5919061538e565b6040516308208aaf60e21b8152600060048201528590859089906001600160a01b038a16906320822abc9060240160206040518083038186803b15801561130b57600080fd5b505afa15801561131f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611343919061538e565b61405c565b50505050565b611356613eaf565b826113b15760405162461bcd60e51b815260206004820152602560248201527f57686974656c6973746564206164647265737365732063616e6e6f7420626520604482015264656d70747960d81b6064820152608401610ad2565b60005b8381101561165c578160ff166001141561150357821515600f60008787858181106113ef57634e487b7160e01b600052603260045260246000fd5b9050602002016020810190611404919061501f565b6001600160a01b0316815260208101919091526040016000205460ff161515146115035782600f600087878581811061144d57634e487b7160e01b600052603260045260246000fd5b9050602002016020810190611462919061501f565b6001600160a01b031681526020810191909152604001600020805460ff19169115159190911790557f58d7a3ccc34541e162fcfc87b84be7b78c34d1e1e7f15de6e4dd67d0fe70aecd8585838181106114cb57634e487b7160e01b600052603260045260246000fd5b90506020020160208101906114e0919061501f565b604080516001600160a01b03909216825285151560208301520160405180910390a15b8160ff166002141561164a578215156012600087878581811061153657634e487b7160e01b600052603260045260246000fd5b905060200201602081019061154b919061501f565b6001600160a01b0316815260208101919091526040016000205460ff1615151461164a57826012600087878581811061159457634e487b7160e01b600052603260045260246000fd5b90506020020160208101906115a9919061501f565b6001600160a01b031681526020810191909152604001600020805460ff19169115159190911790557f58d7a3ccc34541e162fcfc87b84be7b78c34d1e1e7f15de6e4dd67d0fe70aecd85858381811061161257634e487b7160e01b600052603260045260246000fd5b9050602002016020810190611627919061501f565b604080516001600160a01b03909216825285151560208301520160405180910390a15b80611654816159d2565b9150506113b4565b5050505050565b61166b613eaf565b60055460ff16151581151514610e4e576005805460ff19168215159081179091556040519081527fcc590b6309435383b617aaa0cae6aba938f2ee471cfb539201dd7655a23caff9906020016109fd565b600054610100900460ff166116d75760005460ff16156116db565b303b155b61173e5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610ad2565b600054610100900460ff16158015611760576000805461ffff19166101011790555b61176983610c14565b600c80546001600160a01b0319166001600160a01b0384161790556000805462010000600160b01b0319163362010000021790556005805461ffff1916600117905580156117bd576000805461ff00191690555b505050565b60035460009060ff16156117e85760405162461bcd60e51b8152600401610ad2906157fa565b60055460ff1661183a5760405162461bcd60e51b815260206004820152601b60248201527f4d61726b6574206372656174696f6e2069732064697361626c656400000000006044820152606401610ad2565b600d546001600160a01b031633148061185d57506013546001600160a01b031633145b8061187257506018546001600160a01b031633145b6118b05760405162461bcd60e51b815260206004820152600f60248201526e24b73b30b634b21031b932b0ba37b960891b6044820152606401610ad2565b60006118c76004548961441190919063ffffffff16565b90508742106119185760405162461bcd60e51b815260206004820181905260248201527f4d617475726974792068617320746f20626520696e20746865206675747572656044820152606401610ad2565b600061198d604051806101200160405280336001600160a01b031681526020018d81526020018c815260200160405180604001604052808d81526020018681525081526020018981526020018881526020018715158152602001866001600160a01b031681526020016000151581525061441d565b90506002871180156119a1575060155460ff165b156119dc576119dc338c8b85858b6000815181106119cf57634e487b7160e01b600052603260045260246000fd5b602002602001015161405c565b9a9950505050505050505050565b6119f2613eaf565b601155565b6119ff613eaf565b600d80546001600160a01b0319166001600160a01b0383169081179091556040519081527f82c2f8aad8de17db4e2115c03f9a95266ac400ef1f7c7895c5a6487e45bcb279906020016109fd565b611a5633613743565b611aac5760405162461bcd60e51b815260206004820152602160248201527f5065726d6974746564206f6e6c7920666f72206b6e6f776e206d61726b6574736044820152601760f91b6064820152608401610ad2565b60035460ff1615611acf5760405162461bcd60e51b8152600401610ad2906157fa565b600654611adc908261461f565b60065550565b6000611aef60078361462b565b8015610fc05750816001600160a01b0316635c975abb6040518163ffffffff1660e01b815260040160206040518083038186803b158015611b2f57600080fd5b505afa158015611b43573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b679190615372565b1592915050565b611b76613eaf565b600e80546001600160a01b0319166001600160a01b0383169081179091556040519081527f7860d99a18d1d40974259a27a70db54aed4b0ed3584556d2f266af2a0990be68906020016109fd565b6001546001600160a01b03163314611c3c5760405162461bcd60e51b815260206004820152603560248201527f596f75206d757374206265206e6f6d696e61746564206265666f726520796f7560448201527402063616e20616363657074206f776e65727368697605c1b6064820152608401610ad2565b60005460015460408051620100009093046001600160a01b03908116845290911660208301527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c910160405180910390a1600180546000805462010000600160b01b0319166001600160a01b03831662010000021790556001600160a01b0319169055565b6000546201000090046001600160a01b0316331480611cea5750600d546001600160a01b031633145b80611cff57506013546001600160a01b031633145b80611d1457506018546001600160a01b031633145b80611d2e5750336000908152600f602052604090205460ff165b611d6b5760405162461bcd60e51b815260206004820152600e60248201526d24b73b30b634b21031b0b63632b960911b6044820152606401610ad2565b801515826001600160a01b0316635c975abb6040518163ffffffff1660e01b815260040160206040518083038186803b158015611da757600080fd5b505afa158015611dbb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ddf9190615372565b15151415611e215760405162461bcd60e51b815260206004820152600f60248201526e4e6f207374617465206368616e676560881b6044820152606401610ad2565b6040516305b0e2cf60e21b815281151560048201526001600160a01b038316906316c38b3c906024015b600060405180830381600087803b158015611e6557600080fd5b505af1158015611e79573d6000803e3d6000fd5b505050505050565b60005b8151811015610c105760146000838381518110611eb157634e487b7160e01b600052603260045260246000fd5b6020908102919091018101516001600160a01b031682528101919091526040016000205460ff1615611ef55760405162461bcd60e51b8152600401610ad2906157b3565b600080611f28848481518110611f1b57634e487b7160e01b600052603260045260246000fd5b60200260200101516146ad565b9150915081158015611f3a5750428111155b8015611f665750611f64848481518110610b4a57634e487b7160e01b600052603260045260246000fd5b155b1561202357600d5484516001600160a01b039091169063099177e990869086908110611fa257634e487b7160e01b600052603260045260246000fd5b60209081029190910101516040516001600160e01b031960e084901b1681526001600160a01b0390911660048201526000602482018190526044820181905260648201819052608482015260a401600060405180830381600087803b15801561200a57600080fd5b505af115801561201e573d6000803e3d6000fd5b505050505b50508080612030906159d2565b915050611e84565b612040613eaf565b601880546001600160a01b0319166001600160a01b0383169081179091556040519081527fb29efe346fda749edc8ac04767e9facace07f2dd8deb4ad51a68f5cd887a57fd906020016109fd565b606061209c600984846147aa565b9392505050565b60608060608084516001600160401b038111156120d057634e487b7160e01b600052604160045260246000fd5b6040519080825280602002602001820160405280156120f9578160200160208202803683370190505b50935084516001600160401b0381111561212357634e487b7160e01b600052604160045260246000fd5b60405190808252806020026020018201604052801561214c578160200160208202803683370190505b50925084516001600160401b0381111561217657634e487b7160e01b600052604160045260246000fd5b60405190808252806020026020018201604052801561219f578160200160208202803683370190505b50915084516001600160401b038111156121c957634e487b7160e01b600052604160045260246000fd5b6040519080825280602002602001820160405280156121f2578160200160208202803683370190505b50905060005b855181101561232b57600080612227888481518110610b0157634e487b7160e01b600052603260045260246000fd5b9150915061224e888481518110610b4a57634e487b7160e01b600052603260045260246000fd5b85848151811061226e57634e487b7160e01b600052603260045260246000fd5b602002602001019015159081151581525050818784815181106122a157634e487b7160e01b600052603260045260246000fd5b602002602001019015159081151581525050428111158684815181106122d757634e487b7160e01b600052603260045260246000fd5b6020026020010190151590811515815250508084848151811061230a57634e487b7160e01b600052603260045260246000fd5b60200260200101818152505050508080612323906159d2565b9150506121f8565b509193509193565b6000546201000090046001600160a01b031633148061235c5750600d546001600160a01b031633145b6123995760405162461bcd60e51b815260206004820152600e60248201526d24b73b30b634b21031b0b63632b960911b6044820152606401610ad2565b60006123b06004548361441190919063ffffffff16565b90506123bd8383836148ee565b6013546123d8908490849084906001600160a01b031661499f565b6018546117bd908490849084906001600160a01b031661499f565b6123fe60073361462b565b6124555760405162461bcd60e51b815260206004820152602260248201527f5065726d6974746564206f6e6c7920666f7220616374697665206d61726b6574604482015261399760f11b6064820152608401610ad2565b60035460ff16156124785760405162461bcd60e51b8152600401610ad2906157fa565b600654611adc9082614411565b6000546201000090046001600160a01b03163314806124b357503360009081526012602052604090205460ff165b6124cf5760405162461bcd60e51b8152600401610ad290615760565b6001600160a01b03861660009081526014602052604090205460ff16156125085760405162461bcd60e51b8152600401610ad2906157b3565b84156125745780156125745760405162461bcd60e51b815260206004820152602f60248201527f4f6e6c7920757365206261636b7570206f646473206f6e2063616e63656c617460448201526e696f6e2c206966206e65656465642160881b6064820152608401610ad2565b600d546001600160a01b0383811691161415611e7957600d5460405163099177e960e01b81526001600160a01b0388811660048301526024820188905260ff80881660448401528616606483015283151560848301529091169063099177e99060a401600060405180830381600087803b1580156125f157600080fd5b505af1158015612605573d6000803e3d6000fd5b50505050505050505050565b61261a33613743565b6126365760405162461bcd60e51b8152600401610ad29061578a565b61263f81614acd565b600e54909150600160a01b900460ff166126595780612664565b612664816001615964565b600c546040516323b872dd60e01b81526001600160a01b038681166004830152858116602483015260448201849052929350600092909116906323b872dd90606401602060405180830381600087803b1580156126c057600080fd5b505af11580156126d4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126f89190615372565b9050806113485760405162461bcd60e51b815260206004820152601c60248201527f5472616e7366657246726f6d2066756e6374696f6e206661696c6564000000006044820152606401610ad2565b600d546001600160a01b031633148061277057506000546201000090046001600160a01b031633145b8061278557506013546001600160a01b031633145b8061279a57506018546001600160a01b031633145b806127b457503360009081526012602052604090205460ff165b6127d05760405162461bcd60e51b8152600401610ad290615760565b6127db60078361462b565b61281e5760405162461bcd60e51b8152602060048201526014602482015273139bdd08185b881858dd1a5d99481b585c9ad95d60621b6044820152606401610ad2565b6001600160a01b03821660009081526014602052604090205460ff16156128575760405162461bcd60e51b8152600401610ad2906157b3565b816001600160a01b0316635c975abb6040518163ffffffff1660e01b815260040160206040518083038186803b15801561289057600080fd5b505afa1580156128a4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128c89190615372565b15612928576040516305b0e2cf60e21b8152600060048201526001600160a01b038316906316c38b3c90602401600060405180830381600087803b15801561290f57600080fd5b505af1158015612923573d6000803e3d6000fd5b505050505b604051634f896d4f60e01b8152600481018290526001600160a01b03831690634f896d4f90602401600060405180830381600087803b15801561296a57600080fd5b505af115801561297e573d6000803e3d6000fd5b50505050612996826007614af190919063ffffffff16565b6129a1600983614c74565b6001600160a01b03821660009081526016602052604090205415610c10578060011415612bad576001600160a01b038216600090815260166020526040812080549091906129ff57634e487b7160e01b600052603260045260246000fd5b600091825260209091200154604051634f896d4f60e01b8152600160048201526001600160a01b0390911690634f896d4f90602401600060405180830381600087803b158015612a4e57600080fd5b505af1158015612a62573d6000803e3d6000fd5b505050506001600160a01b038216600090815260166020526040902080546001908110612a9f57634e487b7160e01b600052603260045260246000fd5b600091825260209091200154604051634f896d4f60e01b8152600260048201526001600160a01b0390911690634f896d4f906024015b600060405180830381600087803b158015612aef57600080fd5b505af1158015612b03573d6000803e3d6000fd5b505050506001600160a01b038216600090815260166020526040902080546002908110612b4057634e487b7160e01b600052603260045260246000fd5b600091825260209091200154604051634f896d4f60e01b8152600160048201526001600160a01b0390911690634f896d4f906024015b600060405180830381600087803b158015612b9057600080fd5b505af1158015612ba4573d6000803e3d6000fd5b5050505061305a565b8060021415612cc7576001600160a01b03821660009081526016602052604081208054909190612bed57634e487b7160e01b600052603260045260246000fd5b600091825260209091200154604051634f896d4f60e01b8152600260048201526001600160a01b0390911690634f896d4f90602401600060405180830381600087803b158015612c3c57600080fd5b505af1158015612c50573d6000803e3d6000fd5b505050506001600160a01b038216600090815260166020526040902080546001908110612c8d57634e487b7160e01b600052603260045260246000fd5b600091825260209091200154604051634f896d4f60e01b8152600160048201526001600160a01b0390911690634f896d4f90602401612ad5565b8060031415612e81576001600160a01b03821660009081526016602052604081208054909190612d0757634e487b7160e01b600052603260045260246000fd5b600091825260209091200154604051634f896d4f60e01b8152600160048201526001600160a01b0390911690634f896d4f90602401600060405180830381600087803b158015612d5657600080fd5b505af1158015612d6a573d6000803e3d6000fd5b505050506001600160a01b038216600090815260166020526040902080546001908110612da757634e487b7160e01b600052603260045260246000fd5b600091825260209091200154604051634f896d4f60e01b8152600160048201526001600160a01b0390911690634f896d4f90602401600060405180830381600087803b158015612df657600080fd5b505af1158015612e0a573d6000803e3d6000fd5b505050506001600160a01b038216600090815260166020526040902080546002908110612e4757634e487b7160e01b600052603260045260246000fd5b600091825260209091200154604051634f896d4f60e01b8152600260048201526001600160a01b0390911690634f896d4f90602401612b76565b6001600160a01b03821660009081526016602052604081208054909190612eb857634e487b7160e01b600052603260045260246000fd5b6000918252602082200154604051634f896d4f60e01b815260048101929092526001600160a01b031690634f896d4f90602401600060405180830381600087803b158015612f0557600080fd5b505af1158015612f19573d6000803e3d6000fd5b505050506001600160a01b038216600090815260166020526040902080546001908110612f5657634e487b7160e01b600052603260045260246000fd5b6000918252602082200154604051634f896d4f60e01b815260048101929092526001600160a01b031690634f896d4f90602401600060405180830381600087803b158015612fa357600080fd5b505af1158015612fb7573d6000803e3d6000fd5b505050506001600160a01b038216600090815260166020526040902080546002908110612ff457634e487b7160e01b600052603260045260246000fd5b6000918252602082200154604051634f896d4f60e01b815260048101929092526001600160a01b031690634f896d4f90602401600060405180830381600087803b15801561304157600080fd5b505af1158015613055573d6000803e3d6000fd5b505050505b60005b6001600160a01b0383166000908152601660205260409020548110156117bd576001600160a01b038316600090815260166020526040902080546130d79190839081106130ba57634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546007906001600160a01b0316614af1565b6001600160a01b0383166000908152601660205260409020805461313191908390811061311457634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546009906001600160a01b0316614c74565b8061313b816159d2565b91505061305d565b60035460ff16156131665760405162461bcd60e51b8152600401610ad2906157fa565b61316e613eaf565b60005b818110156117bd57600083838381811061319b57634e487b7160e01b600052603260045260246000fd5b90506020020160208101906131b0919061501f565b90506131bb81613743565b6131d75760405162461bcd60e51b8152600401610ad29061578a565b60405163646d919f60e11b81523360048201526001600160a01b0382169063c8db233e90602401600060405180830381600087803b15801561321857600080fd5b505af115801561322c573d6000803e3d6000fd5b50505050613244816009614af190919063ffffffff16565b6040516001600160a01b03821681527f16e62064e42f5aec62df22ae895ef539f153e0d4ea290e2cc4e0e8f708f2fbbc9060200160405180910390a1508061328b816159d2565b915050613171565b61329b613eaf565b6001600160a01b0381166132e35760405162461bcd60e51b815260206004820152600f60248201526e496e76616c6964206164647265737360881b6044820152606401610ad2565b600154600160a81b900460ff16156133335760405162461bcd60e51b8152602060048201526013602482015272105b1c9958591e481d1c985b9cd9995c9c9959606a1b6044820152606401610ad2565b600080546001600160a01b038381166201000081810262010000600160b01b031990941693909317938490556001805460ff60a81b1916600160a81b1790556040805193909404909116825260208201527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c91016109fd565b6133b4613eaf565b6133bd84613743565b6133d95760405162461bcd60e51b8152600401610ad29061578a565b836001600160a01b0316639a82a09a6040518163ffffffff1660e01b815260040160206040518083038186803b15801561341257600080fd5b505afa158015613426573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061344a9190615372565b61348e5760405162461bcd60e51b815260206004820152601560248201527426b0b935b2ba103737ba1031b0b731b2b63632b21760591b6044820152606401610ad2565b6040516364ee874960e11b81526004810184905260248101839052604481018290526001600160a01b0385169063c9dd0e9290606401600060405180830381600087803b1580156134de57600080fd5b505af11580156134f2573d6000803e3d6000fd5b5050604080516001600160a01b038816815260208101879052908101859052606081018490527f11b2eca36fe7a3aaee80f5737d95923d4ac267614f4de9a91e63b24baa2bc1cf9250608001905060405180910390a150505050565b6000816001600160a01b0316635c975abb6040518163ffffffff1660e01b815260040160206040518083038186803b15801561358957600080fd5b505afa15801561359d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fc09190615372565b60075460009082101561360b5760078054839081106135f057634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b031692915050565b506000919050565b61361b613eaf565b60005b82518110156117bd578115156017600085848151811061364e57634e487b7160e01b600052603260045260246000fd5b60209081029190910181015182528101919091526040016000205460ff1615151461373157816017600085848151811061369857634e487b7160e01b600052603260045260246000fd5b6020026020010151815260200190815260200160002060006101000a81548160ff0219169083151502179055507fe98ab4bde655ceada15ea801bef97987659458457b2f770527e7c9ed5aeac98483828151811061370657634e487b7160e01b600052603260045260246000fd5b6020026020010151836040516137289291909182521515602082015260400190565b60405180910390a15b8061373b816159d2565b91505061361e565b600061375060078361462b565b80610fc05750610fc060098361462b565b606061209c600784846147aa565b6000546201000090046001600160a01b031633148061379d57503360009081526012602052604090205460ff165b6137b95760405162461bcd60e51b8152600401610ad290615760565b80156138005760405162461bcd60e51b815260206004820152601660248201527543616e206f6e6c79207365742030206f7574636f6d6560501b6044820152606401610ad2565b816001600160a01b0316633f6fa6556040518163ffffffff1660e01b815260040160206040518083038186803b15801561383957600080fd5b505afa15801561384d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906138719190615372565b6138b35760405162461bcd60e51b815260206004820152601360248201527213585c9ad95d081b9bdd081c995cdbdb1d9959606a1b6044820152606401610ad2565b6138be60078361462b565b156138fb5760405162461bcd60e51b815260206004820152600d60248201526c1058dd1a5d99481b585c9ad95d609a1b6044820152606401610ad2565b6001600160a01b03821660009081526014602052604090205460ff16156139345760405162461bcd60e51b8152600401610ad2906157b3565b816001600160a01b0316635c975abb6040518163ffffffff1660e01b815260040160206040518083038186803b15801561396d57600080fd5b505afa158015613981573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906139a59190615372565b15613a05576040516305b0e2cf60e21b8152600060048201526001600160a01b038316906316c38b3c90602401600060405180830381600087803b1580156139ec57600080fd5b505af1158015613a00573d6000803e3d6000fd5b505050505b604051634f896d4f60e01b8152600481018290526001600160a01b03831690634f896d4f90602401600060405180830381600087803b158015613a4757600080fd5b505af1158015613a5b573d6000803e3d6000fd5b505050506001600160a01b03821660009081526016602052604090205415610c10576001600160a01b03821660009081526016602052604081208054909190613ab457634e487b7160e01b600052603260045260246000fd5b6000918252602082200154604051634f896d4f60e01b815260048101929092526001600160a01b031690634f896d4f90602401600060405180830381600087803b158015613b0157600080fd5b505af1158015613b15573d6000803e3d6000fd5b505050506001600160a01b038216600090815260166020526040902080546001908110613b5257634e487b7160e01b600052603260045260246000fd5b6000918252602082200154604051634f896d4f60e01b815260048101929092526001600160a01b031690634f896d4f90602401600060405180830381600087803b158015613b9f57600080fd5b505af1158015613bb3573d6000803e3d6000fd5b505050506001600160a01b038216600090815260166020526040902080546002908110613bf057634e487b7160e01b600052603260045260246000fd5b6000918252602082200154604051634f896d4f60e01b815260048101929092526001600160a01b031690634f896d4f90602401611e4b565b6000610fc082614acd565b613c3b613eaf565b600e8054911515600160a01b0260ff60a01b19909216919091179055565b606080606083516001600160401b03811115613c8557634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015613cae578160200160208202803683370190505b50925083516001600160401b03811115613cd857634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015613d01578160200160208202803683370190505b50915083516001600160401b03811115613d2b57634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015613d54578160200160208202803683370190505b50905060005b8451811015613e5e57600080613d89878481518110611f1b57634e487b7160e01b600052603260045260246000fd5b91509150613db0878481518110610b4a57634e487b7160e01b600052603260045260246000fd5b848481518110613dd057634e487b7160e01b600052603260045260246000fd5b60200260200101901515908115158152505081868481518110613e0357634e487b7160e01b600052603260045260246000fd5b60200260200101901515908115158152505042811115858481518110613e3957634e487b7160e01b600052603260045260246000fd5b9115156020928302919091019091015250819050613e56816159d2565b915050613d5a565b509193909250565b613e6e613eaf565b6015805460ff19168215159081179091556040519081527fafa98ec751b49f853d1a5f51c4b6df2a6248c9daa73a920ee644094abe32e41e906020016109fd565b6000546201000090046001600160a01b03163314613f275760405162461bcd60e51b815260206004820152602f60248201527f4f6e6c792074686520636f6e7472616374206f776e6572206d6179207065726660448201526e37b936903a3434b99030b1ba34b7b760891b6064820152608401610ad2565b565b60008060008390506000816001600160a01b0316639e3b34bf6040518163ffffffff1660e01b8152600401604080518083038186803b158015613f6b57600080fd5b505afa158015613f7f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613fa39190615525565b509050816001600160a01b031663ef83f7246040518163ffffffff1660e01b815260040160206040518083038186803b158015613fdf57600080fd5b505afa158015613ff3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906140179190615372565b9590945092505050565b6000816001600160a01b0316633f6fa6556040518163ffffffff1660e01b815260040160206040518083038186803b15801561358957600080fd5b600d54604051631c2ab73160e21b81526004810187905286916000916001600160a01b03909116906370aadcc49060240160206040518083038186803b1580156140a557600080fd5b505afa1580156140b9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906140dd919061538e565b60008181526017602052604090205490915060ff168015614100575060155460ff165b15614407576040805160a0810182526011606080830182815270486f6d655465616d4e6f74546f4c6f736560781b608085015283528351808501855291825270417761795465616d4e6f74546f4c6f736560781b602080840191909152808401929092528351808501855260068152654e6f4472617760d01b81840152838501528351600280825291810185529293600093928301908036833701905050905084816000815181106141c257634e487b7160e01b600052603260045260246000fd5b602002602001018181525050612713816001815181106141f257634e487b7160e01b600052603260045260246000fd5b60200260200101818152505060005b60038110156144035760006142a56040518061012001604052808e6001600160a01b031681526020018d815260200186856003811061425057634e487b7160e01b600052603260045260246000fd5b6020020151815260200160405180604001604052808e81526020018d8152508152602001600281526020018581526020016000151581526020018a6001600160a01b031681526020016001151581525061441d565b90506142b2600782614c74565b6001600160a01b0388811660009081526016602090815260408083208054600180820183559185528385200180546001600160a01b031916878716908117909155808552601490935292819020805460ff19169093179092556013549151631c71e4e760e31b8152600481018f9052602481019190915291169063e38f273890604401600060405180830381600087803b15801561434f57600080fd5b505af1158015614363573d6000803e3d6000fd5b505050507f0cf6abc895e0e76ef58c3555c8cd5ffca2afecb927fccd65c136122c0c39404f8882856001815181106143ab57634e487b7160e01b600052603260045260246000fd5b60200260200101518786600381106143d357634e487b7160e01b600052603260045260246000fd5b60200201516040516143e89493929190615621565b60405180910390a150806143fb816159d2565b915050614201565b5050505b5050505050505050565b600061209c8284615964565b600e54604051634f3565e360e01b815260009182916001600160a01b0390911690634f3565e390614452908690600401615857565b602060405180830381600087803b15801561446c57600080fd5b505af1158015614480573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906144a4919061503b565b90506144b1600782614c74565b6000806000836001600160a01b031663cc2ee1966040518163ffffffff1660e01b815260040160606040518083038186803b1580156144ef57600080fd5b505afa158015614503573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061452791906154a0565b925092509250856020015186600001516001600160a01b03167f5b94d36374b7499bec3849984d165c16e10e3ee59241963bd809a169d1a9cf2686896060015160006002811061458757634e487b7160e01b600052603260045260246000fd5b6020908102919091015160608c810151830151604080516001600160a01b039687168152948501939093528383015289841690830152878316608083015291861660a082015290519081900360c00190a37f319d1be996912ef0acee5fb7cc9b908129bf7bc7290609b7578839c4a1689bad84876040015160405161460d92919061565e565b60405180910390a15091949350505050565b600061209c82846159bb565b815460009061463c57506000610fc0565b6001600160a01b0382166000908152600184016020526040902054801515806146a55750826001600160a01b03168460000160008154811061468e57634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b0316145b949350505050565b60008060008390506000816001600160a01b0316639e3b34bf6040518163ffffffff1660e01b8152600401604080518083038186803b1580156146ef57600080fd5b505afa158015614703573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906147279190615525565b509050816001600160a01b031663ef83f7246040518163ffffffff1660e01b815260040160206040518083038186803b15801561476357600080fd5b505afa158015614777573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061479b9190615372565b80614017575061401785614cc6565b606060006147b88385615964565b85549091508111156147c8575083545b8381116147e557505060408051600081526020810190915261209c565b60006147f185836159bb565b90506000816001600160401b0381111561481b57634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015614844578160200160208202803683370190505b50905060005b828110156148e3578761485d8883615964565b8154811061487b57634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b03168282815181106148b957634e487b7160e01b600052603260045260246000fd5b6001600160a01b0390921660209283029190910190910152806148db816159d2565b91505061484a565b509695505050505050565b6040516339acb21f60e21b815260048101839052602481018290526001600160a01b0384169063e6b2c87c90604401600060405180830381600087803b15801561493757600080fd5b505af115801561494b573d6000803e3d6000fd5b5050604080516001600160a01b0387168152602081018690529081018490527f0915c734742076f135119aa0d73364ab8589b1a6d441c764678c275613a3c6e19250606001905060405180910390a1505050565b604051630ceda8e960e41b81526001600160a01b0385811660048301526000919083169063ceda8e909060240160206040518083038186803b1580156149e457600080fd5b505afa1580156149f8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614a1c919061538e565b905060005b81811015611e795760405163088f63ab60e31b81526001600160a01b038781166004830152602482018390526000919085169063447b1d589060440160206040518083038186803b158015614a7557600080fd5b505afa158015614a89573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614aad919061503b565b9050614aba8187876148ee565b5080614ac5816159d2565b915050614a21565b600e54600090600160a01b900460ff1615610fc657610fc064e8d4a510008361597c565b614afb828261462b565b614b3d5760405162461bcd60e51b815260206004820152601360248201527222b632b6b2b73a103737ba1034b71039b2ba1760691b6044820152606401610ad2565b6001600160a01b0381166000908152600180840160205260408220548454909291614b67916159bb565b9050808214614c0f576000846000018281548110614b9557634e487b7160e01b600052603260045260246000fd5b60009182526020909120015485546001600160a01b0390911691508190869085908110614bd257634e487b7160e01b600052603260045260246000fd5b600091825260208083209190910180546001600160a01b0319166001600160a01b0394851617905592909116815260018601909152604090208290555b8354849080614c2e57634e487b7160e01b600052603160045260246000fd5b60008281526020808220830160001990810180546001600160a01b03191690559092019092556001600160a01b0394909416815260019490940190925250506040812055565b614c7e828261462b565b610c105781546001600160a01b038216600081815260018086016020908152604083208590559084018655858252902090910180546001600160a01b03191690911790555050565b6000614cd3826001614ce0565b80610fc05750610fc08260005b60008060008315614d7e57601854604051630ceda8e960e41b81526001600160a01b0387811660048301529091169063ceda8e909060240160206040518083038186803b158015614d3057600080fd5b505afa158015614d44573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614d68919061538e565b6018549092506001600160a01b03169050614e0d565b601354604051630ceda8e960e41b81526001600160a01b0387811660048301529091169063ceda8e909060240160206040518083038186803b158015614dc357600080fd5b505afa158015614dd7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614dfb919061538e565b6013549092506001600160a01b031690505b60005b82811015614f345760405163088f63ab60e31b81526001600160a01b038781166004830152602482018390526000919084169063447b1d589060440160206040518083038186803b158015614e6457600080fd5b505afa158015614e78573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614e9c919061503b565b9050806001600160a01b031663ef83f7246040518163ffffffff1660e01b815260040160206040518083038186803b158015614ed757600080fd5b505afa158015614eeb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614f0f9190615372565b15614f21576001945050505050610fc0565b5080614f2c816159d2565b915050614e10565b50600095945050505050565b8035610f5f81615a19565b60008083601f840112614f5c578182fd5b5081356001600160401b03811115614f72578182fd5b6020830191508360208260051b8501011115614f8d57600080fd5b9250929050565b600082601f830112614fa4578081fd5b81356020614fb9614fb483615941565b615911565b80838252828201915082860187848660051b8901011115614fd8578586fd5b855b85811015614ff657813584529284019290840190600101614fda565b5090979650505050505050565b8035610f5f81615a2e565b803560ff81168114610f5f57600080fd5b600060208284031215615030578081fd5b813561209c81615a19565b60006020828403121561504c578081fd5b815161209c81615a19565b60008060006060848603121561506b578182fd5b833561507681615a19565b9250602084013561508681615a19565b929592945050506040919091013590565b600080604083850312156150a9578182fd5b82356150b481615a19565b915060208301356150c481615a2e565b809150509250929050565b600080604083850312156150e1578182fd5b82356150ec81615a19565b915060208301356150c481615a19565b6000806040838503121561510e578182fd5b823561511981615a19565b946020939093013593505050565b6000806000806080858703121561513c578081fd5b843561514781615a19565b966020860135965060408601359560600135945092505050565b60008060008060008060c08789031215615179578384fd5b863561518481615a19565b9550602087013594506151996040880161500e565b93506151a76060880161500e565b925060808701356151b781615a19565b915060a08701356151c781615a2e565b809150509295509295509295565b600080602083850312156151e7578182fd5b82356001600160401b038111156151fc578283fd5b61520885828601614f4b565b90969095509350505050565b60008060008060608587031215615229578182fd5b84356001600160401b0381111561523e578283fd5b61524a87828801614f4b565b909550935050602085013561525e81615a2e565b915061526c6040860161500e565b905092959194509250565b60006020808385031215615289578182fd5b82356001600160401b0381111561529e578283fd5b8301601f810185136152ae578283fd5b80356152bc614fb482615941565b80828252848201915084840188868560051b87010111156152db578687fd5b8694505b838510156153065780356152f281615a19565b8352600194909401939185019185016152df565b50979650505050505050565b60008060408385031215615324578182fd5b82356001600160401b03811115615339578283fd5b61534585828601614f94565b92505060208301356150c481615a2e565b600060208284031215615367578081fd5b813561209c81615a2e565b600060208284031215615383578081fd5b815161209c81615a2e565b60006020828403121561539f578081fd5b5051919050565b600080600080600080600080610100898b0312156153c2578586fd5b883597506020808a01356001600160401b03808211156153e0578889fd5b818c0191508c601f8301126153f3578889fd5b81358181111561540557615405615a03565b615417601f8201601f19168501615911565b8181528e8583860101111561542a578a8bfd5b81858501868301378a858383010152809b50505060408c0135985060608c0135975060808c0135965060a08c0135925080831115615466578485fd5b50506154748b828c01614f94565b93505061548360c08a01615003565b915061549160e08a01614f40565b90509295985092959890939650565b6000806000606084860312156154b4578081fd5b83516154bf81615a19565b60208501519093506154d081615a19565b60408501519092506154e181615a19565b809150509250925092565b6000602082840312156154fd578081fd5b5035919050565b60008060408385031215615516578182fd5b50508035926020909101359150565b60008060408385031215615537578182fd5b505080516020909101519092909150565b6000815180845260208085019450808401835b8381101561557957815115158752958201959082019060010161555b565b509495945050505050565b8060005b6002811015611348578151845260209384019390910190600101615588565b6000815180845260208085019450808401835b83811015615579578151875295820195908201906001016155ba565b60008151808452815b818110156155fb576020818501810151868301820152016155df565b8181111561560c5782602083870101525b50601f01601f19169290920160200192915050565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090615654908301846155d6565b9695505050505050565b6001600160a01b03831681526040602082018190526000906146a5908301846155d6565b6020808252825182820181905260009190848201906040850190845b818110156156c35783516001600160a01b03168352928401929184019160010161569e565b50909695505050505050565b6060815260006156e26060830186615548565b82810360208401526156f48186615548565b905082810360408401526156548185615548565b60808152600061571b6080830187615548565b828103602084015261572d8187615548565b905082810360408401526157418186615548565b9050828103606084015261575581856155a7565b979650505050505050565b60208082526010908201526f24b73b30b634b2103932b9b7b63b32b960811b604082015260600190565b6020808252600f908201526e26b0b935b2ba103ab735b737bbb71760891b604082015260600190565b60208082526027908201527f4e6f7420737570706f7274656420666f7220646f75626c65206368616e6365206040820152666d61726b65747360c81b606082015260800190565b6020808252603c908201527f5468697320616374696f6e2063616e6e6f7420626520706572666f726d65642060408201527f7768696c652074686520636f6e74726163742069732070617573656400000000606082015260800190565b602081526158716020820183516001600160a01b03169052565b60208201516040820152600060408301516101408060608501526158996101608501836155d6565b915060608501516158ad6080860182615584565b50608085015160c085015260a0850151848303601f190160e08601526158d383826155a7565b92505060c08501516101006158eb8187018315159052565b60e08701516001600160a01b031661012087015290950151151593019290925250919050565b604051601f8201601f191681016001600160401b038111828210171561593957615939615a03565b604052919050565b60006001600160401b0382111561595a5761595a615a03565b5060051b60200190565b60008219821115615977576159776159ed565b500190565b60008261599757634e487b7160e01b81526012600452602481fd5b500490565b60008160001904831182151516156159b6576159b66159ed565b500290565b6000828210156159cd576159cd6159ed565b500390565b60006000198214156159e6576159e66159ed565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114610e4e57600080fd5b8015158114610e4e57600080fdfea2646970667358221220c7e82e603ff7c7ab21419770bd77608e73c2251c8c07240f1750c390d885e52d64736f6c63430008040033

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