Contract 0x5EE98B5d88Fb7AFFe62e1f791A564A6B7925c777

Contract Overview

Balance:
0 ETH
Txn Hash Method
Block
From
To
Value
0x03350b99a24632aceacedb4dec51c036f1fd739ca8b55bc613ec5423969c29290x608060407977042022-09-01 15:26:35390 days 17 hrs ago0x3363e40cd9ed1bfc82dfa42e059d82570dd8651d IN  Create: ExoticPositionalMarketManager0 ETH0.0005516833660.00001
[ Download CSV Export 
Latest 25 internal transaction
Parent Txn Hash Block From To Value
0xa0d6393cbe704665ab854d7e485daa837cb4629acb338a50126f9e503178ff6c43000642023-01-18 7:49:56252 days 1 hr ago 0x42ae885508cc7155fbf747d5acd8babda1b5d9f0 0x5ee98b5d88fb7affe62e1f791a564a6b7925c7770 ETH
0xf8ffc7efab50c3e469b033529a33c9a11be02f159f285c8c1caea2dbe77b04e243000272023-01-18 7:48:42252 days 1 hr ago 0x42ae885508cc7155fbf747d5acd8babda1b5d9f0 0x5ee98b5d88fb7affe62e1f791a564a6b7925c7770 ETH
0x6d515aa96dc9470dc09802dba6ad6cd0f603d28acdaa2ed19a26d229bba02d6d11313112022-09-15 14:44:27376 days 18 hrs ago 0x42ae885508cc7155fbf747d5acd8babda1b5d9f0 0x5ee98b5d88fb7affe62e1f791a564a6b7925c7770 ETH
0x6d515aa96dc9470dc09802dba6ad6cd0f603d28acdaa2ed19a26d229bba02d6d11313112022-09-15 14:44:27376 days 18 hrs ago 0x42ae885508cc7155fbf747d5acd8babda1b5d9f0 0x5ee98b5d88fb7affe62e1f791a564a6b7925c7770 ETH
0x9fc414b22b45877bba736aab410a3e2d97e2b9d9e0de0c758b0ada2bacd3921611285622022-09-15 12:26:18376 days 20 hrs ago 0x42ae885508cc7155fbf747d5acd8babda1b5d9f0 0x5ee98b5d88fb7affe62e1f791a564a6b7925c7770 ETH
0x9fc414b22b45877bba736aab410a3e2d97e2b9d9e0de0c758b0ada2bacd3921611285622022-09-15 12:26:18376 days 20 hrs ago 0x42ae885508cc7155fbf747d5acd8babda1b5d9f0 0x5ee98b5d88fb7affe62e1f791a564a6b7925c7770 ETH
0x91e7fbfff4e39cd3fefa08fce180c8662b2fca7fd6b57952835f2b83daed3ab011280142022-09-15 11:58:22376 days 21 hrs ago 0x42ae885508cc7155fbf747d5acd8babda1b5d9f0 0x5ee98b5d88fb7affe62e1f791a564a6b7925c7770 ETH
0x91e7fbfff4e39cd3fefa08fce180c8662b2fca7fd6b57952835f2b83daed3ab011280142022-09-15 11:58:22376 days 21 hrs ago 0x42ae885508cc7155fbf747d5acd8babda1b5d9f0 0x5ee98b5d88fb7affe62e1f791a564a6b7925c7770 ETH
0x00f7a97d1d041f10475dbf2dbd0c281d00f8550a87ddcf3e7b835902cee89ef211280022022-09-15 11:57:52376 days 21 hrs ago 0x42ae885508cc7155fbf747d5acd8babda1b5d9f0 0x5ee98b5d88fb7affe62e1f791a564a6b7925c7770 ETH
0x00f7a97d1d041f10475dbf2dbd0c281d00f8550a87ddcf3e7b835902cee89ef211280022022-09-15 11:57:52376 days 21 hrs ago 0x42ae885508cc7155fbf747d5acd8babda1b5d9f0 0x5ee98b5d88fb7affe62e1f791a564a6b7925c7770 ETH
0xff6f453ed2d1bb41739586ac0089b3221cc23d769289e5f6d0a03c1aca28a89c11279942022-09-15 11:57:37376 days 21 hrs ago 0x42ae885508cc7155fbf747d5acd8babda1b5d9f0 0x5ee98b5d88fb7affe62e1f791a564a6b7925c7770 ETH
0x5cc6b93bca5cd6cf640932bd7be1b93298dec9bf6237b766885badbafb32aaac11278992022-09-15 11:52:16376 days 21 hrs ago 0x42ae885508cc7155fbf747d5acd8babda1b5d9f0 0x5ee98b5d88fb7affe62e1f791a564a6b7925c7770 ETH
0x5cc6b93bca5cd6cf640932bd7be1b93298dec9bf6237b766885badbafb32aaac11278992022-09-15 11:52:16376 days 21 hrs ago 0x42ae885508cc7155fbf747d5acd8babda1b5d9f0 0x5ee98b5d88fb7affe62e1f791a564a6b7925c7770 ETH
0x4397953950304aea4ce5e35c2df106d3dba6b705e6012541c3da90224a6332c311275552022-09-15 11:31:05376 days 21 hrs ago 0x42ae885508cc7155fbf747d5acd8babda1b5d9f0 0x5ee98b5d88fb7affe62e1f791a564a6b7925c7770 ETH
0xa00df822de7bcbe4c4e711d82718b0ec714fd6bb93d6edc3149c14a33ffa2e6911032752022-09-14 15:16:21377 days 18 hrs ago 0x42ae885508cc7155fbf747d5acd8babda1b5d9f0 0x5ee98b5d88fb7affe62e1f791a564a6b7925c7770 ETH
0xa00df822de7bcbe4c4e711d82718b0ec714fd6bb93d6edc3149c14a33ffa2e6911032752022-09-14 15:16:21377 days 18 hrs ago 0x42ae885508cc7155fbf747d5acd8babda1b5d9f0 0x5ee98b5d88fb7affe62e1f791a564a6b7925c7770 ETH
0xa6cc774835d51064dfa80e0e7e931ddba16a2541538bf8c44e9f3a55f767018f11032652022-09-14 15:15:50377 days 18 hrs ago 0x42ae885508cc7155fbf747d5acd8babda1b5d9f0 0x5ee98b5d88fb7affe62e1f791a564a6b7925c7770 ETH
0xa6cc774835d51064dfa80e0e7e931ddba16a2541538bf8c44e9f3a55f767018f11032652022-09-14 15:15:50377 days 18 hrs ago 0x42ae885508cc7155fbf747d5acd8babda1b5d9f0 0x5ee98b5d88fb7affe62e1f791a564a6b7925c7770 ETH
0xa6cc774835d51064dfa80e0e7e931ddba16a2541538bf8c44e9f3a55f767018f11032652022-09-14 15:15:50377 days 18 hrs ago 0x42ae885508cc7155fbf747d5acd8babda1b5d9f0 0x5ee98b5d88fb7affe62e1f791a564a6b7925c7770 ETH
0xa6cc774835d51064dfa80e0e7e931ddba16a2541538bf8c44e9f3a55f767018f11032652022-09-14 15:15:50377 days 18 hrs ago 0x42ae885508cc7155fbf747d5acd8babda1b5d9f0 0x5ee98b5d88fb7affe62e1f791a564a6b7925c7770 ETH
0xa6cc774835d51064dfa80e0e7e931ddba16a2541538bf8c44e9f3a55f767018f11032652022-09-14 15:15:50377 days 18 hrs ago 0x42ae885508cc7155fbf747d5acd8babda1b5d9f0 0x5ee98b5d88fb7affe62e1f791a564a6b7925c7770 ETH
0xa6cc774835d51064dfa80e0e7e931ddba16a2541538bf8c44e9f3a55f767018f11032652022-09-14 15:15:50377 days 18 hrs ago 0x42ae885508cc7155fbf747d5acd8babda1b5d9f0 0x5ee98b5d88fb7affe62e1f791a564a6b7925c7770 ETH
0xa6cc774835d51064dfa80e0e7e931ddba16a2541538bf8c44e9f3a55f767018f11032652022-09-14 15:15:50377 days 18 hrs ago 0x42ae885508cc7155fbf747d5acd8babda1b5d9f0 0x5ee98b5d88fb7affe62e1f791a564a6b7925c7770 ETH
0xa6cc774835d51064dfa80e0e7e931ddba16a2541538bf8c44e9f3a55f767018f11032652022-09-14 15:15:50377 days 18 hrs ago 0x42ae885508cc7155fbf747d5acd8babda1b5d9f0 0x5ee98b5d88fb7affe62e1f791a564a6b7925c7770 ETH
0xa6cc774835d51064dfa80e0e7e931ddba16a2541538bf8c44e9f3a55f767018f11032652022-09-14 15:15:50377 days 18 hrs ago 0x42ae885508cc7155fbf747d5acd8babda1b5d9f0 0x5ee98b5d88fb7affe62e1f791a564a6b7925c7770 ETH
[ Download CSV Export 
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.

Contract Source Code Verified (Exact Match)

Contract Name:
ExoticPositionalMarketManager

Compiler Version
v0.8.4+commit.c7e474f2

Optimization Enabled:
Yes with 200 runs

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

pragma solidity ^0.8.0;

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

import "@openzeppelin/contracts-4.4.1/proxy/Clones.sol";
import "./ExoticPositionalFixedMarket.sol";
import "./ExoticPositionalOpenBidMarket.sol";
import "../interfaces/IThalesBonds.sol";
import "../interfaces/IExoticPositionalTags.sol";
import "../interfaces/IThalesOracleCouncil.sol";
import "../interfaces/IExoticPositionalMarket.sol";
import "../interfaces/IExoticRewards.sol";

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

contract ExoticPositionalMarketManager is Initializable, ProxyOwned, PausableUpgradeable, ProxyReentrancyGuard {
    using SafeMathUpgradeable for uint;
    using AddressSetLib for AddressSetLib.AddressSet;

    AddressSetLib.AddressSet private _activeMarkets;

    uint public fixedBondAmount;
    uint public backstopTimeout;
    uint public minimumPositioningDuration;
    uint public claimTimeoutDefaultPeriod;
    uint public pDAOResolveTimePeriod;
    uint public safeBoxPercentage;
    uint public creatorPercentage;
    uint public resolverPercentage;
    uint public withdrawalPercentage;
    uint public maximumPositionsAllowed;
    uint public disputePrice;
    uint public maxOracleCouncilMembers;
    uint public pausersCount;
    uint public maxNumberOfTags;
    uint public backstopTimeoutGeneral;
    uint public safeBoxLowAmount;
    uint public arbitraryRewardForDisputor;
    uint public minFixedTicketPrice;
    uint public disputeStringLengthLimit;
    uint public marketQuestionStringLimit;
    uint public marketSourceStringLimit;
    uint public marketPositionStringLimit;
    uint public withdrawalTimePeriod;
    bool public creationRestrictedToOwner;
    bool public openBidAllowed;

    address public exoticMarketMastercopy;
    address public oracleCouncilAddress;
    address public safeBoxAddress;
    address public thalesBonds;
    address public paymentToken;
    address public tagsAddress;
    address public theRundownConsumerAddress;
    address public marketDataAddress;
    address public exoticMarketOpenBidMastercopy;
    address public exoticRewards;

    mapping(uint => address) public pauserAddress;
    mapping(address => uint) public pauserIndex;

    mapping(address => address) public creatorAddress;
    mapping(address => address) public resolverAddress;
    mapping(address => bool) public isChainLinkMarket;
    mapping(address => bool) public cancelledByCreator;
    uint public maxAmountForOpenBidPosition;
    uint public maxFinalWithdrawPercentage;
    uint public maxFixedTicketPrice;

    function initialize(address _owner) public initializer {
        setOwner(_owner);
        initNonReentrant();
    }

    // Create Exotic market
    function createExoticMarket(
        string memory _marketQuestion,
        string memory _marketSource,
        string memory _additionalInfo,
        uint _endOfPositioning,
        uint _fixedTicketPrice,
        bool _withdrawalAllowed,
        uint[] memory _tags,
        uint _positionCount,
        uint[] memory _positionsOfCreator,
        string[] memory _positionPhrases
    ) external nonReentrant whenNotPaused {
        require(_endOfPositioning >= block.timestamp.add(minimumPositioningDuration), "endOfPositioning too low.");
        require(!creationRestrictedToOwner || msg.sender == owner, "Restricted creation");
        require(
            (openBidAllowed && _fixedTicketPrice == 0) ||
                (_fixedTicketPrice >= minFixedTicketPrice && _fixedTicketPrice <= maxFixedTicketPrice),
            "Exc min/max"
        );
        require(_tags.length > 0 && _tags.length <= maxNumberOfTags);
        require(keccak256(abi.encode(_marketQuestion)) != keccak256(abi.encode("")), "Invalid question.");
        require(keccak256(abi.encode(_marketSource)) != keccak256(abi.encode("")), "Invalid source");
        require(_positionCount == _positionPhrases.length, "Invalid posCount.");
        require(bytes(_marketQuestion).length < marketQuestionStringLimit, "mQuestion exceeds length");
        require(bytes(_marketSource).length < marketSourceStringLimit, "mSource exceeds length");
        require(thereAreNonEqualPositions(_positionPhrases), "Equal positional phrases");
        for (uint i = 0; i < _tags.length; i++) {
            require(IExoticPositionalTags(tagsAddress).isValidTagNumber(_tags[i]), "Invalid tag.");
        }

        if (_fixedTicketPrice > 0) {
            require(
                IERC20(paymentToken).balanceOf(msg.sender) >= fixedBondAmount.add(_fixedTicketPrice),
                "Low amount for creation."
            );
            require(
                IERC20(paymentToken).allowance(msg.sender, thalesBonds) >= fixedBondAmount.add(_fixedTicketPrice),
                "No allowance."
            );
            ExoticPositionalFixedMarket exoticMarket = ExoticPositionalFixedMarket(Clones.clone(exoticMarketMastercopy));

            exoticMarket.initialize(
                _marketQuestion,
                _marketSource,
                _additionalInfo,
                _endOfPositioning,
                _fixedTicketPrice,
                _withdrawalAllowed,
                _tags,
                _positionCount,
                _positionPhrases
            );
            creatorAddress[address(exoticMarket)] = msg.sender;
            IThalesBonds(thalesBonds).sendCreatorBondToMarket(address(exoticMarket), msg.sender, fixedBondAmount);
            _activeMarkets.add(address(exoticMarket));
            exoticMarket.takeCreatorInitialPosition(_positionsOfCreator[0]);
            emit MarketCreatedWithDescription(
                address(exoticMarket),
                _marketQuestion,
                _marketSource,
                _additionalInfo,
                _endOfPositioning,
                _fixedTicketPrice,
                _withdrawalAllowed,
                _tags,
                _positionCount,
                _positionPhrases,
                msg.sender
            );
        } else {
            require(_positionsOfCreator.length == _positionCount, "Creator init pos invalid");
            uint totalCreatorDeposit;
            uint[] memory creatorPositions = new uint[](_positionCount);
            for (uint i = 0; i < _positionCount; i++) {
                totalCreatorDeposit = totalCreatorDeposit.add(_positionsOfCreator[i]);
                creatorPositions[i] = i + 1;
            }
            require(IERC20(paymentToken).balanceOf(msg.sender) >= fixedBondAmount.add(totalCreatorDeposit), "Low amount");
            require(
                IERC20(paymentToken).allowance(msg.sender, thalesBonds) >= fixedBondAmount.add(totalCreatorDeposit),
                "No allowance."
            );

            ExoticPositionalOpenBidMarket exoticMarket = ExoticPositionalOpenBidMarket(
                Clones.clone(exoticMarketOpenBidMastercopy)
            );

            exoticMarket.initialize(
                _marketQuestion,
                _marketSource,
                _additionalInfo,
                _endOfPositioning,
                _fixedTicketPrice,
                _withdrawalAllowed,
                _tags,
                _positionCount,
                _positionPhrases
            );
            creatorAddress[address(exoticMarket)] = msg.sender;
            IThalesBonds(thalesBonds).sendCreatorBondToMarket(address(exoticMarket), msg.sender, fixedBondAmount);
            _activeMarkets.add(address(exoticMarket));
            exoticMarket.takeCreatorInitialOpenBidPositions(creatorPositions, _positionsOfCreator);
            emit MarketCreatedWithDescription(
                address(exoticMarket),
                _marketQuestion,
                _marketSource,
                _additionalInfo,
                _endOfPositioning,
                _fixedTicketPrice,
                _withdrawalAllowed,
                _tags,
                _positionCount,
                _positionPhrases,
                msg.sender
            );
        }
    }

    // function createCLMarket(
    //     string memory _marketQuestion,
    //     string memory _marketSource,
    //     string memory _additionalInfo,
    //     uint _endOfPositioning,
    //     uint _fixedTicketPrice,
    //     bool _withdrawalAllowed,
    //     uint[] memory _tags,
    //     uint _positionCount,
    //     uint[] memory _positionsOfCreator,
    //     string[] memory _positionPhrases
    // ) external nonReentrant whenNotPaused {
    //     require(_endOfPositioning >= block.timestamp.add(minimumPositioningDuration), "endOfPositioning too low");
    //     require(theRundownConsumerAddress != address(0), "Invalid theRundownConsumer");
    //     require(msg.sender == theRundownConsumerAddress, "Invalid creator");
    //     require(_tags.length > 0 && _tags.length <= maxNumberOfTags);
    //     require(keccak256(abi.encode(_marketQuestion)) != keccak256(abi.encode("")), "Invalid question");
    //     require(keccak256(abi.encode(_marketSource)) != keccak256(abi.encode("")), "Invalid source");
    //     require(_positionCount == _positionPhrases.length, "Invalid posCount");
    //     require(bytes(_marketQuestion).length < 110, "Q exceeds length");
    //     require(thereAreNonEqualPositions(_positionPhrases), "Equal pos phrases");
    //     require(_positionsOfCreator.length == _positionCount, "Creator deposits wrong");
    //     uint totalCreatorDeposit;
    //     uint[] memory creatorPositions = new uint[](_positionCount);
    //     for (uint i = 0; i < _positionCount; i++) {
    //         totalCreatorDeposit = totalCreatorDeposit.add(_positionsOfCreator[i]);
    //         creatorPositions[i] = i + 1;
    //     }
    //     require(IERC20(paymentToken).balanceOf(msg.sender) >= totalCreatorDeposit, "Low creation amount");
    //     require(IERC20(paymentToken).allowance(msg.sender, thalesBonds) >= totalCreatorDeposit, "No allowance.");

    //     ExoticPositionalOpenBidMarket exoticMarket =
    //         ExoticPositionalOpenBidMarket(Clones.clone(exoticMarketOpenBidMastercopy));
    //     exoticMarket.initialize(
    //         _marketQuestion,
    //         _marketSource,
    //         _additionalInfo,
    //         _endOfPositioning,
    //         _fixedTicketPrice,
    //         _withdrawalAllowed,
    //         _tags,
    //         _positionCount,
    //         _positionPhrases
    //     );
    //     isChainLinkMarket[address(exoticMarket)] = true;
    //     creatorAddress[address(exoticMarket)] = msg.sender;
    //     _activeMarkets.add(address(exoticMarket));
    //     exoticMarket.takeCreatorInitialOpenBidPositions(creatorPositions, _positionsOfCreator);
    //     emit CLMarketCreated(
    //         address(exoticMarket),
    //         _marketQuestion,
    //         _marketSource,
    //         _endOfPositioning,
    //         _fixedTicketPrice,
    //         _withdrawalAllowed,
    //         _tags,
    //         _positionCount,
    //         _positionPhrases,
    //         msg.sender
    //     );
    // }

    function resolveMarket(address _marketAddress, uint _outcomePosition) external whenNotPaused {
        require(isActiveMarket(_marketAddress), "NotActive");
        if (isChainLinkMarket[_marketAddress]) {
            require(msg.sender == theRundownConsumerAddress, "Only theRundownConsumer");
        }
        require(!IThalesOracleCouncil(oracleCouncilAddress).isOracleCouncilMember(msg.sender), "OC mem can not resolve");
        if (msg.sender != owner && msg.sender != oracleCouncilAddress) {
            require(IExoticPositionalMarket(_marketAddress).canMarketBeResolved(), "Resolved");
        }
        if (IExoticPositionalMarket(_marketAddress).paused()) {
            require(msg.sender == owner, "Only pDAO while paused");
        }
        if (
            (msg.sender == creatorAddress[_marketAddress] &&
                IThalesBonds(thalesBonds).getCreatorBondForMarket(_marketAddress) > 0) ||
            msg.sender == owner ||
            msg.sender == oracleCouncilAddress
        ) {
            require(oracleCouncilAddress != address(0), "Invalid OC");
            require(creatorAddress[_marketAddress] != address(0), "Invalid creator");
            require(owner != address(0), "Invalid owner");
            if (msg.sender == creatorAddress[_marketAddress]) {
                IThalesBonds(thalesBonds).transferCreatorToResolverBonds(_marketAddress);
            }
        } else {
            require(
                IERC20(paymentToken).balanceOf(msg.sender) >= IExoticPositionalMarket(_marketAddress).fixedBondAmount(),
                "Low amount for creation"
            );
            require(
                IERC20(paymentToken).allowance(msg.sender, thalesBonds) >=
                    IExoticPositionalMarket(_marketAddress).fixedBondAmount(),
                "No allowance."
            );
            IThalesBonds(thalesBonds).sendResolverBondToMarket(
                _marketAddress,
                msg.sender,
                IExoticPositionalMarket(_marketAddress).fixedBondAmount()
            );
        }
        resolverAddress[_marketAddress] = (msg.sender == oracleCouncilAddress || msg.sender == owner)
            ? safeBoxAddress
            : msg.sender;
        IExoticPositionalMarket(_marketAddress).resolveMarket(_outcomePosition, resolverAddress[_marketAddress]);
        emit MarketResolved(_marketAddress, _outcomePosition);
    }

    function cancelMarket(address _marketAddress) external whenNotPaused {
        require(isActiveMarket(_marketAddress), "NotActive");
        require(
            msg.sender == oracleCouncilAddress || msg.sender == owner || msg.sender == creatorAddress[_marketAddress],
            "Invalid address"
        );
        if (msg.sender != owner) {
            require(oracleCouncilAddress != address(0), "Invalid address");
        }
        // Creator can cancel if it is the only ticket holder or only one that placed open bid
        if (msg.sender == creatorAddress[_marketAddress]) {
            require(
                IExoticPositionalMarket(_marketAddress).canCreatorCancelMarket(),
                "Market can not be cancelled by creator"
            );
            cancelledByCreator[_marketAddress] = true;
            if (!IThalesOracleCouncil(oracleCouncilAddress).isMarketClosedForDisputes(_marketAddress)) {
                IThalesOracleCouncil(oracleCouncilAddress).closeMarketForDisputes(_marketAddress);
            }
            IThalesBonds(thalesBonds).decreaseCreatorVolume(_marketAddress);
        }
        if (IExoticPositionalMarket(_marketAddress).paused()) {
            require(msg.sender == owner, "only pDAO");
        }
        IExoticPositionalMarket(_marketAddress).cancelMarket();
        resolverAddress[msg.sender] = safeBoxAddress;
        if (cancelledByCreator[_marketAddress]) {
            IExoticPositionalMarket(_marketAddress).claimWinningTicketOnBehalf(creatorAddress[_marketAddress]);
        }
        emit MarketCanceled(_marketAddress);
    }

    function resetMarket(address _marketAddress) external onlyOracleCouncilAndOwner {
        require(isActiveMarket(_marketAddress), "NotActive");
        if (IExoticPositionalMarket(_marketAddress).paused()) {
            require(msg.sender == owner, "only pDAO");
            if (IThalesBonds(thalesBonds).getResolverBondForMarket(_marketAddress) > 0) {
                IThalesBonds(thalesBonds).sendBondFromMarketToUser(
                    _marketAddress,
                    safeBoxAddress,
                    IThalesBonds(thalesBonds).getResolverBondForMarket(_marketAddress),
                    102,
                    safeBoxAddress
                );
            }
        }
        IExoticPositionalMarket(_marketAddress).resetMarket();
        emit MarketReset(_marketAddress);
    }

    function sendRewardToDisputor(
        address _market,
        address _disputorAddress,
        uint _amount
    ) external onlyOracleCouncilAndOwner whenNotPaused {
        require(isActiveMarket(_market), "NotActive");
        IExoticRewards(exoticRewards).sendRewardToDisputoraddress(_market, _disputorAddress, _amount);
    }

    function issueBondsBackToCreatorAndResolver(address _marketAddress) external nonReentrant {
        require(isActiveMarket(_marketAddress), "NotActive");
        require(
            IExoticPositionalMarket(_marketAddress).canUsersClaim() || cancelledByCreator[_marketAddress],
            "Not claimable"
        );
        if (
            IThalesBonds(thalesBonds).getCreatorBondForMarket(_marketAddress) > 0 ||
            IThalesBonds(thalesBonds).getResolverBondForMarket(_marketAddress) > 0
        ) {
            IThalesBonds(thalesBonds).issueBondsBackToCreatorAndResolver(_marketAddress);
        }
    }

    function disputeMarket(address _marketAddress, address _disputor) external onlyOracleCouncil whenNotPaused {
        require(isActiveMarket(_marketAddress), "NotActive");
        IThalesBonds(thalesBonds).sendDisputorBondToMarket(
            _marketAddress,
            _disputor,
            IExoticPositionalMarket(_marketAddress).disputePrice()
        );
        require(!IExoticPositionalMarket(_marketAddress).paused(), "Market paused");
        if (!IExoticPositionalMarket(_marketAddress).disputed()) {
            IExoticPositionalMarket(_marketAddress).openDispute();
        }
    }

    function closeDispute(address _marketAddress) external onlyOracleCouncilAndOwner whenNotPaused {
        require(isActiveMarket(_marketAddress), "NotActive");
        if (IExoticPositionalMarket(_marketAddress).paused()) {
            require(msg.sender == owner, "Only pDAO");
        }
        require(IExoticPositionalMarket(_marketAddress).disputed(), "Market not disputed");
        IExoticPositionalMarket(_marketAddress).closeDispute();
    }

    function isActiveMarket(address _marketAddress) public view returns (bool) {
        return _activeMarkets.contains(_marketAddress);
    }

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

    function getActiveMarketAddress(uint _index) external view returns (address) {
        return _activeMarkets.elements[_index];
    }

    function isPauserAddress(address _pauser) external view returns (bool) {
        return pauserIndex[_pauser] > 0;
    }

    function setBackstopTimeout(address _market) external onlyOracleCouncilAndOwner {
        IExoticPositionalMarket(_market).setBackstopTimeout(backstopTimeout);
    }

    function setCustomBackstopTimeout(address _market, uint _timeout) external onlyOracleCouncilAndOwner {
        require(_timeout > 0, "Invalid timeout");
        if (IExoticPositionalMarket(_market).backstopTimeout() != _timeout) {
            IExoticPositionalMarket(_market).setBackstopTimeout(_timeout);
        }
    }

    function setAddresses(
        address _exoticMarketMastercopy,
        address _exoticMarketOpenBidMastercopy,
        address _oracleCouncilAddress,
        address _paymentToken,
        address _tagsAddress,
        address _theRundownConsumerAddress,
        address _marketDataAddress,
        address _exoticRewards,
        address _safeBoxAddress
    ) external onlyOwner {
        if (_paymentToken != paymentToken) {
            paymentToken = _paymentToken;
        }
        if (_exoticMarketMastercopy != exoticMarketMastercopy) {
            exoticMarketMastercopy = _exoticMarketMastercopy;
        }
        if (_exoticMarketOpenBidMastercopy != exoticMarketOpenBidMastercopy) {
            exoticMarketOpenBidMastercopy = _exoticMarketOpenBidMastercopy;
        }
        if (_oracleCouncilAddress != oracleCouncilAddress) {
            oracleCouncilAddress = _oracleCouncilAddress;
        }
        if (_tagsAddress != tagsAddress) {
            tagsAddress = _tagsAddress;
        }

        if (_theRundownConsumerAddress != theRundownConsumerAddress) {
            theRundownConsumerAddress = _theRundownConsumerAddress;
        }

        if (_marketDataAddress != marketDataAddress) {
            marketDataAddress = _marketDataAddress;
        }
        if (_exoticRewards != exoticRewards) {
            exoticRewards = _exoticRewards;
        }

        if (_safeBoxAddress != safeBoxAddress) {
            safeBoxAddress = _safeBoxAddress;
        }
        emit AddressesUpdated(
            _paymentToken,
            _exoticMarketMastercopy,
            _exoticMarketOpenBidMastercopy,
            _oracleCouncilAddress,
            _tagsAddress,
            _theRundownConsumerAddress,
            _marketDataAddress,
            _exoticRewards,
            _safeBoxAddress
        );
    }

    function setPercentages(
        uint _safeBoxPercentage,
        uint _creatorPercentage,
        uint _resolverPercentage,
        uint _withdrawalPercentage,
        uint _maxFinalWithdrawPercentage
    ) external onlyOwner {
        if (_safeBoxPercentage != safeBoxPercentage) {
            safeBoxPercentage = _safeBoxPercentage;
        }
        if (_creatorPercentage != creatorPercentage) {
            creatorPercentage = _creatorPercentage;
        }
        if (_resolverPercentage != resolverPercentage) {
            resolverPercentage = _resolverPercentage;
        }
        if (_withdrawalPercentage != withdrawalPercentage) {
            withdrawalPercentage = _withdrawalPercentage;
        }
        if (_maxFinalWithdrawPercentage != maxFinalWithdrawPercentage) {
            maxFinalWithdrawPercentage = _maxFinalWithdrawPercentage;
        }
        emit PercentagesUpdated(
            _safeBoxPercentage,
            _creatorPercentage,
            _resolverPercentage,
            _withdrawalPercentage,
            _maxFinalWithdrawPercentage
        );
    }

    function setDurations(
        uint _backstopTimeout,
        uint _minimumPositioningDuration,
        uint _withdrawalTimePeriod,
        uint _pDAOResolveTimePeriod,
        uint _claimTimeoutDefaultPeriod
    ) external onlyOwner {
        if (_backstopTimeout != backstopTimeout) {
            backstopTimeout = _backstopTimeout;
        }

        if (_minimumPositioningDuration != minimumPositioningDuration) {
            minimumPositioningDuration = _minimumPositioningDuration;
        }

        if (_withdrawalTimePeriod != withdrawalTimePeriod) {
            withdrawalTimePeriod = _withdrawalTimePeriod;
        }

        if (_pDAOResolveTimePeriod != pDAOResolveTimePeriod) {
            pDAOResolveTimePeriod = _pDAOResolveTimePeriod;
        }

        if (_claimTimeoutDefaultPeriod != claimTimeoutDefaultPeriod) {
            claimTimeoutDefaultPeriod = _claimTimeoutDefaultPeriod;
        }

        emit DurationsUpdated(
            _backstopTimeout,
            _minimumPositioningDuration,
            _withdrawalTimePeriod,
            _pDAOResolveTimePeriod,
            _claimTimeoutDefaultPeriod
        );
    }

    function setLimits(
        uint _marketQuestionStringLimit,
        uint _marketSourceStringLimit,
        uint _marketPositionStringLimit,
        uint _disputeStringLengthLimit,
        uint _maximumPositionsAllowed,
        uint _maxNumberOfTags,
        uint _maxOracleCouncilMembers
    ) external onlyOwner {
        if (_marketQuestionStringLimit != marketQuestionStringLimit) {
            marketQuestionStringLimit = _marketQuestionStringLimit;
        }

        if (_marketSourceStringLimit != marketSourceStringLimit) {
            marketSourceStringLimit = _marketSourceStringLimit;
        }

        if (_marketPositionStringLimit != marketPositionStringLimit) {
            marketPositionStringLimit = _marketPositionStringLimit;
        }

        if (_disputeStringLengthLimit != disputeStringLengthLimit) {
            disputeStringLengthLimit = _disputeStringLengthLimit;
        }

        if (_maximumPositionsAllowed != maximumPositionsAllowed) {
            maximumPositionsAllowed = _maximumPositionsAllowed;
        }

        if (_maxNumberOfTags != maxNumberOfTags) {
            maxNumberOfTags = _maxNumberOfTags;
        }

        if (_maxOracleCouncilMembers != maxOracleCouncilMembers) {
            maxOracleCouncilMembers = _maxOracleCouncilMembers;
        }

        emit LimitsUpdated(
            _marketQuestionStringLimit,
            _marketSourceStringLimit,
            _marketPositionStringLimit,
            _disputeStringLengthLimit,
            _maximumPositionsAllowed,
            _maxNumberOfTags,
            _maxOracleCouncilMembers
        );
    }

    function setAmounts(
        uint _minFixedTicketPrice,
        uint _maxFixedTicketPrice,
        uint _disputePrice,
        uint _fixedBondAmount,
        uint _safeBoxLowAmount,
        uint _arbitraryRewardForDisputor,
        uint _maxAmountForOpenBidPosition
    ) external onlyOwner {
        if (_minFixedTicketPrice != minFixedTicketPrice) {
            minFixedTicketPrice = _minFixedTicketPrice;
        }

        if (_maxFixedTicketPrice != maxFixedTicketPrice) {
            maxFixedTicketPrice = _maxFixedTicketPrice;
        }

        if (_disputePrice != disputePrice) {
            disputePrice = _disputePrice;
        }

        if (_fixedBondAmount != fixedBondAmount) {
            fixedBondAmount = _fixedBondAmount;
        }

        if (_safeBoxLowAmount != safeBoxLowAmount) {
            safeBoxLowAmount = _safeBoxLowAmount;
        }

        if (_arbitraryRewardForDisputor != arbitraryRewardForDisputor) {
            arbitraryRewardForDisputor = _arbitraryRewardForDisputor;
        }

        if (_maxAmountForOpenBidPosition != maxAmountForOpenBidPosition) {
            maxAmountForOpenBidPosition = _maxAmountForOpenBidPosition;
        }

        emit AmountsUpdated(
            _minFixedTicketPrice,
            _maxFixedTicketPrice,
            _disputePrice,
            _fixedBondAmount,
            _safeBoxLowAmount,
            _arbitraryRewardForDisputor,
            _maxAmountForOpenBidPosition
        );
    }

    function setFlags(bool _creationRestrictedToOwner, bool _openBidAllowed) external onlyOwner {
        if (_creationRestrictedToOwner != creationRestrictedToOwner) {
            creationRestrictedToOwner = _creationRestrictedToOwner;
        }

        if (_openBidAllowed != openBidAllowed) {
            openBidAllowed = _openBidAllowed;
        }

        emit FlagsUpdated(_creationRestrictedToOwner, _openBidAllowed);
    }

    function setThalesBonds(address _thalesBonds) external onlyOwner {
        require(_thalesBonds != address(0), "Invalid address");
        if (thalesBonds != address(0)) {
            IERC20(paymentToken).approve(address(thalesBonds), 0);
        }
        thalesBonds = _thalesBonds;
        IERC20(paymentToken).approve(address(thalesBonds), type(uint256).max);
        emit NewThalesBonds(_thalesBonds);
    }

    function addPauserAddress(address _pauserAddress) external onlyOracleCouncilAndOwner {
        require(_pauserAddress != address(0), "Invalid address");
        require(pauserIndex[_pauserAddress] == 0, "Exists as pauser");
        pausersCount = pausersCount.add(1);
        pauserIndex[_pauserAddress] = pausersCount;
        pauserAddress[pausersCount] = _pauserAddress;
        emit PauserAddressAdded(_pauserAddress);
    }

    function removePauserAddress(address _pauserAddress) external onlyOracleCouncilAndOwner {
        require(_pauserAddress != address(0), "Invalid address");
        require(pauserIndex[_pauserAddress] != 0, "Not exists");
        pauserAddress[pauserIndex[_pauserAddress]] = pauserAddress[pausersCount];
        pauserIndex[pauserAddress[pausersCount]] = pauserIndex[_pauserAddress];
        pausersCount = pausersCount.sub(1);
        pauserIndex[_pauserAddress] = 0;
        emit PauserAddressRemoved(_pauserAddress);
    }

    // INTERNAL

    function thereAreNonEqualPositions(string[] memory positionPhrases) internal view returns (bool) {
        for (uint i = 0; i < positionPhrases.length - 1; i++) {
            if (
                keccak256(abi.encode(positionPhrases[i])) == keccak256(abi.encode(positionPhrases[i + 1])) ||
                bytes(positionPhrases[i]).length > marketPositionStringLimit
            ) {
                return false;
            }
        }
        return true;
    }

    event AddressesUpdated(
        address _exoticMarketMastercopy,
        address _exoticMarketOpenBidMastercopy,
        address _oracleCouncilAddress,
        address _paymentToken,
        address _tagsAddress,
        address _theRundownConsumerAddress,
        address _marketDataAddress,
        address _exoticRewards,
        address _safeBoxAddress
    );

    event PercentagesUpdated(
        uint safeBoxPercentage,
        uint creatorPercentage,
        uint resolverPercentage,
        uint withdrawalPercentage,
        uint maxFinalWithdrawPercentage
    );

    event DurationsUpdated(
        uint backstopTimeout,
        uint minimumPositioningDuration,
        uint withdrawalTimePeriod,
        uint pDAOResolveTimePeriod,
        uint claimTimeoutDefaultPeriod
    );
    event LimitsUpdated(
        uint marketQuestionStringLimit,
        uint marketSourceStringLimit,
        uint marketPositionStringLimit,
        uint disputeStringLengthLimit,
        uint maximumPositionsAllowed,
        uint maxNumberOfTags,
        uint maxOracleCouncilMembers
    );

    event AmountsUpdated(
        uint minFixedTicketPrice,
        uint maxFixedTicketPrice,
        uint disputePrice,
        uint fixedBondAmount,
        uint safeBoxLowAmount,
        uint arbitraryRewardForDisputor,
        uint maxAmountForOpenBidPosition
    );

    event FlagsUpdated(bool _creationRestrictedToOwner, bool _openBidAllowed);

    event MarketResolved(address marketAddress, uint outcomePosition);
    event MarketCanceled(address marketAddress);
    event MarketReset(address marketAddress);
    event PauserAddressAdded(address pauserAddress);
    event PauserAddressRemoved(address pauserAddress);
    event NewThalesBonds(address thalesBondsAddress);

    // used for old markets without description
    event MarketCreated(
        address marketAddress,
        string marketQuestion,
        string marketSource,
        uint endOfPositioning,
        uint fixedTicketPrice,
        bool withdrawalAllowed,
        uint[] tags,
        uint positionCount,
        string[] positionPhrases,
        address marketOwner
    );

    event MarketCreatedWithDescription(
        address marketAddress,
        string marketQuestion,
        string marketSource,
        string additionalInfo,
        uint endOfPositioning,
        uint fixedTicketPrice,
        bool withdrawalAllowed,
        uint[] tags,
        uint positionCount,
        string[] positionPhrases,
        address marketOwner
    );

    event CLMarketCreated(
        address marketAddress,
        string marketQuestion,
        string marketSource,
        uint endOfPositioning,
        uint fixedTicketPrice,
        bool withdrawalAllowed,
        uint[] tags,
        uint positionCount,
        string[] positionPhrases,
        address marketOwner
    );

    modifier onlyOracleCouncil() {
        require(msg.sender == oracleCouncilAddress, "No OC");
        require(oracleCouncilAddress != address(0), "No OC");
        _;
    }
    modifier onlyOracleCouncilAndOwner() {
        require(msg.sender == oracleCouncilAddress || msg.sender == owner, "No OC/owner");
        if (msg.sender != owner) {
            require(oracleCouncilAddress != address(0), "No OC/owner");
        }
        _;
    }
}

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

pragma solidity ^0.8.0;

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

/**
 * @title SafeERC20
 * @dev Wrappers around ERC20 operations that throw on failure (when the token
 * contract returns false). Tokens that return no value (and instead revert or
 * throw on failure) are also supported, non-reverting calls are assumed to be
 * successful.
 * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeERC20Upgradeable {
    using AddressUpgradeable for address;

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

    function __Ownable_init_unchained() internal onlyInitializing {
        _transferOwnership(_msgSender());
    }

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

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

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

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

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

File 5 of 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 6 of 27 : SafeMathUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/math/SafeMath.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

File 7 of 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 8 of 27 : PausableUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/Pausable.sol)

pragma solidity ^0.8.0;

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

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

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

    bool private _paused;

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

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

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

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

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

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

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

File 9 of 27 : Clones.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (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) {
        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) {
        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) {
        assembly {
            let ptr := mload(0x40)
            mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
            mstore(add(ptr, 0x14), shl(0x60, implementation))
            mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf3ff00000000000000000000000000000000)
            mstore(add(ptr, 0x38), shl(0x60, deployer))
            mstore(add(ptr, 0x4c), salt)
            mstore(add(ptr, 0x6c), keccak256(ptr, 0x37))
            predicted := keccak256(add(ptr, 0x37), 0x55)
        }
    }

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

File 10 of 27 : ExoticPositionalFixedMarket.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "@openzeppelin/contracts-4.4.1/utils/math/SafeMath.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "../utils/proxy/solidity-0.8.0/ProxyOwned.sol";
import "./OraclePausable.sol";
import "@openzeppelin/contracts-4.4.1/token/ERC20/utils/SafeERC20.sol";
import "../utils/proxy/solidity-0.8.0/ProxyReentrancyGuard.sol";
import "../interfaces/IExoticPositionalMarketManager.sol";
import "../interfaces/IThalesBonds.sol";

contract ExoticPositionalFixedMarket is Initializable, ProxyOwned, OraclePausable, ProxyReentrancyGuard {
    using SafeMath for uint;
    using SafeERC20 for IERC20;

    enum TicketType {
        FIXED_TICKET_PRICE,
        FLEXIBLE_BID
    }
    uint private constant HUNDRED = 100;
    uint private constant ONE_PERCENT = 1e16;
    uint private constant HUNDRED_PERCENT = 1e18;
    uint private constant CANCELED = 0;

    uint public creationTime;
    uint public resolvedTime;
    uint public lastDisputeTime;
    uint public positionCount;
    uint public endOfPositioning;
    uint public marketMaturity;
    uint public fixedTicketPrice;
    uint public backstopTimeout;
    uint public totalUsersTakenPositions;
    uint public claimableTicketsCount;
    uint public winningPosition;
    uint public disputeClosedTime;
    uint public fixedBondAmount;
    uint public disputePrice;
    uint public safeBoxLowAmount;
    uint public arbitraryRewardForDisputor;
    uint public withdrawalPeriod;

    bool public noWinners;
    bool public disputed;
    bool public resolved;
    bool public disputedInPositioningPhase;
    bool public feesAndBondsClaimed;
    bool public withdrawalAllowed;

    address public resolverAddress;
    TicketType public ticketType;
    IExoticPositionalMarketManager public marketManager;
    IThalesBonds public thalesBonds;

    mapping(address => uint) public userPosition;
    mapping(address => uint) public userAlreadyClaimed;
    mapping(uint => uint) public ticketsPerPosition;
    mapping(uint => string) public positionPhrase;
    uint[] public tags;
    string public marketQuestion;
    string public marketSource;
    string public additionalInfo;

    function initialize(
        string memory _marketQuestion,
        string memory _marketSource,
        string memory _additionalInfo,
        uint _endOfPositioning,
        uint _fixedTicketPrice,
        bool _withdrawalAllowed,
        uint[] memory _tags,
        uint _positionCount,
        string[] memory _positionPhrases
    ) external initializer {
        require(
            _positionCount >= 2 && _positionCount <= IExoticPositionalMarketManager(msg.sender).maximumPositionsAllowed(),
            "Invalid num of positions"
        );
        require(_tags.length > 0);
        setOwner(msg.sender);
        marketManager = IExoticPositionalMarketManager(msg.sender);
        thalesBonds = IThalesBonds(marketManager.thalesBonds());
        _initializeWithTwoParameters(
            _marketQuestion,
            _marketSource,
            _additionalInfo,
            _endOfPositioning,
            _fixedTicketPrice,
            _withdrawalAllowed,
            _tags,
            _positionPhrases[0],
            _positionPhrases[1]
        );
        if (_positionCount > 2) {
            for (uint i = 2; i < _positionCount; i++) {
                _addPosition(_positionPhrases[i]);
            }
        }
        fixedBondAmount = marketManager.fixedBondAmount();
        disputePrice = marketManager.disputePrice();
        safeBoxLowAmount = marketManager.safeBoxLowAmount();
        arbitraryRewardForDisputor = marketManager.arbitraryRewardForDisputor();
        withdrawalPeriod = _endOfPositioning.sub(marketManager.withdrawalTimePeriod());
    }

    function takeCreatorInitialPosition(uint _position) external onlyOwner {
        require(_position > 0 && _position <= positionCount, "Value invalid");
        require(ticketType == TicketType.FIXED_TICKET_PRICE, "Not Fixed type");
        totalUsersTakenPositions = totalUsersTakenPositions.add(1);
        address creator = marketManager.creatorAddress(address(this));
        ticketsPerPosition[_position] = ticketsPerPosition[_position].add(1);
        userPosition[creator] = _position;
        IThalesBonds(marketManager.thalesBonds()).transferToMarket(creator, fixedTicketPrice);
        emit NewPositionTaken(creator, _position, fixedTicketPrice);
    }

    function takeAPosition(
        uint _position,
        address collateral,
        uint expectedPayout,
        uint additionalSlippage
    ) external notPaused nonReentrant {
        require(_position > 0, "Invalid position");
        require(_position <= positionCount, "Position value invalid");
        require(canUsersPlacePosition(), "Positioning finished/market resolved");
        //require(same position)
        require(ticketType == TicketType.FIXED_TICKET_PRICE, "Not Fixed type");
        if (userPosition[msg.sender] == 0) {
            transferToMarket(msg.sender, fixedTicketPrice, collateral, expectedPayout, additionalSlippage);
            totalUsersTakenPositions = totalUsersTakenPositions.add(1);
        } else {
            ticketsPerPosition[userPosition[msg.sender]] = ticketsPerPosition[userPosition[msg.sender]].sub(1);
        }
        ticketsPerPosition[_position] = ticketsPerPosition[_position].add(1);
        userPosition[msg.sender] = _position;
        emit NewPositionTaken(msg.sender, _position, fixedTicketPrice);
    }

    function withdraw() external notPaused nonReentrant {
        require(withdrawalAllowed, "Not allowed");
        require(canUsersPlacePosition(), "Market resolved");
        require(block.timestamp <= withdrawalPeriod, "Withdrawal expired");
        require(userPosition[msg.sender] > 0, "Not a ticket holder");
        address creator = marketManager.creatorAddress(address(this));
        require(msg.sender != creator, "Can not withdraw");
        uint withdrawalFee = fixedTicketPrice.mul(marketManager.withdrawalPercentage()).mul(ONE_PERCENT).div(
            HUNDRED_PERCENT
        );
        totalUsersTakenPositions = totalUsersTakenPositions.sub(1);
        ticketsPerPosition[userPosition[msg.sender]] = ticketsPerPosition[userPosition[msg.sender]].sub(1);
        userPosition[msg.sender] = 0;
        thalesBonds.transferFromMarket(marketManager.safeBoxAddress(), withdrawalFee.div(2));
        thalesBonds.transferFromMarket(creator, withdrawalFee.div(2));
        thalesBonds.transferFromMarket(msg.sender, fixedTicketPrice.sub(withdrawalFee));
        emit TicketWithdrawn(msg.sender, fixedTicketPrice.sub(withdrawalFee));
    }

    function issueFees() external notPaused nonReentrant {
        require(canUsersClaim(), "Not finalized");
        require(!feesAndBondsClaimed, "Fees claimed");
        if (winningPosition != CANCELED) {
            thalesBonds.transferFromMarket(marketManager.creatorAddress(address(this)), getAdditionalCreatorAmount());
            thalesBonds.transferFromMarket(resolverAddress, getAdditionalResolverAmount());
            thalesBonds.transferFromMarket(marketManager.safeBoxAddress(), getSafeBoxAmount());
        }
        marketManager.issueBondsBackToCreatorAndResolver(address(this));
        feesAndBondsClaimed = true;
        emit FeesIssued(getTotalFeesAmount());
    }

    // market resolved only through the Manager
    function resolveMarket(uint _outcomePosition, address _resolverAddress) external onlyOwner {
        require(canMarketBeResolvedByOwner(), "Not resolvable. Disputed/not matured");
        require(_outcomePosition <= positionCount, "Outcome exeeds positionNum");
        winningPosition = _outcomePosition;
        if (_outcomePosition == CANCELED) {
            claimableTicketsCount = totalUsersTakenPositions;
            ticketsPerPosition[winningPosition] = totalUsersTakenPositions;
        } else {
            if (ticketsPerPosition[_outcomePosition] == 0) {
                claimableTicketsCount = totalUsersTakenPositions;
                noWinners = true;
            } else {
                claimableTicketsCount = ticketsPerPosition[_outcomePosition];
                noWinners = false;
            }
        }
        resolved = true;
        resolvedTime = block.timestamp;
        resolverAddress = _resolverAddress;
        emit MarketResolved(_outcomePosition, _resolverAddress, noWinners);
    }

    function resetMarket() external onlyOwner {
        require(resolved, "Not resolved");
        if (winningPosition == CANCELED) {
            ticketsPerPosition[winningPosition] = 0;
        }
        winningPosition = 0;
        claimableTicketsCount = 0;
        resolved = false;
        noWinners = false;
        resolvedTime = 0;
        resolverAddress = marketManager.safeBoxAddress();
        emit MarketReset();
    }

    function cancelMarket() external onlyOwner {
        winningPosition = CANCELED;
        claimableTicketsCount = totalUsersTakenPositions;
        ticketsPerPosition[winningPosition] = totalUsersTakenPositions;
        resolved = true;
        noWinners = false;
        resolvedTime = block.timestamp;
        resolverAddress = marketManager.safeBoxAddress();
        emit MarketResolved(CANCELED, msg.sender, noWinners);
    }

    function claimWinningTicket() external notPaused nonReentrant {
        require(canUsersClaim(), "Not finalized.");
        uint amount = getUserClaimableAmount(msg.sender);
        require(amount > 0, "Zero claimable.");
        claimableTicketsCount = claimableTicketsCount.sub(1);
        userPosition[msg.sender] = 0;
        thalesBonds.transferFromMarket(msg.sender, amount);
        if (!feesAndBondsClaimed) {
            if (winningPosition != CANCELED) {
                thalesBonds.transferFromMarket(marketManager.creatorAddress(address(this)), getAdditionalCreatorAmount());
                thalesBonds.transferFromMarket(resolverAddress, getAdditionalResolverAmount());
                thalesBonds.transferFromMarket(marketManager.safeBoxAddress(), getSafeBoxAmount());
            }
            marketManager.issueBondsBackToCreatorAndResolver(address(this));
            feesAndBondsClaimed = true;
            emit FeesIssued(getTotalFeesAmount());
        }
        userAlreadyClaimed[msg.sender] = userAlreadyClaimed[msg.sender].add(amount);
        emit WinningTicketClaimed(msg.sender, amount);
    }

    function claimWinningTicketOnBehalf(address _user) external onlyOwner {
        require(canUsersClaim() || marketManager.cancelledByCreator(address(this)), "Not finalized.");
        uint amount = getUserClaimableAmount(_user);
        require(amount > 0, "Zero claimable.");
        claimableTicketsCount = claimableTicketsCount.sub(1);
        userPosition[_user] = 0;
        thalesBonds.transferFromMarket(_user, amount);
        if (
            winningPosition == CANCELED &&
            marketManager.cancelledByCreator(address(this)) &&
            thalesBonds.getCreatorBondForMarket(address(this)) > 0
        ) {
            marketManager.issueBondsBackToCreatorAndResolver(address(this));
            feesAndBondsClaimed = true;
        } else if (!feesAndBondsClaimed) {
            if (winningPosition != CANCELED) {
                thalesBonds.transferFromMarket(marketManager.creatorAddress(address(this)), getAdditionalCreatorAmount());
                thalesBonds.transferFromMarket(resolverAddress, getAdditionalResolverAmount());
                thalesBonds.transferFromMarket(marketManager.safeBoxAddress(), getSafeBoxAmount());
            }
            marketManager.issueBondsBackToCreatorAndResolver(address(this));
            feesAndBondsClaimed = true;
            emit FeesIssued(getTotalFeesAmount());
        }
        userAlreadyClaimed[msg.sender] = userAlreadyClaimed[msg.sender].add(amount);
        emit WinningTicketClaimed(_user, amount);
    }

    function openDispute() external onlyOwner {
        require(isMarketCreated(), "Not created");
        require(!disputed, "Already disputed");
        disputed = true;
        disputedInPositioningPhase = canUsersPlacePosition();
        lastDisputeTime = block.timestamp;
        emit MarketDisputed(true);
    }

    function closeDispute() external onlyOwner {
        require(disputed, "Not disputed");
        disputeClosedTime = block.timestamp;
        if (disputedInPositioningPhase) {
            disputed = false;
            disputedInPositioningPhase = false;
        } else {
            disputed = false;
        }
        emit MarketDisputed(false);
    }

    function transferToMarket(
        address _sender,
        uint _amount,
        address collateral,
        uint expectedPayout,
        uint additionalSlippage
    ) internal notPaused {
        require(_sender != address(0), "Invalid sender");
        IThalesBonds(marketManager.thalesBonds()).transferToMarket(
            _sender,
            _amount,
            collateral,
            expectedPayout,
            additionalSlippage
        );
    }

    // SETTERS ///////////////////////////////////////////////////////

    function setBackstopTimeout(uint _timeoutPeriod) external onlyOwner {
        backstopTimeout = _timeoutPeriod;
        emit BackstopTimeoutPeriodChanged(_timeoutPeriod);
    }

    // VIEWS /////////////////////////////////////////////////////////

    function isMarketCreated() public view returns (bool) {
        return creationTime > 0;
    }

    function isMarketCancelled() public view returns (bool) {
        return resolved && winningPosition == CANCELED;
    }

    function canUsersPlacePosition() public view returns (bool) {
        return block.timestamp <= endOfPositioning && creationTime > 0 && !resolved;
    }

    function canMarketBeResolved() public view returns (bool) {
        return block.timestamp >= endOfPositioning && creationTime > 0 && (!disputed) && !resolved;
    }

    function canMarketBeResolvedByOwner() public view returns (bool) {
        return block.timestamp >= endOfPositioning && creationTime > 0 && (!disputed);
    }

    function canMarketBeResolvedByPDAO() public view returns (bool) {
        return
            canMarketBeResolvedByOwner() && block.timestamp >= endOfPositioning.add(marketManager.pDAOResolveTimePeriod());
    }

    function canCreatorCancelMarket() external view returns (bool) {
        if (disputed) {
            return false;
        } else if (totalUsersTakenPositions != 1) {
            return totalUsersTakenPositions > 1 ? false : true;
        } else {
            return userPosition[marketManager.creatorAddress(address(this))] > 0 ? true : false;
        }
    }

    function canUsersClaim() public view returns (bool) {
        return
            resolved &&
            (!disputed) &&
            ((resolvedTime > 0 && block.timestamp > resolvedTime.add(marketManager.claimTimeoutDefaultPeriod())) ||
                (backstopTimeout > 0 &&
                    resolvedTime > 0 &&
                    disputeClosedTime > 0 &&
                    block.timestamp > disputeClosedTime.add(backstopTimeout)));
    }

    function canUserClaim(address _user) external view returns (bool) {
        return canUsersClaim() && getUserClaimableAmount(_user) > 0;
    }

    function canIssueFees() external view returns (bool) {
        return
            !feesAndBondsClaimed &&
            (thalesBonds.getCreatorBondForMarket(address(this)) > 0 ||
                thalesBonds.getResolverBondForMarket(address(this)) > 0);
    }

    function canUserWithdraw(address _account) public view returns (bool) {
        if (_account == marketManager.creatorAddress(address(this))) {
            return false;
        }
        return
            withdrawalAllowed &&
            canUsersPlacePosition() &&
            userPosition[_account] > 0 &&
            block.timestamp <= withdrawalPeriod;
    }

    function getPositionPhrase(uint index) public view returns (string memory) {
        return (index <= positionCount && index > 0) ? positionPhrase[index] : string("");
    }

    function getTotalPlacedAmount() public view returns (uint) {
        return totalUsersTakenPositions > 0 ? fixedTicketPrice.mul(totalUsersTakenPositions) : 0;
    }

    function getTotalClaimableAmount() public view returns (uint) {
        if (totalUsersTakenPositions == 0) {
            return 0;
        } else {
            return winningPosition == CANCELED ? getTotalPlacedAmount() : applyDeduction(getTotalPlacedAmount());
        }
    }

    function getTotalFeesAmount() public view returns (uint) {
        return getTotalPlacedAmount().sub(getTotalClaimableAmount());
    }

    function getPlacedAmountPerPosition(uint _position) public view returns (uint) {
        return fixedTicketPrice.mul(ticketsPerPosition[_position]);
    }

    function getUserClaimableAmount(address _account) public view returns (uint) {
        return
            userPosition[_account] > 0 &&
                (noWinners || userPosition[_account] == winningPosition || winningPosition == CANCELED)
                ? getWinningAmountPerTicket()
                : 0;
    }

    /// FLEXIBLE BID FUNCTIONS

    function getAllUserPositions(address _account) external view returns (uint[] memory) {
        uint[] memory userAllPositions = new uint[](positionCount);
        if (positionCount == 0) {
            return userAllPositions;
        }
        userAllPositions[userPosition[_account]] = 1;
        return userAllPositions;
    }

    /// FIXED TICKET FUNCTIONS

    function getUserPosition(address _account) external view returns (uint) {
        return userPosition[_account];
    }

    function getUserPositionPhrase(address _account) external view returns (string memory) {
        return (userPosition[_account] > 0) ? positionPhrase[userPosition[_account]] : string("");
    }

    function getPotentialWinningAmountForAllPosition(bool forNewUserView, uint userAlreadyTakenPosition)
        external
        view
        returns (uint[] memory)
    {
        uint[] memory potentialWinning = new uint[](positionCount);
        for (uint i = 1; i <= positionCount; i++) {
            potentialWinning[i - 1] = getPotentialWinningAmountForPosition(i, forNewUserView, userAlreadyTakenPosition == i);
        }
        return potentialWinning;
    }

    function getUserPotentialWinningAmount(address _account) external view returns (uint) {
        return userPosition[_account] > 0 ? getPotentialWinningAmountForPosition(userPosition[_account], false, true) : 0;
    }

    function getPotentialWinningAmountForPosition(
        uint _position,
        bool forNewUserView,
        bool userHasAlreadyTakenThisPosition
    ) internal view returns (uint) {
        if (totalUsersTakenPositions == 0) {
            return 0;
        }
        if (ticketsPerPosition[_position] == 0) {
            return
                forNewUserView
                    ? applyDeduction(getTotalPlacedAmount().add(fixedTicketPrice))
                    : applyDeduction(getTotalPlacedAmount());
        } else {
            if (forNewUserView) {
                return
                    applyDeduction(getTotalPlacedAmount().add(fixedTicketPrice)).div(ticketsPerPosition[_position].add(1));
            } else {
                uint calculatedPositions = userHasAlreadyTakenThisPosition && ticketsPerPosition[_position] > 0
                    ? ticketsPerPosition[_position]
                    : ticketsPerPosition[_position].add(1);
                return applyDeduction(getTotalPlacedAmount()).div(calculatedPositions);
            }
        }
    }

    function getWinningAmountPerTicket() public view returns (uint) {
        if (totalUsersTakenPositions == 0 || !resolved || (!noWinners && (ticketsPerPosition[winningPosition] == 0))) {
            return 0;
        }
        if (noWinners) {
            return getTotalClaimableAmount().div(totalUsersTakenPositions);
        } else {
            return
                winningPosition == CANCELED
                    ? fixedTicketPrice
                    : getTotalClaimableAmount().div(ticketsPerPosition[winningPosition]);
        }
    }

    function applyDeduction(uint value) internal view returns (uint) {
        return
            (value)
                .mul(
                    HUNDRED.sub(
                        marketManager.safeBoxPercentage().add(marketManager.creatorPercentage()).add(
                            marketManager.resolverPercentage()
                        )
                    )
                )
                .mul(ONE_PERCENT)
                .div(HUNDRED_PERCENT);
    }

    function getTagsCount() external view returns (uint) {
        return tags.length;
    }

    function getTags() external view returns (uint[] memory) {
        return tags;
    }

    function getTicketType() external view returns (uint) {
        return uint(ticketType);
    }

    function getAllAmounts()
        external
        view
        returns (
            uint,
            uint,
            uint,
            uint
        )
    {
        return (fixedBondAmount, disputePrice, safeBoxLowAmount, arbitraryRewardForDisputor);
    }

    function getAllFees()
        external
        view
        returns (
            uint,
            uint,
            uint,
            uint
        )
    {
        return (getAdditionalCreatorAmount(), getAdditionalResolverAmount(), getSafeBoxAmount(), getTotalFeesAmount());
    }

    function getAdditionalCreatorAmount() internal view returns (uint) {
        return getTotalPlacedAmount().mul(marketManager.creatorPercentage()).mul(ONE_PERCENT).div(HUNDRED_PERCENT);
    }

    function getAdditionalResolverAmount() internal view returns (uint) {
        return getTotalPlacedAmount().mul(marketManager.resolverPercentage()).mul(ONE_PERCENT).div(HUNDRED_PERCENT);
    }

    function getSafeBoxAmount() internal view returns (uint) {
        return getTotalPlacedAmount().mul(marketManager.safeBoxPercentage()).mul(ONE_PERCENT).div(HUNDRED_PERCENT);
    }

    function _initializeWithTwoParameters(
        string memory _marketQuestion,
        string memory _marketSource,
        string memory _additionalInfo,
        uint _endOfPositioning,
        uint _fixedTicketPrice,
        bool _withdrawalAllowed,
        uint[] memory _tags,
        string memory _positionPhrase1,
        string memory _positionPhrase2
    ) internal {
        creationTime = block.timestamp;
        marketQuestion = _marketQuestion;
        marketSource = _marketSource;
        additionalInfo = _additionalInfo;
        endOfPositioning = _endOfPositioning;
        // Ticket Type can be determined based on ticket price
        ticketType = _fixedTicketPrice > 0 ? TicketType.FIXED_TICKET_PRICE : TicketType.FLEXIBLE_BID;
        fixedTicketPrice = _fixedTicketPrice;
        // Withdrawal allowance determined based on withdrawal percentage, if it is over 100% then it is forbidden
        withdrawalAllowed = _withdrawalAllowed;
        // The tag is just a number for now
        tags = _tags;
        _addPosition(_positionPhrase1);
        _addPosition(_positionPhrase2);
    }

    function _addPosition(string memory _position) internal {
        require(keccak256(abi.encode(_position)) != keccak256(abi.encode("")), "Invalid position label (empty string)");
        // require(bytes(_position).length < marketManager.marketPositionStringLimit(), "Position label exceeds length");
        positionCount = positionCount.add(1);
        positionPhrase[positionCount] = _position;
    }

    event MarketDisputed(bool disputed);
    event MarketCreated(uint creationTime, uint positionCount, bytes32 phrase);
    event MarketResolved(uint winningPosition, address resolverAddress, bool noWinner);
    event MarketReset();
    event WinningTicketClaimed(address account, uint amount);
    event BackstopTimeoutPeriodChanged(uint timeoutPeriod);
    event NewPositionTaken(address account, uint position, uint fixedTicketAmount);
    event TicketWithdrawn(address account, uint amount);
    event BondIncreased(uint amount, uint totalAmount);
    event BondDecreased(uint amount, uint totalAmount);
    event FeesIssued(uint totalFees);
}

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

pragma solidity ^0.8.0;

import "@openzeppelin/contracts-4.4.1/utils/math/SafeMath.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "../utils/proxy/solidity-0.8.0/ProxyOwned.sol";
import "./OraclePausable.sol";
import "@openzeppelin/contracts-4.4.1/token/ERC20/utils/SafeERC20.sol";
import "../utils/proxy/solidity-0.8.0/ProxyReentrancyGuard.sol";
import "../interfaces/IExoticPositionalMarketManager.sol";
import "../interfaces/IThalesBonds.sol";

contract ExoticPositionalOpenBidMarket is Initializable, ProxyOwned, OraclePausable, ProxyReentrancyGuard {
    using SafeMath for uint;
    using SafeERC20 for IERC20;

    enum TicketType {
        FIXED_TICKET_PRICE,
        FLEXIBLE_BID
    }
    uint private constant HUNDRED = 100;
    uint private constant ONE_PERCENT = 1e16;
    uint private constant HUNDRED_PERCENT = 1e18;
    uint private constant CANCELED = 0;

    uint public creationTime;
    uint public resolvedTime;
    uint public lastDisputeTime;
    uint public positionCount;
    uint public endOfPositioning;
    uint public marketMaturity;
    uint public fixedTicketPrice;
    uint public backstopTimeout;
    uint public totalUsersTakenPositions;
    uint public totalOpenBidAmount;
    uint public claimableOpenBidAmount;
    uint public winningPosition;
    uint public disputeClosedTime;
    uint public fixedBondAmount;
    uint public disputePrice;
    uint public safeBoxLowAmount;
    uint public arbitraryRewardForDisputor;
    uint public withdrawalPeriod;
    uint public maxAmountForOpenBidPosition;
    uint public maxWithdrawPercentage;
    uint public minPosAmount;

    bool public noWinners;
    bool public disputed;
    bool public resolved;
    bool public disputedInPositioningPhase;
    bool public feesAndBondsClaimed;
    bool public withdrawalAllowed;

    address public resolverAddress;
    TicketType public ticketType;
    IExoticPositionalMarketManager public marketManager;
    IThalesBonds public thalesBonds;

    mapping(address => uint) public totalUserPlacedAmount;
    mapping(address => mapping(uint => uint)) public userOpenBidPosition;
    mapping(address => uint) public userAlreadyClaimed;
    mapping(uint => uint) public totalOpenBidAmountPerPosition;
    mapping(uint => string) public positionPhrase;
    mapping(address => bool) public withrawalRestrictedForUser;
    uint[] public tags;
    string public marketQuestion;
    string public marketSource;
    string public additionalInfo;

    function initialize(
        string memory _marketQuestion,
        string memory _marketSource,
        string memory _additionalInfo,
        uint _endOfPositioning,
        uint _fixedTicketPrice,
        bool _withdrawalAllowed,
        uint[] memory _tags,
        uint _positionCount,
        string[] memory _positionPhrases
    ) external initializer {
        require(
            _positionCount >= 2 && _positionCount <= IExoticPositionalMarketManager(msg.sender).maximumPositionsAllowed(),
            "Invalid num pos"
        );
        require(_tags.length > 0);
        setOwner(msg.sender);
        marketManager = IExoticPositionalMarketManager(msg.sender);
        thalesBonds = IThalesBonds(marketManager.thalesBonds());
        _initializeWithTwoParameters(
            _marketQuestion,
            _marketSource,
            _endOfPositioning,
            _fixedTicketPrice,
            _withdrawalAllowed,
            _tags,
            _positionPhrases[0],
            _positionPhrases[1]
        );
        if (_positionCount > 2) {
            for (uint i = 2; i < _positionCount; i++) {
                _addPosition(_positionPhrases[i]);
            }
        }
        additionalInfo = _additionalInfo;
        maxAmountForOpenBidPosition = marketManager.maxAmountForOpenBidPosition();
        maxWithdrawPercentage = marketManager.maxFinalWithdrawPercentage();
        fixedBondAmount = marketManager.fixedBondAmount();
        disputePrice = marketManager.disputePrice();
        safeBoxLowAmount = marketManager.safeBoxLowAmount();
        arbitraryRewardForDisputor = marketManager.arbitraryRewardForDisputor();
        withdrawalPeriod = _endOfPositioning.sub(marketManager.withdrawalTimePeriod());
        minPosAmount = marketManager.minFixedTicketPrice();
    }

    function takeCreatorInitialOpenBidPositions(uint[] memory _positions, uint[] memory _amounts) external onlyOwner {
        require(_positions.length > 0 && _positions.length <= positionCount, "Invalid posNum");
        require(ticketType == TicketType.FLEXIBLE_BID, "Not OpenBid");
        uint totalDepositedAmount = 0;
        address creator = marketManager.creatorAddress(address(this));
        for (uint i = 0; i < _positions.length; i++) {
            require(_positions[i] > 0 && _positions[i] <= positionCount, "Value invalid");
            require(
                _amounts[i] == 0 || (_amounts[i] >= minPosAmount && _amounts[i] <= maxAmountForOpenBidPosition),
                "Amounts exceed"
            );

            totalOpenBidAmountPerPosition[_positions[i]] = totalOpenBidAmountPerPosition[_positions[i]].add(_amounts[i]);
            userOpenBidPosition[creator][_positions[i]] = userOpenBidPosition[creator][_positions[i]].add(_amounts[i]);
            totalDepositedAmount = totalDepositedAmount.add(_amounts[i]);
        }
        require(
            totalUserPlacedAmount[creator].add(totalDepositedAmount) >= minPosAmount &&
                totalUserPlacedAmount[creator].add(totalDepositedAmount) <= maxAmountForOpenBidPosition,
            "Amounts exceed"
        );
        totalOpenBidAmount = totalOpenBidAmount.add(totalDepositedAmount);
        totalUserPlacedAmount[creator] = totalUserPlacedAmount[creator].add(totalDepositedAmount);
        totalUsersTakenPositions = totalUsersTakenPositions.add(1);
        IThalesBonds(marketManager.thalesBonds()).transferToMarket(creator, totalDepositedAmount);
        emit NewOpenBidsForPositions(creator, _positions, _amounts);
    }

    function takeOpenBidPositions(
        uint[] memory _positions,
        uint[] memory _amounts,
        address collateral,
        uint expectedPayout,
        uint additionalSlippage
    ) external notPaused nonReentrant {
        require(_positions.length > 0 && _positions.length <= positionCount, "Invalid posNum");
        require(canUsersPlacePosition(), "Market resolved");
        require(ticketType == TicketType.FLEXIBLE_BID, "Not OpenBid");
        if (block.timestamp.add(1 days) > endOfPositioning) {
            if (totalUserPlacedAmount[msg.sender] > 0) {
                require(
                    totalUserPlacedAmount[msg.sender] <=
                        totalOpenBidAmount.mul(maxWithdrawPercentage.mul(ONE_PERCENT)).div(HUNDRED_PERCENT),
                    "Exceeds reposition"
                );
            }
        }
        uint totalDepositedAmount = 0;
        bool firstTime = true;
        for (uint i = 0; i < _positions.length; i++) {
            require(_positions[i] > 0 && _positions[i] <= positionCount, "Position value invalid");
            require(
                _amounts[i] == 0 || (_amounts[i] >= minPosAmount && _amounts[i] <= maxAmountForOpenBidPosition),
                "Amounts exceed"
            );
            if (userOpenBidPosition[msg.sender][_positions[i]] > 0) {
                totalOpenBidAmountPerPosition[_positions[i]] = totalOpenBidAmountPerPosition[_positions[i]].sub(
                    userOpenBidPosition[msg.sender][_positions[i]]
                );
                firstTime = false;
            }
            totalOpenBidAmountPerPosition[_positions[i]] = totalOpenBidAmountPerPosition[_positions[i]].add(_amounts[i]);
            userOpenBidPosition[msg.sender][_positions[i]] = _amounts[i];
            totalDepositedAmount = totalDepositedAmount.add(_amounts[i]);
        }
        require(
            totalDepositedAmount >= minPosAmount && totalDepositedAmount >= totalUserPlacedAmount[msg.sender],
            "Bellow init amounts"
        );
        uint amountToBeAdded = totalDepositedAmount.sub(totalUserPlacedAmount[msg.sender]);
        require(amountToBeAdded <= maxAmountForOpenBidPosition, "Amounts exceed");
        if (amountToBeAdded > 0) {
            totalOpenBidAmount = totalOpenBidAmount.add(amountToBeAdded);
            totalUserPlacedAmount[msg.sender] = totalUserPlacedAmount[msg.sender].add(amountToBeAdded);
            totalUsersTakenPositions = firstTime ? totalUsersTakenPositions.add(1) : totalUsersTakenPositions;
            transferToMarket(msg.sender, amountToBeAdded, collateral, expectedPayout, additionalSlippage);
        }
        emit NewOpenBidsForPositions(msg.sender, _positions, _amounts);
    }

    function withdraw(uint _openBidPosition) external notPaused nonReentrant {
        require(withdrawalAllowed && canUsersPlacePosition() && block.timestamp <= withdrawalPeriod, "Not allowed");
        address creator = marketManager.creatorAddress(address(this));
        require(msg.sender != creator, "Creator forbidden");
        uint totalToWithdraw;
        if (_openBidPosition == 0) {
            for (uint i = 1; i <= positionCount; i++) {
                if (userOpenBidPosition[msg.sender][i] > 0) {
                    totalToWithdraw = totalToWithdraw.add(userOpenBidPosition[msg.sender][i]);
                    totalOpenBidAmountPerPosition[i] = totalOpenBidAmountPerPosition[i].sub(
                        userOpenBidPosition[msg.sender][i]
                    );
                    userOpenBidPosition[msg.sender][i] = 0;
                }
            }
        } else {
            require(userOpenBidPosition[msg.sender][_openBidPosition] > 0, "No amount for position");
            totalOpenBidAmountPerPosition[_openBidPosition] = totalOpenBidAmountPerPosition[_openBidPosition].sub(
                userOpenBidPosition[msg.sender][_openBidPosition]
            );
            totalToWithdraw = userOpenBidPosition[msg.sender][_openBidPosition];
            userOpenBidPosition[msg.sender][_openBidPosition] = 0;
        }
        if (block.timestamp.add(1 days) > endOfPositioning && block.timestamp <= endOfPositioning) {
            require(!withrawalRestrictedForUser[msg.sender], "Already withdrawn");
            require(
                totalToWithdraw <= totalOpenBidAmount.mul(maxWithdrawPercentage.mul(ONE_PERCENT)).div(HUNDRED_PERCENT),
                "Exceeds withdraw limit"
            );
            withrawalRestrictedForUser[msg.sender] = true;
        }
        if (getUserOpenBidTotalPlacedAmount(msg.sender) == 0) {
            totalUsersTakenPositions = totalUsersTakenPositions.sub(1);
        }
        totalOpenBidAmount = totalOpenBidAmount.sub(totalToWithdraw);
        totalUserPlacedAmount[msg.sender] = totalUserPlacedAmount[msg.sender].sub(totalToWithdraw);
        uint withdrawalFee = totalToWithdraw.mul(marketManager.withdrawalPercentage()).mul(ONE_PERCENT).div(HUNDRED_PERCENT);
        thalesBonds.transferFromMarket(marketManager.safeBoxAddress(), withdrawalFee.div(2));
        thalesBonds.transferFromMarket(creator, withdrawalFee.div(2));
        thalesBonds.transferFromMarket(msg.sender, totalToWithdraw.sub(withdrawalFee));
        emit OpenBidUserWithdrawn(msg.sender, _openBidPosition, totalToWithdraw.sub(withdrawalFee), totalOpenBidAmount);
    }

    function resolveMarket(uint _outcomePosition, address _resolverAddress) external onlyOwner {
        require(canMarketBeResolvedByOwner(), "Disputed/not matured");
        require(_outcomePosition <= positionCount, "Outcome exeeds positionNum");
        winningPosition = _outcomePosition;
        if (_outcomePosition == CANCELED) {
            claimableOpenBidAmount = totalOpenBidAmount;
            totalOpenBidAmountPerPosition[_outcomePosition] = totalOpenBidAmount;
        } else {
            claimableOpenBidAmount = getTotalClaimableAmount();
            if (totalOpenBidAmountPerPosition[_outcomePosition] == 0) {
                noWinners = true;
            } else {
                noWinners = false;
            }
        }
        resolved = true;
        resolvedTime = block.timestamp;
        resolverAddress = _resolverAddress;
        emit MarketResolved(_outcomePosition, _resolverAddress, noWinners);
    }

    function resetMarket() external onlyOwner {
        require(resolved, "Market is not resolved");
        if (winningPosition == CANCELED) {
            totalOpenBidAmountPerPosition[winningPosition] = 0;
        }
        winningPosition = 0;
        claimableOpenBidAmount = 0;
        resolved = false;
        noWinners = false;
        resolvedTime = 0;
        resolverAddress = marketManager.safeBoxAddress();
        emit MarketReset();
    }

    function cancelMarket() external onlyOwner {
        winningPosition = CANCELED;
        claimableOpenBidAmount = totalOpenBidAmount;
        totalOpenBidAmountPerPosition[winningPosition] = totalOpenBidAmount;
        resolved = true;
        resolvedTime = block.timestamp;
        resolverAddress = marketManager.safeBoxAddress();
        emit MarketResolved(CANCELED, msg.sender, noWinners);
    }

    function claimWinningTicket() external notPaused nonReentrant {
        require(canUsersClaim(), "Market not finalized");
        uint amount = getUserClaimableAmount(msg.sender);
        require(amount > 0, "Claimable amount is zero.");
        claimableOpenBidAmount = claimableOpenBidAmount.sub(amount);
        resetForUserAllPositionsToZero(msg.sender);
        thalesBonds.transferFromMarket(msg.sender, amount);
        if (!feesAndBondsClaimed) {
            _issueFees();
        }
        userAlreadyClaimed[msg.sender] = userAlreadyClaimed[msg.sender].add(amount);
        emit WinningOpenBidAmountClaimed(msg.sender, amount);
    }

    function claimWinningTicketOnBehalf(address _user) external onlyOwner {
        require(canUsersClaim() || marketManager.cancelledByCreator(address(this)), "Market not finalized");
        uint amount = getUserClaimableAmount(_user);
        require(amount > 0, "Claimable amount is zero.");
        claimableOpenBidAmount = claimableOpenBidAmount.sub(amount);
        resetForUserAllPositionsToZero(_user);
        thalesBonds.transferFromMarket(_user, amount);
        if (!feesAndBondsClaimed) {
            _issueFees();
        }
        userAlreadyClaimed[msg.sender] = userAlreadyClaimed[msg.sender].add(amount);
        emit WinningOpenBidAmountClaimed(_user, amount);
    }

    function issueFees() external notPaused nonReentrant {
        _issueFees();
    }

    function _issueFees() internal {
        require(canUsersClaim() || marketManager.cancelledByCreator(address(this)), "Not finalized");
        require(!feesAndBondsClaimed, "Fees claimed");
        if (winningPosition != CANCELED) {
            thalesBonds.transferFromMarket(marketManager.creatorAddress(address(this)), getAdditionalCreatorAmount());
            thalesBonds.transferFromMarket(resolverAddress, getAdditionalResolverAmount());
            thalesBonds.transferFromMarket(marketManager.safeBoxAddress(), getSafeBoxAmount());
        }
        marketManager.issueBondsBackToCreatorAndResolver(address(this));
        feesAndBondsClaimed = true;
        emit FeesIssued(getTotalFeesAmount());
    }

    function openDispute() external onlyOwner {
        require(isMarketCreated(), "Market not created");
        require(!disputed, "Market already disputed");
        disputed = true;
        disputedInPositioningPhase = canUsersPlacePosition();
        lastDisputeTime = block.timestamp;
        emit MarketDisputed(true);
    }

    function closeDispute() external onlyOwner {
        require(disputed, "Market not disputed");
        disputeClosedTime = block.timestamp;
        if (disputedInPositioningPhase) {
            disputed = false;
            disputedInPositioningPhase = false;
        } else {
            disputed = false;
        }
        emit MarketDisputed(false);
    }

    function transferToMarket(
        address _sender,
        uint _amount,
        address collateral,
        uint expectedPayout,
        uint additionalSlippage
    ) internal notPaused {
        require(_sender != address(0), "Invalid sender address");
        IThalesBonds(marketManager.thalesBonds()).transferToMarket(
            _sender,
            _amount,
            collateral,
            expectedPayout,
            additionalSlippage
        );
    }

    // SETTERS ///////////////////////////////////////////////////////

    function setBackstopTimeout(uint _timeoutPeriod) external onlyOwner {
        backstopTimeout = _timeoutPeriod;
        emit BackstopTimeoutPeriodChanged(_timeoutPeriod);
    }

    // VIEWS /////////////////////////////////////////////////////////

    function isMarketCreated() public view returns (bool) {
        return creationTime > 0;
    }

    function isMarketCancelled() public view returns (bool) {
        return resolved && winningPosition == CANCELED;
    }

    function canUsersPlacePosition() public view returns (bool) {
        return block.timestamp <= endOfPositioning && creationTime > 0 && !resolved;
    }

    function canMarketBeResolved() public view returns (bool) {
        return block.timestamp >= endOfPositioning && creationTime > 0 && (!disputed) && !resolved;
    }

    function canMarketBeResolvedByOwner() public view returns (bool) {
        return block.timestamp >= endOfPositioning && creationTime > 0 && (!disputed);
    }

    function canMarketBeResolvedByPDAO() public view returns (bool) {
        return
            canMarketBeResolvedByOwner() && block.timestamp >= endOfPositioning.add(marketManager.pDAOResolveTimePeriod());
    }

    function canCreatorCancelMarket() external view returns (bool result) {
        if (!disputed && totalUsersTakenPositions == 1) {
            result = true;
        }
    }

    function canUsersClaim() public view returns (bool) {
        return
            resolved &&
            (!disputed) &&
            ((resolvedTime > 0 && block.timestamp > resolvedTime.add(marketManager.claimTimeoutDefaultPeriod())) ||
                (backstopTimeout > 0 &&
                    resolvedTime > 0 &&
                    disputeClosedTime > 0 &&
                    block.timestamp > disputeClosedTime.add(backstopTimeout)));
    }

    function canUserClaim(address _user) external view returns (bool) {
        return canUsersClaim() && getUserClaimableAmount(_user) > 0;
    }

    function canUserWithdraw(address _account) public view returns (bool) {
        if (_account == marketManager.creatorAddress(address(this))) {
            return false;
        }
        return
            withdrawalAllowed &&
            canUsersPlacePosition() &&
            getUserOpenBidTotalPlacedAmount(_account) > 0 &&
            !withrawalRestrictedForUser[_account] &&
            block.timestamp <= withdrawalPeriod;
    }

    function canIssueFees() external view returns (bool) {
        return
            !feesAndBondsClaimed &&
            (thalesBonds.getCreatorBondForMarket(address(this)) > 0 ||
                thalesBonds.getResolverBondForMarket(address(this)) > 0);
    }

    function getPositionPhrase(uint index) public view returns (string memory) {
        return (index <= positionCount && index > 0) ? positionPhrase[index] : string("");
    }

    function getTotalPlacedAmount() public view returns (uint) {
        return totalOpenBidAmount;
    }

    function getTotalClaimableAmount() public view returns (uint) {
        if (totalUsersTakenPositions == 0) {
            return 0;
        } else {
            return winningPosition == CANCELED ? getTotalPlacedAmount() : applyDeduction(getTotalPlacedAmount());
        }
    }

    function getTotalFeesAmount() public view returns (uint) {
        return getTotalPlacedAmount().sub(getTotalClaimableAmount());
    }

    function getPlacedAmountPerPosition(uint _position) public view returns (uint) {
        return totalOpenBidAmountPerPosition[_position];
    }

    function getUserClaimableAmount(address _account) public view returns (uint) {
        return getUserOpenBidTotalClaimableAmount(_account);
    }

    /// FLEXIBLE BID FUNCTIONS

    function getUserOpenBidTotalPlacedAmount(address _account) public view returns (uint amount) {
        for (uint i = 1; i <= positionCount; i++) {
            amount = amount.add(userOpenBidPosition[_account][i]);
        }
        return amount;
    }

    function getUserOpenBidPositionPlacedAmount(address _account, uint _position) external view returns (uint) {
        return userOpenBidPosition[_account][_position];
    }

    function getAllUserPositions(address _account) external view returns (uint[] memory) {
        uint[] memory userAllPositions = new uint[](positionCount);
        if (positionCount == 0) {
            return userAllPositions;
        }
        for (uint i = 1; i <= positionCount; i++) {
            userAllPositions[i - 1] = userOpenBidPosition[_account][i];
        }
        return userAllPositions;
    }

    function getPotentialOpenBidWinningForAllPositions() external view returns (uint[] memory) {
        uint[] memory potentialWinning = new uint[](positionCount);
        if (totalUsersTakenPositions == 0 || totalOpenBidAmount == 0) {
            return potentialWinning;
        }
        for (uint i = 1; i <= positionCount; i++) {
            if (totalOpenBidAmountPerPosition[i] > 0) {
                potentialWinning[i - 1] = applyDeduction(totalOpenBidAmount).mul(HUNDRED_PERCENT).div(
                    totalOpenBidAmountPerPosition[i]
                );
            }
        }
        return potentialWinning;
    }

    function getUserOpenBidPotentialWinningForPosition(address _account, uint _position) public view returns (uint) {
        if (_position == CANCELED) {
            return getUserOpenBidTotalPlacedAmount(_account);
        }
        return
            totalOpenBidAmountPerPosition[_position] > 0
                ? userOpenBidPosition[_account][_position].mul(getTotalClaimableAmount()).div(
                    totalOpenBidAmountPerPosition[_position]
                )
                : 0;
    }

    function getUserOpenBidTotalClaimableAmount(address _account) public view returns (uint) {
        if (noWinners) {
            return applyDeduction(getUserOpenBidTotalPlacedAmount(_account));
        }
        return getUserOpenBidPotentialWinningForPosition(_account, winningPosition);
    }

    function getUserPotentialWinningAmountForAllPosition(address _account) external view returns (uint[] memory) {
        uint[] memory potentialWinning = new uint[](positionCount);
        for (uint i = 1; i <= positionCount; i++) {
            potentialWinning[i - 1] = getUserOpenBidPotentialWinningForPosition(_account, i);
        }
        return potentialWinning;
    }

    function applyDeduction(uint value) internal view returns (uint) {
        return
            (value)
                .mul(
                    HUNDRED.sub(
                        marketManager.safeBoxPercentage().add(marketManager.creatorPercentage()).add(
                            marketManager.resolverPercentage()
                        )
                    )
                )
                .mul(ONE_PERCENT)
                .div(HUNDRED_PERCENT);
    }

    function getTagsCount() external view returns (uint) {
        return tags.length;
    }

    function getTags() external view returns (uint[] memory) {
        return tags;
    }

    function getTicketType() external view returns (uint) {
        return uint(ticketType);
    }

    function getAllAmounts()
        external
        view
        returns (
            uint,
            uint,
            uint,
            uint
        )
    {
        return (fixedBondAmount, disputePrice, safeBoxLowAmount, arbitraryRewardForDisputor);
    }

    function getAllFees()
        external
        view
        returns (
            uint,
            uint,
            uint,
            uint
        )
    {
        return (getAdditionalCreatorAmount(), getAdditionalResolverAmount(), getSafeBoxAmount(), getTotalFeesAmount());
    }

    function resetForUserAllPositionsToZero(address _account) internal {
        if (positionCount > 0) {
            for (uint i = 1; i <= positionCount; i++) {
                userOpenBidPosition[_account][i] = 0;
            }
        }
    }

    function getAdditionalCreatorAmount() internal view returns (uint) {
        return getTotalPlacedAmount().mul(marketManager.creatorPercentage()).mul(ONE_PERCENT).div(HUNDRED_PERCENT);
    }

    function getAdditionalResolverAmount() internal view returns (uint) {
        return getTotalPlacedAmount().mul(marketManager.resolverPercentage()).mul(ONE_PERCENT).div(HUNDRED_PERCENT);
    }

    function getSafeBoxAmount() internal view returns (uint) {
        return getTotalPlacedAmount().mul(marketManager.safeBoxPercentage()).mul(ONE_PERCENT).div(HUNDRED_PERCENT);
    }

    function _initializeWithTwoParameters(
        string memory _marketQuestion,
        string memory _marketSource,
        uint _endOfPositioning,
        uint _fixedTicketPrice,
        bool _withdrawalAllowed,
        uint[] memory _tags,
        string memory _positionPhrase1,
        string memory _positionPhrase2
    ) internal {
        creationTime = block.timestamp;
        marketQuestion = _marketQuestion;
        marketSource = _marketSource;
        endOfPositioning = _endOfPositioning;
        ticketType = _fixedTicketPrice > 0 ? TicketType.FIXED_TICKET_PRICE : TicketType.FLEXIBLE_BID;
        withdrawalAllowed = _withdrawalAllowed;
        tags = _tags;
        _addPosition(_positionPhrase1);
        _addPosition(_positionPhrase2);
    }

    function _addPosition(string memory _position) internal {
        require(keccak256(abi.encode(_position)) != keccak256(abi.encode("")), "Invalid position label (empty string)");
        positionCount = positionCount.add(1);
        positionPhrase[positionCount] = _position;
    }

    event MarketDisputed(bool disputed);
    event MarketCreated(uint creationTime, uint positionCount, bytes32 phrase);
    event MarketResolved(uint winningPosition, address resolverAddress, bool noWinner);
    event MarketReset();
    event WinningOpenBidAmountClaimed(address account, uint amount);
    event BackstopTimeoutPeriodChanged(uint timeoutPeriod);
    event TicketWithdrawn(address account, uint amount);
    event BondIncreased(uint amount, uint totalAmount);
    event BondDecreased(uint amount, uint totalAmount);
    event NewOpenBidsForPositions(address account, uint[] openBidPositions, uint[] openBidAmounts);
    event OpenBidUserWithdrawn(address account, uint position, uint withdrawnAmount, uint totalOpenBidAmount);
    event FeesIssued(uint totalFees);
}

File 12 of 27 : IThalesBonds.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

interface IThalesBonds {
    /* ========== VIEWS / VARIABLES ========== */
    function getTotalDepositedBondAmountForMarket(address _market) external view returns (uint);

    function getClaimedBondAmountForMarket(address _market) external view returns (uint);

    function getClaimableBondAmountForMarket(address _market) external view returns (uint);

    function getDisputorBondForMarket(address _market, address _disputorAddress) external view returns (uint);

    function getCreatorBondForMarket(address _market) external view returns (uint);

    function getResolverBondForMarket(address _market) external view returns (uint);

    function getCurveQuoteForDifferentCollateral(
        uint amount,
        address collateral,
        bool toSUSD
    ) external view returns (uint);

    function sendCreatorBondToMarket(
        address _market,
        address _creatorAddress,
        uint _amount
    ) external;

    function sendResolverBondToMarket(
        address _market,
        address _resolverAddress,
        uint _amount
    ) external;

    function sendDisputorBondToMarket(
        address _market,
        address _disputorAddress,
        uint _amount
    ) external;

    function sendBondFromMarketToUser(
        address _market,
        address _account,
        uint _amount,
        uint _bondToReduce,
        address _disputorAddress
    ) external;

    function sendOpenDisputeBondFromMarketToDisputor(
        address _market,
        address _account,
        uint _amount
    ) external;

    function setOracleCouncilAddress(address _oracleCouncilAddress) external;

    function setManagerAddress(address _managerAddress) external;

    function setCurveSUSD(
        address _curveSUSD,
        address _dai,
        address _usdc,
        address _usdt,
        bool _curveOnrampEnabled
    ) external;

    function issueBondsBackToCreatorAndResolver(address _market) external;

    function transferToMarket(address _account, uint _amount) external;

    function transferToMarket(
        address _account,
        uint _amount,
        address collateral,
        uint expectedPayout,
        uint additionalSlippage
    ) external;

    function transferFromMarket(address _account, uint _amount) external;

    function transferCreatorToResolverBonds(address _market) external;

    function decreaseCreatorVolume(address _market) external;
}

File 13 of 27 : IExoticPositionalTags.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

interface IExoticPositionalTags {
    /* ========== VIEWS / VARIABLES ========== */
    function isValidTagNumber(uint _number) external view returns (bool);

    function isValidTagLabel(string memory _label) external view returns (bool);

    function isValidTag(string memory _label, uint _number) external view returns (bool);

    function getTagLabel(uint _number) external view returns (string memory);

    function getTagNumber(string memory _label) external view returns (uint);

    function getTagNumberIndex(uint _number) external view returns (uint);

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

    function getTagByIndex(uint _index) external view returns (string memory, uint);

    function getTagsCount() external view returns (uint);

    function addTag(string memory _label, uint _number) external;

    function editTagNumber(string memory _label, uint _number) external;

    function editTagLabel(string memory _label, uint _number) external;

    function removeTag(uint _number) external;
}

File 14 of 27 : IThalesOracleCouncil.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

interface IThalesOracleCouncil {
    /* ========== VIEWS / VARIABLES ========== */
    function isOracleCouncilMember(address _councilMember) external view returns (bool);

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

    function closeMarketForDisputes(address _market) external;
}

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

pragma solidity ^0.8.0;

interface IExoticPositionalMarket {
    /* ========== VIEWS / VARIABLES ========== */
    function isMarketCreated() external view returns (bool);

    function creatorAddress() external view returns (address);

    function resolverAddress() external view returns (address);

    function totalBondAmount() external view returns (uint);

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

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

    function positionPhrase(uint index) external view returns (string memory);

    function getTicketType() external view returns (uint);

    function positionCount() external view returns (uint);

    function endOfPositioning() external view returns (uint);

    function resolvedTime() external view returns (uint);

    function fixedTicketPrice() external view returns (uint);

    function creationTime() external view returns (uint);

    function winningPosition() external view returns (uint);

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

    function getTotalPlacedAmount() external view returns (uint);

    function getTotalClaimableAmount() external view returns (uint);

    function getPlacedAmountPerPosition(uint index) external view returns (uint);

    function fixedBondAmount() external view returns (uint);

    function disputePrice() external view returns (uint);

    function safeBoxLowAmount() external view returns (uint);

    function arbitraryRewardForDisputor() external view returns (uint);

    function backstopTimeout() external view returns (uint);

    function disputeClosedTime() external view returns (uint);

    function totalUsersTakenPositions() external view returns (uint);

    function withdrawalAllowed() external view returns (bool);

    function disputed() external view returns (bool);

    function resolved() external view returns (bool);

    function canUsersPlacePosition() external view returns (bool);

    function canMarketBeResolvedByPDAO() external view returns (bool);

    function canMarketBeResolved() external view returns (bool);

    function canUsersClaim() external view returns (bool);

    function isMarketCancelled() external view returns (bool);

    function paused() external view returns (bool);

    function canCreatorCancelMarket() external view returns (bool);

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

    function canIssueFees() external view returns (bool);

    function noWinners() external view returns (bool);

    function transferBondToMarket(address _sender, uint _amount) external;

    function resolveMarket(uint _outcomePosition, address _resolverAddress) external;

    function cancelMarket() external;

    function resetMarket() external;

    function claimWinningTicketOnBehalf(address _user) external;

    function openDispute() external;

    function closeDispute() external;

    function setBackstopTimeout(uint _timeoutPeriod) external;
}

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

pragma solidity ^0.8.0;

interface IExoticRewards {
    /* ========== VIEWS / VARIABLES ========== */
    function sendRewardToDisputoraddress(
        address _market,
        address _disputorAddress,
        uint _amount
    ) external;
}

File 17 of 27 : ProxyReentrancyGuard.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the `nonReentrant` modifier
 * available, which can be aplied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 */
contract ProxyReentrancyGuard {
    /// @dev counter to allow mutex lock with only one SSTORE operation
    uint256 private _guardCounter;
    bool private _initialized;

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

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and make it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        _guardCounter += 1;
        uint256 localCounter = _guardCounter;
        _;
        require(localCounter == _guardCounter, "ReentrancyGuard: reentrant call");
    }
}

File 18 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 19 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 20 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);
            }
        }
    }
}

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

pragma solidity ^0.8.0;
import "../proxy/utils/Initializable.sol";

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

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

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

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

File 23 of 27 : OraclePausable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

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

// Clone of syntetix contract without constructor

contract OraclePausable 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 pauserOnly {
        // Ensure we're actually changing the state before we do anything
        if (_paused == paused) {
            return;
        }
        if (paused) {
            require(msg.sender == IExoticPositionalMarketManager(owner).owner(), "Only Protocol DAO can unpause");
        }
        // 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(!IExoticPositionalMarketManager(owner).paused(), "Manager paused.");
        require(!paused, "Contract is paused");
        _;
    }

    modifier pauserOnly {
        require(
            IExoticPositionalMarketManager(owner).isPauserAddress(msg.sender) ||
                IExoticPositionalMarketManager(owner).owner() == msg.sender ||
                owner == msg.sender,
            "Non-pauser address"
        );
        _;
    }
}

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

pragma solidity ^0.8.0;

import "../IERC20.sol";
import "../../../utils/Address.sol";

/**
 * @title SafeERC20
 * @dev Wrappers around ERC20 operations that throw on failure (when the token
 * contract returns false). Tokens that return no value (and instead revert or
 * throw on failure) are also supported, non-reverting calls are assumed to be
 * successful.
 * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeERC20 {
    using Address for address;

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

interface IExoticPositionalMarketManager {
    /* ========== VIEWS / VARIABLES ========== */
    function paused() external view returns (bool);

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

    function getActiveMarketIndex(address _marketAddress) external view returns (uint);

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

    function numberOfActiveMarkets() external view returns (uint);

    function getMarketBondAmount(address _market) external view returns (uint);

    function maximumPositionsAllowed() external view returns (uint);

    function paymentToken() external view returns (address);

    function owner() external view returns (address);

    function thalesBonds() external view returns (address);

    function oracleCouncilAddress() external view returns (address);

    function safeBoxAddress() external view returns (address);

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

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

    function isPauserAddress(address _pauserAddress) external view returns (bool);

    function safeBoxPercentage() external view returns (uint);

    function creatorPercentage() external view returns (uint);

    function resolverPercentage() external view returns (uint);

    function withdrawalPercentage() external view returns (uint);

    function pDAOResolveTimePeriod() external view returns (uint);

    function claimTimeoutDefaultPeriod() external view returns (uint);

    function maxOracleCouncilMembers() external view returns (uint);

    function fixedBondAmount() external view returns (uint);

    function disputePrice() external view returns (uint);

    function safeBoxLowAmount() external view returns (uint);

    function arbitraryRewardForDisputor() external view returns (uint);

    function disputeStringLengthLimit() external view returns (uint);

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

    function withdrawalTimePeriod() external view returns (uint);

    function maxAmountForOpenBidPosition() external view returns (uint);

    function maxFinalWithdrawPercentage() external view returns (uint);

    function minFixedTicketPrice() external view returns (uint);

    function createExoticMarket(
        string memory _marketQuestion,
        string memory _marketSource,
        uint _endOfPositioning,
        uint _fixedTicketPrice,
        bool _withdrawalAllowed,
        uint[] memory _tags,
        uint _positionCount,
        string[] memory _positionPhrases
    ) external;

    function createCLMarket(
        string memory _marketQuestion,
        string memory _marketSource,
        uint _endOfPositioning,
        uint _fixedTicketPrice,
        bool _withdrawalAllowed,
        uint[] memory _tags,
        uint _positionCount,
        uint[] memory _positionsOfCreator,
        string[] memory _positionPhrases
    ) external;

    function disputeMarket(address _marketAddress, address disputor) external;

    function resolveMarket(address _marketAddress, uint _outcomePosition) external;

    function resetMarket(address _marketAddress) external;

    function cancelMarket(address _market) external;

    function closeDispute(address _market) external;

    function setBackstopTimeout(address _market) external;

    function sendMarketBondAmountTo(
        address _market,
        address _recepient,
        uint _amount
    ) external;

    function addPauserAddress(address _pauserAddress) external;

    function removePauserAddress(address _pauserAddress) external;

    function sendRewardToDisputor(
        address _market,
        address _disputorAddress,
        uint amount
    ) external;

    function issueBondsBackToCreatorAndResolver(address _marketAddress) external;
}

File 26 of 27 : IERC20.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 IERC20 {
    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

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

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

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

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

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

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

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

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

        uint256 size;
        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 Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionDelegateCall(target, data, "Address: low-level delegate call failed");
    }

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

        (bool success, bytes memory returndata) = target.delegatecall(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":"_exoticMarketMastercopy","type":"address"},{"indexed":false,"internalType":"address","name":"_exoticMarketOpenBidMastercopy","type":"address"},{"indexed":false,"internalType":"address","name":"_oracleCouncilAddress","type":"address"},{"indexed":false,"internalType":"address","name":"_paymentToken","type":"address"},{"indexed":false,"internalType":"address","name":"_tagsAddress","type":"address"},{"indexed":false,"internalType":"address","name":"_theRundownConsumerAddress","type":"address"},{"indexed":false,"internalType":"address","name":"_marketDataAddress","type":"address"},{"indexed":false,"internalType":"address","name":"_exoticRewards","type":"address"},{"indexed":false,"internalType":"address","name":"_safeBoxAddress","type":"address"}],"name":"AddressesUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"minFixedTicketPrice","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"maxFixedTicketPrice","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"disputePrice","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"fixedBondAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"safeBoxLowAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"arbitraryRewardForDisputor","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"maxAmountForOpenBidPosition","type":"uint256"}],"name":"AmountsUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"marketAddress","type":"address"},{"indexed":false,"internalType":"string","name":"marketQuestion","type":"string"},{"indexed":false,"internalType":"string","name":"marketSource","type":"string"},{"indexed":false,"internalType":"uint256","name":"endOfPositioning","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"fixedTicketPrice","type":"uint256"},{"indexed":false,"internalType":"bool","name":"withdrawalAllowed","type":"bool"},{"indexed":false,"internalType":"uint256[]","name":"tags","type":"uint256[]"},{"indexed":false,"internalType":"uint256","name":"positionCount","type":"uint256"},{"indexed":false,"internalType":"string[]","name":"positionPhrases","type":"string[]"},{"indexed":false,"internalType":"address","name":"marketOwner","type":"address"}],"name":"CLMarketCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"backstopTimeout","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"minimumPositioningDuration","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"withdrawalTimePeriod","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"pDAOResolveTimePeriod","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"claimTimeoutDefaultPeriod","type":"uint256"}],"name":"DurationsUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"_creationRestrictedToOwner","type":"bool"},{"indexed":false,"internalType":"bool","name":"_openBidAllowed","type":"bool"}],"name":"FlagsUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"marketQuestionStringLimit","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"marketSourceStringLimit","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"marketPositionStringLimit","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"disputeStringLengthLimit","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"maximumPositionsAllowed","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"maxNumberOfTags","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"maxOracleCouncilMembers","type":"uint256"}],"name":"LimitsUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"marketAddress","type":"address"}],"name":"MarketCanceled","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"marketAddress","type":"address"},{"indexed":false,"internalType":"string","name":"marketQuestion","type":"string"},{"indexed":false,"internalType":"string","name":"marketSource","type":"string"},{"indexed":false,"internalType":"uint256","name":"endOfPositioning","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"fixedTicketPrice","type":"uint256"},{"indexed":false,"internalType":"bool","name":"withdrawalAllowed","type":"bool"},{"indexed":false,"internalType":"uint256[]","name":"tags","type":"uint256[]"},{"indexed":false,"internalType":"uint256","name":"positionCount","type":"uint256"},{"indexed":false,"internalType":"string[]","name":"positionPhrases","type":"string[]"},{"indexed":false,"internalType":"address","name":"marketOwner","type":"address"}],"name":"MarketCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"marketAddress","type":"address"},{"indexed":false,"internalType":"string","name":"marketQuestion","type":"string"},{"indexed":false,"internalType":"string","name":"marketSource","type":"string"},{"indexed":false,"internalType":"string","name":"additionalInfo","type":"string"},{"indexed":false,"internalType":"uint256","name":"endOfPositioning","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"fixedTicketPrice","type":"uint256"},{"indexed":false,"internalType":"bool","name":"withdrawalAllowed","type":"bool"},{"indexed":false,"internalType":"uint256[]","name":"tags","type":"uint256[]"},{"indexed":false,"internalType":"uint256","name":"positionCount","type":"uint256"},{"indexed":false,"internalType":"string[]","name":"positionPhrases","type":"string[]"},{"indexed":false,"internalType":"address","name":"marketOwner","type":"address"}],"name":"MarketCreatedWithDescription","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"marketAddress","type":"address"}],"name":"MarketReset","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"marketAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"outcomePosition","type":"uint256"}],"name":"MarketResolved","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"thalesBondsAddress","type":"address"}],"name":"NewThalesBonds","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":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"pauserAddress","type":"address"}],"name":"PauserAddressAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"pauserAddress","type":"address"}],"name":"PauserAddressRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"safeBoxPercentage","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"creatorPercentage","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"resolverPercentage","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"withdrawalPercentage","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"maxFinalWithdrawPercentage","type":"uint256"}],"name":"PercentagesUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"inputs":[],"name":"acceptOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_pauserAddress","type":"address"}],"name":"addPauserAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"arbitraryRewardForDisputor","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"backstopTimeout","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"backstopTimeoutGeneral","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_marketAddress","type":"address"}],"name":"cancelMarket","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"cancelledByCreator","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claimTimeoutDefaultPeriod","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_marketAddress","type":"address"}],"name":"closeDispute","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"_marketQuestion","type":"string"},{"internalType":"string","name":"_marketSource","type":"string"},{"internalType":"string","name":"_additionalInfo","type":"string"},{"internalType":"uint256","name":"_endOfPositioning","type":"uint256"},{"internalType":"uint256","name":"_fixedTicketPrice","type":"uint256"},{"internalType":"bool","name":"_withdrawalAllowed","type":"bool"},{"internalType":"uint256[]","name":"_tags","type":"uint256[]"},{"internalType":"uint256","name":"_positionCount","type":"uint256"},{"internalType":"uint256[]","name":"_positionsOfCreator","type":"uint256[]"},{"internalType":"string[]","name":"_positionPhrases","type":"string[]"}],"name":"createExoticMarket","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"creationRestrictedToOwner","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"creatorAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"creatorPercentage","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_marketAddress","type":"address"},{"internalType":"address","name":"_disputor","type":"address"}],"name":"disputeMarket","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"disputePrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"disputeStringLengthLimit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"exoticMarketMastercopy","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"exoticMarketOpenBidMastercopy","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"exoticRewards","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"fixedBondAmount","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":[],"name":"initNonReentrant","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_marketAddress","type":"address"}],"name":"isActiveMarket","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"isChainLinkMarket","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_pauser","type":"address"}],"name":"isPauserAddress","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_marketAddress","type":"address"}],"name":"issueBondsBackToCreatorAndResolver","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"marketDataAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"marketPositionStringLimit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"marketQuestionStringLimit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"marketSourceStringLimit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxAmountForOpenBidPosition","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxFinalWithdrawPercentage","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxFixedTicketPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxNumberOfTags","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxOracleCouncilMembers","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maximumPositionsAllowed","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minFixedTicketPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minimumPositioningDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"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":"numberOfActiveMarkets","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"openBidAllowed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"oracleCouncilAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pDAOResolveTimePeriod","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"pauserAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"pauserIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pausersCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"paymentToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_pauserAddress","type":"address"}],"name":"removePauserAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_marketAddress","type":"address"}],"name":"resetMarket","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_marketAddress","type":"address"},{"internalType":"uint256","name":"_outcomePosition","type":"uint256"}],"name":"resolveMarket","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"resolverAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"resolverPercentage","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"safeBoxAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"safeBoxLowAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"safeBoxPercentage","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_market","type":"address"},{"internalType":"address","name":"_disputorAddress","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"sendRewardToDisputor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_exoticMarketMastercopy","type":"address"},{"internalType":"address","name":"_exoticMarketOpenBidMastercopy","type":"address"},{"internalType":"address","name":"_oracleCouncilAddress","type":"address"},{"internalType":"address","name":"_paymentToken","type":"address"},{"internalType":"address","name":"_tagsAddress","type":"address"},{"internalType":"address","name":"_theRundownConsumerAddress","type":"address"},{"internalType":"address","name":"_marketDataAddress","type":"address"},{"internalType":"address","name":"_exoticRewards","type":"address"},{"internalType":"address","name":"_safeBoxAddress","type":"address"}],"name":"setAddresses","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_minFixedTicketPrice","type":"uint256"},{"internalType":"uint256","name":"_maxFixedTicketPrice","type":"uint256"},{"internalType":"uint256","name":"_disputePrice","type":"uint256"},{"internalType":"uint256","name":"_fixedBondAmount","type":"uint256"},{"internalType":"uint256","name":"_safeBoxLowAmount","type":"uint256"},{"internalType":"uint256","name":"_arbitraryRewardForDisputor","type":"uint256"},{"internalType":"uint256","name":"_maxAmountForOpenBidPosition","type":"uint256"}],"name":"setAmounts","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_market","type":"address"}],"name":"setBackstopTimeout","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_market","type":"address"},{"internalType":"uint256","name":"_timeout","type":"uint256"}],"name":"setCustomBackstopTimeout","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_backstopTimeout","type":"uint256"},{"internalType":"uint256","name":"_minimumPositioningDuration","type":"uint256"},{"internalType":"uint256","name":"_withdrawalTimePeriod","type":"uint256"},{"internalType":"uint256","name":"_pDAOResolveTimePeriod","type":"uint256"},{"internalType":"uint256","name":"_claimTimeoutDefaultPeriod","type":"uint256"}],"name":"setDurations","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_creationRestrictedToOwner","type":"bool"},{"internalType":"bool","name":"_openBidAllowed","type":"bool"}],"name":"setFlags","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_marketQuestionStringLimit","type":"uint256"},{"internalType":"uint256","name":"_marketSourceStringLimit","type":"uint256"},{"internalType":"uint256","name":"_marketPositionStringLimit","type":"uint256"},{"internalType":"uint256","name":"_disputeStringLengthLimit","type":"uint256"},{"internalType":"uint256","name":"_maximumPositionsAllowed","type":"uint256"},{"internalType":"uint256","name":"_maxNumberOfTags","type":"uint256"},{"internalType":"uint256","name":"_maxOracleCouncilMembers","type":"uint256"}],"name":"setLimits","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"setOwner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_safeBoxPercentage","type":"uint256"},{"internalType":"uint256","name":"_creatorPercentage","type":"uint256"},{"internalType":"uint256","name":"_resolverPercentage","type":"uint256"},{"internalType":"uint256","name":"_withdrawalPercentage","type":"uint256"},{"internalType":"uint256","name":"_maxFinalWithdrawPercentage","type":"uint256"}],"name":"setPercentages","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_thalesBonds","type":"address"}],"name":"setThalesBonds","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"tagsAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"thalesBonds","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"theRundownConsumerAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"proxyAddress","type":"address"}],"name":"transferOwnershipAtInit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdrawalPercentage","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"withdrawalTimePeriod","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]

608060405234801561001057600080fd5b506151ab806100206000396000f3fe608060405234801561001057600080fd5b50600436106104545760003560e01c806389265ca711610241578063d2fe297b1161013b578063e7aed7c8116100c3578063f4bfd3db11610087578063f4bfd3db1461093e578063f6dcfe8214610947578063f908979914610950578063fbdec41314610963578063fe40c4701461098657600080fd5b8063e7aed7c8146108e9578063ebc79772146108f2578063ee10b8fe146108fa578063f071bf4f14610923578063f19207471461092c57600080fd5b8063dd5adfa31161010a578063dd5adfa31461088a578063df999f621461089d578063dfb8bae7146108b0578063e118c08f146108c3578063e509ee41146108d657600080fd5b8063d2fe297b1461082a578063d9158ecc14610843578063d93caef31461084c578063dcaee5021461085f57600080fd5b8063a4e44fdd116101c9578063c1194e7e1161018d578063c1194e7e146107b5578063c3b83f5f146107c8578063c3f55880146107db578063c4d66de814610804578063caa48c9d1461081757600080fd5b8063a4e44fdd1461076a578063b0092db71461077d578063b33e3afb14610786578063b90a9f0e14610799578063b91f5e35146107a257600080fd5b80639b105ebc116102105780639b105ebc1461070f5780639b11088c146107225780639d937c8c1461072b578063a131bdfe1461074e578063a193687f1461075757600080fd5b806389265ca7146106d15780638da5cb5b146106da57806390cec6b3146106f3578063970dabcf1461070657600080fd5b8063543f1715116103525780636eb8053d116102da5780637d6a0d1a1161029e5780637d6a0d1a146106875780637dc7fe3a1461068f5780637efedd6b146106a257806383e06ead146106b557806388d93ba6146106c857600080fd5b80636eb8053d146106515780636ec38a4e1461065a5780636f191fd91461066d578063707ef77e1461067657806379ba50971461067f57600080fd5b806362d2c36c1161032157806362d2c36c146105f057806366272044146105f9578063677755bb1461060c5780636781e640146106355780636da19c351461064857600080fd5b8063543f1715146105a9578063592740b2146105bc5780635b20d468146105c55780635c975abb146105e557600080fd5b806321345ba8116103e05780633013ce29116103a45780633013ce2914610568578063465591f91461057b5780634b3a15b3146105845780634d736d581461058d57806353a47bb71461059657600080fd5b806321345ba81461051d578063277f487c14610530578063280952ba146105435780632b5cd01f146105565780632c3319571461055f57600080fd5b806313af40351161042757806313af4035146104be578063153ac525146104d15780631627540c146104ee578063177ac8f6146105015780631ac8bb141461051457600080fd5b806306dc48bb1461045957806307cf018c146104755780630b8c06aa146104a05780630f7682af146104b5575b600080fd5b61046260775481565b6040519081526020015b60405180910390f35b608254610488906001600160a01b031681565b6040516001600160a01b03909116815260200161046c565b6104b36104ae3660046149e1565b610999565b005b61046260785481565b6104b36104cc3660046149e1565b610c3a565b6081546104de9060ff1681565b604051901515815260200161046c565b6104b36104fc3660046149e1565b610d75565b6104b361050f3660046149e1565b610dcb565b61046260925481565b6104b361052b3660046149e1565b610e96565b6104b361053e3660046149e1565b61121d565b6104b36105513660046149e1565b6113be565b610462606e5481565b61046260725481565b608554610488906001600160a01b031681565b610462607a5481565b61046260915481565b61046260755481565b600154610488906001600160a01b031681565b608354610488906001600160a01b031681565b610462607c5481565b6104626105d33660046149e1565b608c6020526000908152604090205481565b60345460ff166104de565b610462606c5481565b6104b3610607366004614a2d565b611578565b61048861061a3660046149e1565b608d602052600090815260409020546001600160a01b031681565b6104b36106433660046149fb565b6117ce565b61046260745481565b61046260765481565b6104de6106683660046149e1565b611afa565b61046260735481565b610462607d5481565b6104b3611b0d565b606854610462565b608a54610488906001600160a01b031681565b6104b36106b0366004614b0f565b611c0a565b6104b36106c3366004614cdb565b611d8a565b61046260935481565b610462606a5481565b600054610488906201000090046001600160a01b031681565b608854610488906001600160a01b031681565b610462607b5481565b608954610488906001600160a01b031681565b61046260805481565b6104de6107393660046149e1565b608f6020526000908152604090205460ff1681565b610462606f5481565b6104b36107653660046149e1565b611e34565b6104b3610778366004614cdb565b611fb1565b61046260795481565b6104b3610794366004614ad4565b612050565b610462607e5481565b6104b36107b0366004614b0f565b612188565b6104b36107c3366004614b54565b612b46565b6104b36107d63660046149e1565b612bd4565b6104886107e93660046149e1565b608e602052600090815260409020546001600160a01b031681565b6104b36108123660046149e1565b612ccb565b6104b3610825366004614b8c565b612d95565b608154610488906201000090046001600160a01b031681565b610462606b5481565b608754610488906001600160a01b031681565b6104de61086d3660046149e1565b6001600160a01b03166000908152608c6020526040902054151590565b610488610898366004614cab565b613af6565b6104b36108ab3660046149e1565b613b37565b608454610488906001600160a01b031681565b6104b36108d1366004614d15565b613e02565b608654610488906001600160a01b031681565b610462607f5481565b6104b3613eda565b610488610908366004614cab565b608b602052600090815260409020546001600160a01b031681565b61046260705481565b6081546104de90610100900460ff1681565b61046260715481565b610462606d5481565b6104b361095e366004614d15565b613f38565b6104de6109713660046149e1565b60906020526000908152604090205460ff1681565b6104b36109943660046149e1565b614003565b6082546001600160a01b03163314806109c257506000546201000090046001600160a01b031633145b6109e75760405162461bcd60e51b81526004016109de90615074565b60405180910390fd5b6000546201000090046001600160a01b03163314610a27576082546001600160a01b0316610a275760405162461bcd60e51b81526004016109de90615074565b60345460ff1615610a4a5760405162461bcd60e51b81526004016109de90615023565b610a5381611afa565b610a6f5760405162461bcd60e51b81526004016109de90615000565b806001600160a01b0316635c975abb6040518163ffffffff1660e01b815260040160206040518083038186803b158015610aa857600080fd5b505afa158015610abc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ae09190614b38565b15610b31576000546201000090046001600160a01b03163314610b315760405162461bcd60e51b81526020600482015260096024820152684f6e6c79207044414f60b81b60448201526064016109de565b806001600160a01b0316630695c46c6040518163ffffffff1660e01b815260040160206040518083038186803b158015610b6a57600080fd5b505afa158015610b7e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ba29190614b38565b610be45760405162461bcd60e51b815260206004820152601360248201527213585c9ad95d081b9bdd08191a5cdc1d5d1959606a1b60448201526064016109de565b806001600160a01b031663ffe39fbd6040518163ffffffff1660e01b8152600401600060405180830381600087803b158015610c1f57600080fd5b505af1158015610c33573d6000803e3d6000fd5b5050505050565b6001600160a01b038116610c905760405162461bcd60e51b815260206004820152601960248201527f4f776e657220616464726573732063616e6e6f7420626520300000000000000060448201526064016109de565b600154600160a01b900460ff1615610cfc5760405162461bcd60e51b815260206004820152602960248201527f416c726561647920696e697469616c697a65642c20757365206e6f6d696e617460448201526832a732bba7bbb732b960b91b60648201526084016109de565b6001805460ff60a01b1916600160a01b179055600080546001600160a01b03831662010000810262010000600160b01b03199092169190911782556040805192835260208301919091527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c91015b60405180910390a150565b610d7d61453e565b600180546001600160a01b0319166001600160a01b0383169081179091556040519081527f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce2290602001610d6a565b6082546001600160a01b0316331480610df457506000546201000090046001600160a01b031633145b610e105760405162461bcd60e51b81526004016109de90615074565b6000546201000090046001600160a01b03163314610e50576082546001600160a01b0316610e505760405162461bcd60e51b81526004016109de90615074565b606b546040516370c787d360e11b815260048101919091526001600160a01b0382169063e18f0fa690602401600060405180830381600087803b158015610c1f57600080fd5b6082546001600160a01b0316331480610ebf57506000546201000090046001600160a01b031633145b610edb5760405162461bcd60e51b81526004016109de90615074565b6000546201000090046001600160a01b03163314610f1b576082546001600160a01b0316610f1b5760405162461bcd60e51b81526004016109de90615074565b610f2481611afa565b610f405760405162461bcd60e51b81526004016109de90615000565b806001600160a01b0316635c975abb6040518163ffffffff1660e01b815260040160206040518083038186803b158015610f7957600080fd5b505afa158015610f8d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fb19190614b38565b15611190576000546201000090046001600160a01b031633146110025760405162461bcd60e51b81526020600482015260096024820152686f6e6c79207044414f60b81b60448201526064016109de565b60845460405163f29e0d0f60e01b81526001600160a01b038381166004830152600092169063f29e0d0f9060240160206040518083038186803b15801561104857600080fd5b505afa15801561105c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110809190614cc3565b11156111905760845460835460405163f29e0d0f60e01b81526001600160a01b038481166004830152928316926327b153a0928592911690849063f29e0d0f9060240160206040518083038186803b1580156110db57600080fd5b505afa1580156110ef573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111139190614cc3565b60835460405160e086901b6001600160e01b03191681526001600160a01b039485166004820152928416602484015260448301919091526066606483015291909116608482015260a401600060405180830381600087803b15801561117757600080fd5b505af115801561118b573d6000803e3d6000fd5b505050505b806001600160a01b03166303bb87d76040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156111cb57600080fd5b505af11580156111df573d6000803e3d6000fd5b50506040516001600160a01b03841681527f867003fd269b5114be3e77bb782661cc1e357939f7f2f5a10f05b5061669528392506020019050610d6a565b61122561453e565b6001600160a01b03811661124b5760405162461bcd60e51b81526004016109de90614fd7565b6084546001600160a01b0316156112e65760855460845460405163095ea7b360e01b81526001600160a01b0391821660048201526000602482015291169063095ea7b390604401602060405180830381600087803b1580156112ac57600080fd5b505af11580156112c0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112e49190614b38565b505b608480546001600160a01b0319166001600160a01b0383811691821790925560855460405163095ea7b360e01b8152600481019290925260001960248301529091169063095ea7b390604401602060405180830381600087803b15801561134c57600080fd5b505af1158015611360573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113849190614b38565b506040516001600160a01b03821681527f4b92c6f002a7e2908100501ed3c87b99d190df7a71645f2a92565473e864a44690602001610d6a565b6082546001600160a01b03163314806113e757506000546201000090046001600160a01b031633145b6114035760405162461bcd60e51b81526004016109de90615074565b6000546201000090046001600160a01b03163314611443576082546001600160a01b03166114435760405162461bcd60e51b81526004016109de90615074565b6001600160a01b0381166114695760405162461bcd60e51b81526004016109de90614fd7565b6001600160a01b0381166000908152608c60205260409020546114bb5760405162461bcd60e51b815260206004820152600a6024820152694e6f742065786973747360b01b60448201526064016109de565b607680546000908152608b60208181526040808420546001600160a01b038781168652608c8085528387208054885286865284882080546001600160a01b031916948416949094179093559154875487529484528286205416855290915290912055546115299060016145b8565b6076556001600160a01b0381166000818152608c602090815260408083209290925590519182527f4fc4ad324d6c8ba2512b443ae34b352384dfd7fdb09cd8cffd7e3a22c2ffa89e9101610d6a565b61158061453e565b6085546001600160a01b038781169116146115b157608580546001600160a01b0319166001600160a01b0388161790555b6081546001600160a01b038a81166201000090920416146115ef576081805462010000600160b01b031916620100006001600160a01b038c16021790555b6089546001600160a01b0389811691161461162057608980546001600160a01b0319166001600160a01b038a161790555b6082546001600160a01b0388811691161461165157608280546001600160a01b0319166001600160a01b0389161790555b6086546001600160a01b0386811691161461168257608680546001600160a01b0319166001600160a01b0387161790555b6087546001600160a01b038581169116146116b357608780546001600160a01b0319166001600160a01b0386161790555b6088546001600160a01b038481169116146116e457608880546001600160a01b0319166001600160a01b0385161790555b608a546001600160a01b0383811691161461171557608a80546001600160a01b0319166001600160a01b0384161790555b6083546001600160a01b0382811691161461174657608380546001600160a01b0319166001600160a01b0383161790555b604080516001600160a01b0388811682528b811660208301528a8116828401528981166060830152878116608083015286811660a083015285811660c083015284811660e0830152831661010082015290517fdcb493c60570bc553de543bccde79755ef6ea8eb71e9cd8a77fcbc84d24766f0918190036101200190a1505050505050505050565b6082546001600160a01b031633146118105760405162461bcd60e51b81526020600482015260056024820152644e6f204f4360d81b60448201526064016109de565b6082546001600160a01b03166118505760405162461bcd60e51b81526020600482015260056024820152644e6f204f4360d81b60448201526064016109de565b60345460ff16156118735760405162461bcd60e51b81526004016109de90615023565b61187c82611afa565b6118985760405162461bcd60e51b81526004016109de90615000565b608460009054906101000a90046001600160a01b03166001600160a01b0316637190e8158383856001600160a01b0316636da19c356040518163ffffffff1660e01b815260040160206040518083038186803b1580156118f757600080fd5b505afa15801561190b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061192f9190614cc3565b6040518463ffffffff1660e01b815260040161194d93929190614e39565b600060405180830381600087803b15801561196757600080fd5b505af115801561197b573d6000803e3d6000fd5b50505050816001600160a01b0316635c975abb6040518163ffffffff1660e01b815260040160206040518083038186803b1580156119b857600080fd5b505afa1580156119cc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119f09190614b38565b15611a2d5760405162461bcd60e51b815260206004820152600d60248201526c13585c9ad95d081c185d5cd959609a1b60448201526064016109de565b816001600160a01b0316630695c46c6040518163ffffffff1660e01b815260040160206040518083038186803b158015611a6657600080fd5b505afa158015611a7a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a9e9190614b38565b611af657816001600160a01b0316634fd6137c6040518163ffffffff1660e01b8152600401600060405180830381600087803b158015611add57600080fd5b505af1158015611af1573d6000803e3d6000fd5b505050505b5050565b6000611b076068836145cb565b92915050565b6001546001600160a01b03163314611b855760405162461bcd60e51b815260206004820152603560248201527f596f75206d757374206265206e6f6d696e61746564206265666f726520796f7560448201527402063616e20616363657074206f776e65727368697605c1b60648201526084016109de565b60005460015460408051620100009093046001600160a01b03908116845290911660208301527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c910160405180910390a1600180546000805462010000600160b01b0319166001600160a01b03831662010000021790556001600160a01b0319169055565b6082546001600160a01b0316331480611c3357506000546201000090046001600160a01b031633145b611c4f5760405162461bcd60e51b81526004016109de90615074565b6000546201000090046001600160a01b03163314611c8f576082546001600160a01b0316611c8f5760405162461bcd60e51b81526004016109de90615074565b60008111611cd15760405162461bcd60e51b815260206004820152600f60248201526e125b9d985b1a59081d1a5b595bdd5d608a1b60448201526064016109de565b80826001600160a01b031663d9158ecc6040518163ffffffff1660e01b815260040160206040518083038186803b158015611d0b57600080fd5b505afa158015611d1f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d439190614cc3565b14611af6576040516370c787d360e11b8152600481018290526001600160a01b0383169063e18f0fa690602401600060405180830381600087803b158015611add57600080fd5b611d9261453e565b606f548514611da157606f8590555b6070548414611db05760708490555b6071548314611dbf5760718390555b6072548214611dce5760728290555b6092548114611ddd5760928190555b604080518681526020810186905290810184905260608101839052608081018290527f02ba72f381b69be1253013b942ba335a3686a855d967e5bbd6bc50bc042ff0129060a0015b60405180910390a15050505050565b6082546001600160a01b0316331480611e5d57506000546201000090046001600160a01b031633145b611e795760405162461bcd60e51b81526004016109de90615074565b6000546201000090046001600160a01b03163314611eb9576082546001600160a01b0316611eb95760405162461bcd60e51b81526004016109de90615074565b6001600160a01b038116611edf5760405162461bcd60e51b81526004016109de90614fd7565b6001600160a01b0381166000908152608c602052604090205415611f385760405162461bcd60e51b815260206004820152601060248201526f22bc34b9ba399030b9903830bab9b2b960811b60448201526064016109de565b607654611f4690600161464d565b60768190556001600160a01b0382166000818152608c60209081526040808320859055938252608b81529083902080546001600160a01b0319168317905591519081527f4d0f17e690950c9c0cf10521410e1a7fce39829c9beab9bddcd29a6b5ae648e69101610d6a565b611fb961453e565b606b548514611fc857606b8590555b606c548414611fd757606c8490555b6080548314611fe65760808390555b606e548214611ff557606e8290555b606d54811461200457606d8190555b604080518681526020810186905290810184905260608101839052608081018290527fac71ff8ac58edf88133615d78d6cfe160e500b50071c5c1af26c8a103bc429ba9060a001611e25565b6082546001600160a01b031633148061207957506000546201000090046001600160a01b031633145b6120955760405162461bcd60e51b81526004016109de90615074565b6000546201000090046001600160a01b031633146120d5576082546001600160a01b03166120d55760405162461bcd60e51b81526004016109de90615074565b60345460ff16156120f85760405162461bcd60e51b81526004016109de90615023565b61210183611afa565b61211d5760405162461bcd60e51b81526004016109de90615000565b608a54604051636edaaff960e11b81526001600160a01b039091169063ddb55ff29061215190869086908690600401614e39565b600060405180830381600087803b15801561216b57600080fd5b505af115801561217f573d6000803e3d6000fd5b50505050505050565b60345460ff16156121ab5760405162461bcd60e51b81526004016109de90615023565b6121b482611afa565b6121d05760405162461bcd60e51b81526004016109de90615000565b6001600160a01b0382166000908152608f602052604090205460ff161561224b576087546001600160a01b0316331461224b5760405162461bcd60e51b815260206004820152601760248201527f4f6e6c792074686552756e646f776e436f6e73756d657200000000000000000060448201526064016109de565b608254604051635466519560e11b81523360048201526001600160a01b039091169063a8cca32a9060240160206040518083038186803b15801561228e57600080fd5b505afa1580156122a2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122c69190614b38565b1561230c5760405162461bcd60e51b81526020600482015260166024820152754f43206d656d2063616e206e6f74207265736f6c766560501b60448201526064016109de565b6000546201000090046001600160a01b0316331480159061233857506082546001600160a01b03163314155b156123e557816001600160a01b031663dde27c3a6040518163ffffffff1660e01b815260040160206040518083038186803b15801561237657600080fd5b505afa15801561238a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123ae9190614b38565b6123e55760405162461bcd60e51b815260206004820152600860248201526714995cdbdb1d995960c21b60448201526064016109de565b816001600160a01b0316635c975abb6040518163ffffffff1660e01b815260040160206040518083038186803b15801561241e57600080fd5b505afa158015612432573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124569190614b38565b156124b4576000546201000090046001600160a01b031633146124b45760405162461bcd60e51b815260206004820152601660248201527513db9b1e481c111053c81dda1a5b19481c185d5cd95960521b60448201526064016109de565b6001600160a01b038281166000908152608d602052604090205416331480156125585750608454604051632c21134b60e11b81526001600160a01b038481166004830152600092169063584226969060240160206040518083038186803b15801561251e57600080fd5b505afa158015612532573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125569190614cc3565b115b8061257357506000546201000090046001600160a01b031633145b8061258857506082546001600160a01b031633145b15612700576082546001600160a01b03166125d25760405162461bcd60e51b815260206004820152600a602482015269496e76616c6964204f4360b01b60448201526064016109de565b6001600160a01b038281166000908152608d60205260409020541661262b5760405162461bcd60e51b815260206004820152600f60248201526e24b73b30b634b21031b932b0ba37b960891b60448201526064016109de565b6000546201000090046001600160a01b03166126795760405162461bcd60e51b815260206004820152600d60248201526c24b73b30b634b21037bbb732b960991b60448201526064016109de565b6001600160a01b038281166000908152608d6020526040902054163314156126fb57608454604051633b27f0f360e21b81526001600160a01b0384811660048301529091169063ec9fc3cc90602401600060405180830381600087803b1580156126e257600080fd5b505af11580156126f6573d6000803e3d6000fd5b505050505b612a36565b816001600160a01b03166389265ca76040518163ffffffff1660e01b815260040160206040518083038186803b15801561273957600080fd5b505afa15801561274d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127719190614cc3565b6085546040516370a0823160e01b81523360048201526001600160a01b03909116906370a082319060240160206040518083038186803b1580156127b457600080fd5b505afa1580156127c8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127ec9190614cc3565b101561283a5760405162461bcd60e51b815260206004820152601760248201527f4c6f7720616d6f756e7420666f72206372656174696f6e00000000000000000060448201526064016109de565b816001600160a01b03166389265ca76040518163ffffffff1660e01b815260040160206040518083038186803b15801561287357600080fd5b505afa158015612887573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128ab9190614cc3565b608554608454604051636eb1769f60e11b81523360048201526001600160a01b03918216602482015291169063dd62ed3e9060440160206040518083038186803b1580156128f857600080fd5b505afa15801561290c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129309190614cc3565b101561294e5760405162461bcd60e51b81526004016109de9061504d565b608460009054906101000a90046001600160a01b03166001600160a01b0316635a090b688333856001600160a01b03166389265ca76040518163ffffffff1660e01b815260040160206040518083038186803b1580156129ad57600080fd5b505afa1580156129c1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129e59190614cc3565b6040518463ffffffff1660e01b8152600401612a0393929190614e39565b600060405180830381600087803b158015612a1d57600080fd5b505af1158015612a31573d6000803e3d6000fd5b505050505b6082546001600160a01b0316331480612a5f57506000546201000090046001600160a01b031633145b612a695733612a76565b6083546001600160a01b03165b6001600160a01b038381166000818152608e60205260409081902080546001600160a01b03191694909316938417909255905163642bc7db60e01b81526004810184905260248101929092529063642bc7db90604401600060405180830381600087803b158015612ae657600080fd5b505af1158015612afa573d6000803e3d6000fd5b5050604080516001600160a01b0386168152602081018590527f316a0bcd9820c43f9ba8738fd680d536a8ac65080f56f96833f696f6dd5a12fd93500190505b60405180910390a15050565b612b4e61453e565b60815460ff16151582151514612b6d576081805460ff19168315151790555b608160019054906101000a900460ff16151581151514612b9b576081805461ff001916610100831515021790555b60408051831515815282151560208201527fe60ddd5e5132a1aa8ca1d2829cd0cd733f0047df727e3b056b470163f6082e6b9101612b3a565b612bdc61453e565b6001600160a01b038116612c025760405162461bcd60e51b81526004016109de90614fd7565b600154600160a81b900460ff1615612c525760405162461bcd60e51b8152602060048201526013602482015272105b1c9958591e481d1c985b9cd9995c9c9959606a1b60448201526064016109de565b600080546001600160a01b038381166201000081810262010000600160b01b031990941693909317938490556001805460ff60a81b1916600160a81b1790556040805193909404909116825260208201527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c9101610d6a565b600054610100900460ff16612ce65760005460ff1615612cea565b303b155b612d4d5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016109de565b600054610100900460ff16158015612d6f576000805461ffff19166101011790555b612d7882610c3a565b612d80613eda565b8015611af6576000805461ff00191690555050565b600160666000828254612da891906150ee565b909155505060665460345460ff1615612dd35760405162461bcd60e51b81526004016109de90615023565b606c54612de190429061464d565b881015612e305760405162461bcd60e51b815260206004820152601960248201527f656e644f66506f736974696f6e696e6720746f6f206c6f772e0000000000000060448201526064016109de565b60815460ff161580612e5257506000546201000090046001600160a01b031633145b612e945760405162461bcd60e51b81526020600482015260136024820152722932b9ba3934b1ba32b21031b932b0ba34b7b760691b60448201526064016109de565b608154610100900460ff168015612ea9575086155b80612ec35750607b548710158015612ec357506093548711155b612efd5760405162461bcd60e51b815260206004820152600b60248201526a08af0c640dad2dc5edac2f60ab1b60448201526064016109de565b60008551118015612f115750607754855111155b612f1a57600080fd5b604051602001612f3590602080825260009082015260400190565b604051602081830303815290604052805190602001208b604051602001612f5c9190614f45565b604051602081830303815290604052805190602001201415612fb45760405162461bcd60e51b815260206004820152601160248201527024b73b30b634b21038bab2b9ba34b7b71760791b60448201526064016109de565b604051602001612fcf90602080825260009082015260400190565b604051602081830303815290604052805190602001208a604051602001612ff69190614f45565b60405160208183030381529060405280519060200120141561304b5760405162461bcd60e51b815260206004820152600e60248201526d496e76616c696420736f7572636560901b60448201526064016109de565b8151841461308f5760405162461bcd60e51b815260206004820152601160248201527024b73b30b634b2103837b9a1b7bab73a1760791b60448201526064016109de565b607d548b51106130e15760405162461bcd60e51b815260206004820152601860248201527f6d5175657374696f6e2065786365656473206c656e677468000000000000000060448201526064016109de565b607e548a511061312c5760405162461bcd60e51b81526020600482015260166024820152750daa6deeae4c6ca40caf0c6cacac8e640d8cadccee8d60531b60448201526064016109de565b61313582614659565b6131815760405162461bcd60e51b815260206004820152601860248201527f457175616c20706f736974696f6e616c2070687261736573000000000000000060448201526064016109de565b60005b85518110156132875760865486516001600160a01b039091169063598e8055908890849081106131c457634e487b7160e01b600052603260045260246000fd5b60200260200101516040518263ffffffff1660e01b81526004016131ea91815260200190565b60206040518083038186803b15801561320257600080fd5b505afa158015613216573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061323a9190614b38565b6132755760405162461bcd60e51b815260206004820152600c60248201526b24b73b30b634b2103a30b39760a11b60448201526064016109de565b8061327f8161511d565b915050613184565b50861561361a57606a5461329b908861464d565b6085546040516370a0823160e01b81523360048201526001600160a01b03909116906370a082319060240160206040518083038186803b1580156132de57600080fd5b505afa1580156132f2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133169190614cc3565b10156133645760405162461bcd60e51b815260206004820152601860248201527f4c6f7720616d6f756e7420666f72206372656174696f6e2e000000000000000060448201526064016109de565b606a54613371908861464d565b608554608454604051636eb1769f60e11b81523360048201526001600160a01b03918216602482015291169063dd62ed3e9060440160206040518083038186803b1580156133be57600080fd5b505afa1580156133d2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133f69190614cc3565b10156134145760405162461bcd60e51b81526004016109de9061504d565b608154600090613432906201000090046001600160a01b0316614776565b6040516368d3815760e11b81529091506001600160a01b0382169063d1a702ae90613471908f908f908f908f908f908f908f908f908e90600401614f58565b600060405180830381600087803b15801561348b57600080fd5b505af115801561349f573d6000803e3d6000fd5b5050506001600160a01b038083166000908152608d60205260409081902080546001600160a01b03191633908117909155608454606a54925163105743d160e01b81529316935063105743d1926134fb92869291600401614e39565b600060405180830381600087803b15801561351557600080fd5b505af1158015613529573d6000803e3d6000fd5b5050505061354181606861481390919063ffffffff16565b806001600160a01b0316638a15a2778560008151811061357157634e487b7160e01b600052603260045260246000fd5b60200260200101516040518263ffffffff1660e01b815260040161359791815260200190565b600060405180830381600087803b1580156135b157600080fd5b505af11580156135c5573d6000803e3d6000fd5b505050507f4e78638599344e4e22521a0adf6a3ac91ecfe9a1bb8821948ac0bd22f5cfdb05818d8d8d8d8d8d8d8d8c3360405161360c9b9a99989796959493929190614e5d565b60405180910390a150613a98565b8383511461366a5760405162461bcd60e51b815260206004820152601860248201527f43726561746f7220696e697420706f7320696e76616c6964000000000000000060448201526064016109de565b6000808567ffffffffffffffff81111561369457634e487b7160e01b600052604160045260246000fd5b6040519080825280602002602001820160405280156136bd578160200160208202803683370190505b50905060005b8681101561374f576137058682815181106136ee57634e487b7160e01b600052603260045260246000fd5b60200260200101518461464d90919063ffffffff16565b92506137128160016150ee565b82828151811061373257634e487b7160e01b600052603260045260246000fd5b6020908102919091010152806137478161511d565b9150506136c3565b50606a5461375d908361464d565b6085546040516370a0823160e01b81523360048201526001600160a01b03909116906370a082319060240160206040518083038186803b1580156137a057600080fd5b505afa1580156137b4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906137d89190614cc3565b10156138135760405162461bcd60e51b815260206004820152600a602482015269131bddc8185b5bdd5b9d60b21b60448201526064016109de565b606a54613820908361464d565b608554608454604051636eb1769f60e11b81523360048201526001600160a01b03918216602482015291169063dd62ed3e9060440160206040518083038186803b15801561386d57600080fd5b505afa158015613881573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906138a59190614cc3565b10156138c35760405162461bcd60e51b81526004016109de9061504d565b6089546000906138db906001600160a01b0316614776565b9050806001600160a01b031663d1a702ae8f8f8f8f8f8f8f8f8e6040518a63ffffffff1660e01b815260040161391999989796959493929190614f58565b600060405180830381600087803b15801561393357600080fd5b505af1158015613947573d6000803e3d6000fd5b5050506001600160a01b038083166000908152608d60205260409081902080546001600160a01b03191633908117909155608454606a54925163105743d160e01b81529316935063105743d1926139a392869291600401614e39565b600060405180830381600087803b1580156139bd57600080fd5b505af11580156139d1573d6000803e3d6000fd5b505050506139e981606861481390919063ffffffff16565b6040516303caae9f60e31b81526001600160a01b03821690631e5574f890613a179085908a90600401614f17565b600060405180830381600087803b158015613a3157600080fd5b505af1158015613a45573d6000803e3d6000fd5b505050507f4e78638599344e4e22521a0adf6a3ac91ecfe9a1bb8821948ac0bd22f5cfdb05818f8f8f8f8f8f8f8f8e33604051613a8c9b9a99989796959493929190614e5d565b60405180910390a15050505b6066548114613ae95760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016109de565b5050505050505050505050565b600060686000018281548110613b1c57634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b031692915050565b600160666000828254613b4a91906150ee565b9091555050606654613b5b82611afa565b613b775760405162461bcd60e51b81526004016109de90615000565b816001600160a01b0316631897c8fe6040518163ffffffff1660e01b815260040160206040518083038186803b158015613bb057600080fd5b505afa158015613bc4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613be89190614b38565b80613c0b57506001600160a01b03821660009081526090602052604090205460ff165b613c475760405162461bcd60e51b815260206004820152600d60248201526c4e6f7420636c61696d61626c6560981b60448201526064016109de565b608454604051632c21134b60e11b81526001600160a01b038481166004830152600092169063584226969060240160206040518083038186803b158015613c8d57600080fd5b505afa158015613ca1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613cc59190614cc3565b1180613d4c575060845460405163f29e0d0f60e01b81526001600160a01b038481166004830152600092169063f29e0d0f9060240160206040518083038186803b158015613d1257600080fd5b505afa158015613d26573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613d4a9190614cc3565b115b15613db157608454604051636fcccfb160e11b81526001600160a01b0384811660048301529091169063df999f6290602401600060405180830381600087803b158015613d9857600080fd5b505af1158015613dac573d6000803e3d6000fd5b505050505b6066548114611af65760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016109de565b613e0a61453e565b607b548714613e1957607b8790555b6093548614613e285760938690555b6074548514613e375760748590555b606a548414613e4657606a8490555b6079548314613e555760798390555b607a548214613e6457607a8290555b6091548114613e735760918190555b6040805188815260208101889052908101869052606081018590526080810184905260a0810183905260c081018290527f9438c6ba8ae39b44a9b431206dba321533fcfa5156721e40e7efb6ca6aed3c669060e0015b60405180910390a150505050505050565b60675460ff1615613f235760405162461bcd60e51b8152602060048201526013602482015272105b1c9958591e481a5b9a5d1a585b1a5e9959606a1b60448201526064016109de565b6067805460ff19166001908117909155606655565b613f4061453e565b607d548714613f4f57607d8790555b607e548614613f5e57607e8690555b607f548514613f6d57607f8590555b607c548414613f7c57607c8490555b6073548314613f8b5760738390555b6077548214613f9a5760778290555b6075548114613fa95760758190555b6040805188815260208101889052908101869052606081018590526080810184905260a0810183905260c081018290527f369dcfd0446023b777c6e9e0fdea94c4f596668956aa7f486257b1210f939f8c9060e001613ec9565b60345460ff16156140265760405162461bcd60e51b81526004016109de90615023565b61402f81611afa565b61404b5760405162461bcd60e51b81526004016109de90615000565b6082546001600160a01b031633148061407457506000546201000090046001600160a01b031633145b8061409857506001600160a01b038181166000908152608d60205260409020541633145b6140b45760405162461bcd60e51b81526004016109de90614fd7565b6000546201000090046001600160a01b031633146140f4576082546001600160a01b03166140f45760405162461bcd60e51b81526004016109de90614fd7565b6001600160a01b038181166000908152608d60205260409020541633141561434057806001600160a01b031663e3b221306040518163ffffffff1660e01b815260040160206040518083038186803b15801561414f57600080fd5b505afa158015614163573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906141879190614b38565b6141e25760405162461bcd60e51b815260206004820152602660248201527f4d61726b65742063616e206e6f742062652063616e63656c6c656420627920636044820152653932b0ba37b960d11b60648201526084016109de565b6001600160a01b0381811660008181526090602052604090819020805460ff19166001179055608254905163631808d960e11b815260048101929092529091169063c63011b29060240160206040518083038186803b15801561424457600080fd5b505afa158015614258573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061427c9190614b38565b6142e05760825460405163cf65e30f60e01b81526001600160a01b0383811660048301529091169063cf65e30f90602401600060405180830381600087803b1580156142c757600080fd5b505af11580156142db573d6000803e3d6000fd5b505050505b608454604051631f62166160e11b81526001600160a01b03838116600483015290911690633ec42cc290602401600060405180830381600087803b15801561432757600080fd5b505af115801561433b573d6000803e3d6000fd5b505050505b806001600160a01b0316635c975abb6040518163ffffffff1660e01b815260040160206040518083038186803b15801561437957600080fd5b505afa15801561438d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906143b19190614b38565b15614402576000546201000090046001600160a01b031633146144025760405162461bcd60e51b81526020600482015260096024820152686f6e6c79207044414f60b81b60448201526064016109de565b806001600160a01b0316636bfefd6b6040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561443d57600080fd5b505af1158015614451573d6000803e3d6000fd5b5050608354336000908152608e6020908152604080832080546001600160a01b0319166001600160a01b03958616179055928616825260909052205460ff161591506145059050576001600160a01b038181166000818152608d6020526040908190205490516338e6802d60e11b815292166004830152906371cd005a90602401600060405180830381600087803b1580156144ec57600080fd5b505af1158015614500573d6000803e3d6000fd5b505050505b6040516001600160a01b03821681527f3ff1326b5409d2380d9d1b66c4858652932d1b62586f4fb11e168ff9e7db94bd90602001610d6a565b6000546201000090046001600160a01b031633146145b65760405162461bcd60e51b815260206004820152602f60248201527f4f6e6c792074686520636f6e7472616374206f776e6572206d6179207065726660448201526e37b936903a3434b99030b1ba34b7b760891b60648201526084016109de565b565b60006145c48284615106565b9392505050565b81546000906145dc57506000611b07565b6001600160a01b0382166000908152600184016020526040902054801515806146455750826001600160a01b03168460000160008154811061462e57634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b0316145b949350505050565b60006145c482846150ee565b6000805b6001835161466b9190615106565b81101561476d578261467e8260016150ee565b8151811061469c57634e487b7160e01b600052603260045260246000fd5b60200260200101516040516020016146b49190614f45565b604051602081830303815290604052805190602001208382815181106146ea57634e487b7160e01b600052603260045260246000fd5b60200260200101516040516020016147029190614f45565b60405160208183030381529060405280519060200120148061474d5750607f5483828151811061474257634e487b7160e01b600052603260045260246000fd5b602002602001015151115b1561475b5750600092915050565b806147658161511d565b91505061465d565b50600192915050565b6000604051733d602d80600a3d3981f3363d3d373d3d3d363d7360601b81528260601b60148201526e5af43d82803e903d91602b57fd5bf360881b60288201526037816000f09150506001600160a01b03811661480e5760405162461bcd60e51b8152602060048201526016602482015275115490cc4c4d8dce8818dc99585d194819985a5b195960521b60448201526064016109de565b919050565b61481d82826145cb565b611af65781546001600160a01b038216600081815260018086016020908152604083208590559084018655858252902090910180546001600160a01b03191690911790555050565b80356001600160a01b038116811461480e57600080fd5b600082601f83011261488c578081fd5b813560206148a161489c836150ca565b615099565b80838252828201915082860187848660051b89010111156148c0578586fd5b855b8581101561490157813567ffffffffffffffff8111156148e0578788fd5b6148ee8a87838c0101614976565b85525092840192908401906001016148c2565b5090979650505050505050565b600082601f83011261491e578081fd5b8135602061492e61489c836150ca565b80838252828201915082860187848660051b890101111561494d578586fd5b855b858110156149015781358452928401929084019060010161494f565b803561480e81615164565b600082601f830112614986578081fd5b813567ffffffffffffffff8111156149a0576149a061514e565b6149b3601f8201601f1916602001615099565b8181528460208386010111156149c7578283fd5b816020850160208301379081016020019190915292915050565b6000602082840312156149f2578081fd5b6145c482614865565b60008060408385031215614a0d578081fd5b614a1683614865565b9150614a2460208401614865565b90509250929050565b60008060008060008060008060006101208a8c031215614a4b578485fd5b614a548a614865565b9850614a6260208b01614865565b9750614a7060408b01614865565b9650614a7e60608b01614865565b9550614a8c60808b01614865565b9450614a9a60a08b01614865565b9350614aa860c08b01614865565b9250614ab660e08b01614865565b9150614ac56101008b01614865565b90509295985092959850929598565b600080600060608486031215614ae8578283fd5b614af184614865565b9250614aff60208501614865565b9150604084013590509250925092565b60008060408385031215614b21578182fd5b614b2a83614865565b946020939093013593505050565b600060208284031215614b49578081fd5b81516145c481615164565b60008060408385031215614b66578182fd5b8235614b7181615164565b91506020830135614b8181615164565b809150509250929050565b6000806000806000806000806000806101408b8d031215614bab578081fd5b8a3567ffffffffffffffff80821115614bc2578283fd5b614bce8e838f01614976565b9b5060208d0135915080821115614be3578283fd5b614bef8e838f01614976565b9a5060408d0135915080821115614c04578283fd5b614c108e838f01614976565b995060608d0135985060808d01359750614c2c60a08e0161496b565b965060c08d0135915080821115614c41578283fd5b614c4d8e838f0161490e565b955060e08d013594506101008d0135915080821115614c6a578283fd5b614c768e838f0161490e565b93506101208d0135915080821115614c8c578283fd5b50614c998d828e0161487c565b9150509295989b9194979a5092959850565b600060208284031215614cbc578081fd5b5035919050565b600060208284031215614cd4578081fd5b5051919050565b600080600080600060a08688031215614cf2578283fd5b505083359560208501359550604085013594606081013594506080013592509050565b600080600080600080600060e0888a031215614d2f578081fd5b505085359760208701359750604087013596606081013596506080810135955060a0810135945060c0013592509050565b600081518084526020808501808196508360051b81019150828601855b85811015614da7578284038952614d95848351614dee565b98850198935090840190600101614d7d565b5091979650505050505050565b6000815180845260208085019450808401835b83811015614de357815187529582019590820190600101614dc7565b509495945050505050565b60008151808452815b81811015614e1357602081850181015186830182015201614df7565b81811115614e245782602083870101525b50601f01601f19169290920160200192915050565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b038c16815261016060208201819052600090614e828382018e614dee565b90508281036040840152614e96818d614dee565b90508281036060840152614eaa818c614dee565b90508960808401528860a084015287151560c084015282810360e0840152614ed28188614db4565b905085610100840152828103610120840152614eee8186614d60565b915050614f076101408301846001600160a01b03169052565b9c9b505050505050505050505050565b604081526000614f2a6040830185614db4565b8281036020840152614f3c8185614db4565b95945050505050565b6020815260006145c46020830184614dee565b6000610120808352614f6c8184018d614dee565b90508281036020840152614f80818c614dee565b90508281036040840152614f94818b614dee565b905088606084015287608084015286151560a084015282810360c0840152614fbc8187614db4565b90508460e0840152828103610100840152614f078185614d60565b6020808252600f908201526e496e76616c6964206164647265737360881b604082015260600190565b6020808252600990820152684e6f7441637469766560b81b604082015260600190565b60208082526010908201526f14185d5cd8589b194e881c185d5cd95960821b604082015260600190565b6020808252600d908201526c27379030b63637bbb0b731b29760991b604082015260600190565b6020808252600b908201526a27379027a197b7bbb732b960a91b604082015260600190565b604051601f8201601f1916810167ffffffffffffffff811182821017156150c2576150c261514e565b604052919050565b600067ffffffffffffffff8211156150e4576150e461514e565b5060051b60200190565b6000821982111561510157615101615138565b500190565b60008282101561511857615118615138565b500390565b600060001982141561513157615131615138565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b801515811461517257600080fd5b5056fea26469706673582212203bcd05f1aaed31261cbbae883692ae00c422500a83ecd3ca2d6b98d56f45d4f164736f6c63430008040033

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