Contract 0xC2D6cCfCDAB5Be09F15320FD2d642f374f89bC20

Contract Overview

Balance:
0 Ether
Txn Hash Method
Block
From
To
Value
0xcafebc4078b9aac8eb116915c57d7bfab355b93e84e6c32db27160991fa9d71dCreate Market99942202021-04-07 11:58:378 days 3 hrs ago0x9f8e4ee788d9b00a3409584e18034aa7b736c396 IN  0xc2d6ccfcdab5be09f15320fd2d642f374f89bc200 Ether1.006752206179
0x9221df2074fcc7815d33a36df4fd080bd2e1e77e3c852bf9740b6fbcb01a4dc7Create Market99508262021-03-31 16:34:5714 days 22 hrs ago0x9f8e4ee788d9b00a3409584e18034aa7b736c396 IN  0xc2d6ccfcdab5be09f15320fd2d642f374f89bc200 Ether1.625675616288
0x236c7ff9ffc3ccf0e080589384d6ceb07da0f924dd730ccca667c26555e1b9c9Create Market99492672021-03-31 10:02:0315 days 5 hrs ago0xb8d08d9537fc8e5624c298302137c5b5ce2f301d IN  0xc2d6ccfcdab5be09f15320fd2d642f374f89bc200 Ether0.85962488151
0x8eba74e29a6835298906cfce425a54310f4b6bf6b3f7c8c9eae79c8e6f526ae8Create Market99237542021-03-27 19:32:0318 days 19 hrs ago0x9f8e4ee788d9b00a3409584e18034aa7b736c396 IN  0xc2d6ccfcdab5be09f15320fd2d642f374f89bc200 Ether0.686166308122
0xd77728071227d8655a426f72a29ba0aabf91f3e369921213ed6236e94b3d1847Create Market99045122021-03-25 12:39:3121 days 2 hrs ago0x461783a831e6db52d68ba2f3194f6fd1e0087e04 IN  0xc2d6ccfcdab5be09f15320fd2d642f374f89bc200 Ether0.68906959121
0xdbeb6a5877dd0775f361738058077e9d12db2311affb6255fff730d2ba7913ceCreate Market98220882021-03-12 10:07:3834 days 4 hrs ago0xaa0f527456241aa4e80dacbe6e7b7fbbf6edf297 IN  0xc2d6ccfcdab5be09f15320fd2d642f374f89bc200 Ether0.736786706131
0xdc2f8f80f739894e85282eef537eefa6787f711ff4451c8b1476128ffd517009Create Market98133352021-03-10 22:53:1235 days 16 hrs ago0xaa0f527456241aa4e80dacbe6e7b7fbbf6edf297 IN  0xc2d6ccfcdab5be09f15320fd2d642f374f89bc200 Ether0.601801598107
0xdb9c8b17d987e5ca9b14ac57441b6b69547cf8c3d0b655ad7c14c3abe07c6039Create Market98132492021-03-10 21:43:0835 days 17 hrs ago0x9f8e4ee788d9b00a3409584e18034aa7b736c396 IN  0xc2d6ccfcdab5be09f15320fd2d642f374f89bc200 Ether0.770529374137
0xb4f14f763cb7439027180e8b857c88ada16e69abdaf0dca87645fa4d37caa9f1Create Market98132442021-03-10 21:41:2135 days 17 hrs ago0x9f8e4ee788d9b00a3409584e18034aa7b736c396 IN  0xc2d6ccfcdab5be09f15320fd2d642f374f89bc200 Ether0.081595419137
0x63c6b7a88a0e9601477c6bf003ca5831349d6101795afac450f230e488c0fe31Create Market98132422021-03-10 21:39:3535 days 17 hrs ago0x9f8e4ee788d9b00a3409584e18034aa7b736c396 IN  0xc2d6ccfcdab5be09f15320fd2d642f374f89bc200 Ether0.008532497137
0xd64f5c94cd04f2c9574e3c08ea1bf17a6a0da62a829d525ecff91b5b9cd735a1Create Market98126192021-03-10 14:37:3936 days 26 mins ago0x9f8e4ee788d9b00a3409584e18034aa7b736c396 IN  0xc2d6ccfcdab5be09f15320fd2d642f374f89bc200 Ether0.597693084106
0xb72fd89faec1c29474f398bbe9d87db0a2368db308d05ba53081057930e277a8Create Market95782242021-02-01 9:32:4473 days 5 hrs ago0x53e34401091b531654b8aaed4ee03ad3e75a0629 IN  0xc2d6ccfcdab5be09f15320fd2d642f374f89bc200 Ether0.0005243451
0x1d90a3ec027a4ef8f7d74a7122af08c71102ddbb1123a00207d3d96ff6ea923dSet Resolver And...85943012020-08-31 16:43:37226 days 22 hrs ago0xb64ff7a4a33acdf48d97dab0d764afd0f6176882 IN  0xc2d6ccfcdab5be09f15320fd2d642f374f89bc200 Ether0.031037500
0xcc79c2d7c130a745b1801a81baebcbc11bbfc9fcf84d55e5a24c0c8ece7bc9d5Set Resolver And...83289112020-07-20 1:36:13269 days 13 hrs ago0xb64ff7a4a33acdf48d97dab0d764afd0f6176882 IN  0xc2d6ccfcdab5be09f15320fd2d642f374f89bc200 Ether0.0002693482
0x3e953f8b5a0620f091d0d09ff8e76b0248de6656577f6bf1dd46c5863d5c6f5c0x6011805483289042020-07-20 1:33:37269 days 13 hrs ago0xb64ff7a4a33acdf48d97dab0d764afd0f6176882 IN  Contract Creation0 Ether0.0071783582
[ Download CSV Export 
Latest 25 internal transaction
Parent Txn Hash Block From To Value
0x4cfe53ec623c1145c6224fa53cbd9e1408d1601668ed8b171b847c769497ead2100174052021-04-11 14:14:364 days 49 mins ago 0x3bb8a9d0fa15adb913660aa7a50181462d54faac 0xc2d6ccfcdab5be09f15320fd2d642f374f89bc200 Ether
0x0520fd8bfc6d54985f227e812dd598b92cdf3ef2d63957ca2c92255f5898e18899983682021-04-08 7:56:037 days 7 hrs ago 0xc2d6ccfcdab5be09f15320fd2d642f374f89bc20 0x0800ca66234e4691690485d9e45d8a8c9e6f9b520 Ether
0x0520fd8bfc6d54985f227e812dd598b92cdf3ef2d63957ca2c92255f5898e18899983682021-04-08 7:56:037 days 7 hrs ago 0xb20256a2cd571a4b42efdc11bd5e0d4babae17c0 0xc2d6ccfcdab5be09f15320fd2d642f374f89bc200 Ether
0x1838ca8e27ceb587c6b2f452ab4369fb5ca8efb7cf2b0287a2e11786bd44bab099983662021-04-08 7:52:027 days 7 hrs ago 0xc2d6ccfcdab5be09f15320fd2d642f374f89bc20 0x0800ca66234e4691690485d9e45d8a8c9e6f9b520 Ether
0x1838ca8e27ceb587c6b2f452ab4369fb5ca8efb7cf2b0287a2e11786bd44bab099983662021-04-08 7:52:027 days 7 hrs ago 0xb20256a2cd571a4b42efdc11bd5e0d4babae17c0 0xc2d6ccfcdab5be09f15320fd2d642f374f89bc200 Ether
0x07565f664f555580f0a1b21dd687a613b9eff85c39dc67902c4254c151a20eab99983642021-04-08 7:50:507 days 7 hrs ago 0xc2d6ccfcdab5be09f15320fd2d642f374f89bc20 0x0800ca66234e4691690485d9e45d8a8c9e6f9b520 Ether
0x07565f664f555580f0a1b21dd687a613b9eff85c39dc67902c4254c151a20eab99983642021-04-08 7:50:507 days 7 hrs ago 0xb20256a2cd571a4b42efdc11bd5e0d4babae17c0 0xc2d6ccfcdab5be09f15320fd2d642f374f89bc200 Ether
0x8dae172b8572bffbb7924452475f9140fec5144c02647a36854951df450403a799983532021-04-08 7:47:317 days 7 hrs ago 0xc2d6ccfcdab5be09f15320fd2d642f374f89bc20 0x0800ca66234e4691690485d9e45d8a8c9e6f9b520 Ether
0x8dae172b8572bffbb7924452475f9140fec5144c02647a36854951df450403a799983532021-04-08 7:47:317 days 7 hrs ago 0xb20256a2cd571a4b42efdc11bd5e0d4babae17c0 0xc2d6ccfcdab5be09f15320fd2d642f374f89bc200 Ether
0x492e4fc82f88e517eb970b40d3a2c6bf2341e19ebce9d9592a064c9a567b5fea99983452021-04-08 7:42:277 days 7 hrs ago 0xc2d6ccfcdab5be09f15320fd2d642f374f89bc20 0x0800ca66234e4691690485d9e45d8a8c9e6f9b520 Ether
0x492e4fc82f88e517eb970b40d3a2c6bf2341e19ebce9d9592a064c9a567b5fea99983452021-04-08 7:42:277 days 7 hrs ago 0xb20256a2cd571a4b42efdc11bd5e0d4babae17c0 0xc2d6ccfcdab5be09f15320fd2d642f374f89bc200 Ether
0x905dd7e83ac3e25165eeb7f1159cdeb510f6b53d707063e97d9a9c179120175299983352021-04-08 7:34:107 days 7 hrs ago 0xc2d6ccfcdab5be09f15320fd2d642f374f89bc20 0x0800ca66234e4691690485d9e45d8a8c9e6f9b520 Ether
0x905dd7e83ac3e25165eeb7f1159cdeb510f6b53d707063e97d9a9c179120175299983352021-04-08 7:34:107 days 7 hrs ago 0xb20256a2cd571a4b42efdc11bd5e0d4babae17c0 0xc2d6ccfcdab5be09f15320fd2d642f374f89bc200 Ether
0x126cbb80e23cd3e4a8c66c742dd02844f037c5eeca0fd79e0955ae4e43d0a75999983342021-04-08 7:32:147 days 7 hrs ago 0xc2d6ccfcdab5be09f15320fd2d642f374f89bc20 0x0800ca66234e4691690485d9e45d8a8c9e6f9b520 Ether
0x126cbb80e23cd3e4a8c66c742dd02844f037c5eeca0fd79e0955ae4e43d0a75999983342021-04-08 7:32:147 days 7 hrs ago 0xb20256a2cd571a4b42efdc11bd5e0d4babae17c0 0xc2d6ccfcdab5be09f15320fd2d642f374f89bc200 Ether
0x9ce04de7cdbe231783836feecf3244fefb99406d18a40b65810b699fe53d21ef99982512021-04-08 6:44:007 days 8 hrs ago 0xc2d6ccfcdab5be09f15320fd2d642f374f89bc20 0x0800ca66234e4691690485d9e45d8a8c9e6f9b520 Ether
0x9ce04de7cdbe231783836feecf3244fefb99406d18a40b65810b699fe53d21ef99982512021-04-08 6:44:007 days 8 hrs ago 0xb20256a2cd571a4b42efdc11bd5e0d4babae17c0 0xc2d6ccfcdab5be09f15320fd2d642f374f89bc200 Ether
0xc2b5c0ae68c261076f8d209f82175a0c0e639b9a6e4823cba42109d9ad49855599942792021-04-07 12:11:018 days 2 hrs ago 0x3bb8a9d0fa15adb913660aa7a50181462d54faac 0xc2d6ccfcdab5be09f15320fd2d642f374f89bc200 Ether
0x3d6030b75b3192a120d490ed24781f7556a18fa581ed840d417707b87855e0f099942532021-04-07 12:06:028 days 2 hrs ago 0xc2d6ccfcdab5be09f15320fd2d642f374f89bc20 0x0800ca66234e4691690485d9e45d8a8c9e6f9b520 Ether
0x3d6030b75b3192a120d490ed24781f7556a18fa581ed840d417707b87855e0f099942532021-04-07 12:06:028 days 2 hrs ago 0x202e2ff9797f29b15349a56946f62496b054fbfa 0xc2d6ccfcdab5be09f15320fd2d642f374f89bc200 Ether
0x3d6030b75b3192a120d490ed24781f7556a18fa581ed840d417707b87855e0f099942532021-04-07 12:06:028 days 2 hrs ago 0x202e2ff9797f29b15349a56946f62496b054fbfa 0xc2d6ccfcdab5be09f15320fd2d642f374f89bc200 Ether
0x3d6030b75b3192a120d490ed24781f7556a18fa581ed840d417707b87855e0f099942532021-04-07 12:06:028 days 2 hrs ago 0xc2d6ccfcdab5be09f15320fd2d642f374f89bc20 0x0800ca66234e4691690485d9e45d8a8c9e6f9b520 Ether
0x3d6030b75b3192a120d490ed24781f7556a18fa581ed840d417707b87855e0f099942532021-04-07 12:06:028 days 2 hrs ago 0x202e2ff9797f29b15349a56946f62496b054fbfa 0xc2d6ccfcdab5be09f15320fd2d642f374f89bc200 Ether
0x3d6030b75b3192a120d490ed24781f7556a18fa581ed840d417707b87855e0f099942532021-04-07 12:06:028 days 2 hrs ago 0x202e2ff9797f29b15349a56946f62496b054fbfa 0xc2d6ccfcdab5be09f15320fd2d642f374f89bc200 Ether
0x3d6030b75b3192a120d490ed24781f7556a18fa581ed840d417707b87855e0f099942532021-04-07 12:06:028 days 2 hrs ago 0x202e2ff9797f29b15349a56946f62496b054fbfa 0xc2d6ccfcdab5be09f15320fd2d642f374f89bc200 Ether
[ Download CSV Export 
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
BinaryOptionMarketManager

Compiler Version
v0.5.16+commit.9c3226ce

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity)

/**
 *Submitted for verification at Etherscan.io on 2020-07-20
*/

/*
   ____            __   __        __   _
  / __/__ __ ___  / /_ / /  ___  / /_ (_)__ __
 _\ \ / // // _ \/ __// _ \/ -_)/ __// / \ \ /
/___/ \_, //_//_/\__//_//_/\__/ \__//_/ /_\_\
     /___/

* Synthetix: BinaryOptionMarketManager.sol
*
* Latest source (may be newer): https://github.com/Synthetixio/synthetix/blob/master/contracts/BinaryOptionMarketManager.sol
* Docs: https://docs.synthetix.io/contracts/BinaryOptionMarketManager
*
* Contract Dependencies: 
*	- IAddressResolver
*	- IBinaryOption
*	- IBinaryOptionMarket
*	- IBinaryOptionMarketManager
*	- IERC20
*	- MixinResolver
*	- Owned
*	- Pausable
*	- SelfDestructible
* Libraries: 
*	- AddressListLib
*	- SafeDecimalMath
*	- SafeMath
*
* MIT License
* ===========
*
* Copyright (c) 2020 Synthetix
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
*/

/* ===============================================
* Flattened with Solidifier by Coinage
* 
* https://solidifier.coina.ge
* ===============================================
*/


pragma solidity ^0.5.16;


// https://docs.synthetix.io/contracts/Owned
contract Owned {
    address public owner;
    address public nominatedOwner;

    constructor(address _owner) public {
        require(_owner != address(0), "Owner address cannot be 0");
        owner = _owner;
        emit OwnerChanged(address(0), _owner);
    }

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

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

    modifier onlyOwner {
        require(msg.sender == owner, "Only the contract owner may perform this action");
        _;
    }

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


// Inheritance


// https://docs.synthetix.io/contracts/Pausable
contract Pausable is Owned {
    uint public lastPauseTime;
    bool public paused;

    constructor() internal {
        // This contract is abstract, and thus cannot be instantiated directly
        require(owner != address(0), "Owner must be set");
        // Paused will be false, and lastPauseTime will be 0 upon initialisation
    }

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

        // Set our paused state.
        paused = _paused;

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

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

    event PauseChanged(bool isPaused);

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


// Inheritance


// https://docs.synthetix.io/contracts/SelfDestructible
contract SelfDestructible is Owned {
    uint public constant SELFDESTRUCT_DELAY = 4 weeks;

    uint public initiationTime;
    bool public selfDestructInitiated;

    address public selfDestructBeneficiary;

    constructor() internal {
        // This contract is abstract, and thus cannot be instantiated directly
        require(owner != address(0), "Owner must be set");
        selfDestructBeneficiary = owner;
        emit SelfDestructBeneficiaryUpdated(owner);
    }

    /**
     * @notice Set the beneficiary address of this contract.
     * @dev Only the contract owner may call this. The provided beneficiary must be non-null.
     * @param _beneficiary The address to pay any eth contained in this contract to upon self-destruction.
     */
    function setSelfDestructBeneficiary(address payable _beneficiary) external onlyOwner {
        require(_beneficiary != address(0), "Beneficiary must not be zero");
        selfDestructBeneficiary = _beneficiary;
        emit SelfDestructBeneficiaryUpdated(_beneficiary);
    }

    /**
     * @notice Begin the self-destruction counter of this contract.
     * Once the delay has elapsed, the contract may be self-destructed.
     * @dev Only the contract owner may call this.
     */
    function initiateSelfDestruct() external onlyOwner {
        initiationTime = now;
        selfDestructInitiated = true;
        emit SelfDestructInitiated(SELFDESTRUCT_DELAY);
    }

    /**
     * @notice Terminate and reset the self-destruction timer.
     * @dev Only the contract owner may call this.
     */
    function terminateSelfDestruct() external onlyOwner {
        initiationTime = 0;
        selfDestructInitiated = false;
        emit SelfDestructTerminated();
    }

    /**
     * @notice If the self-destruction delay has elapsed, destroy this contract and
     * remit any ether it owns to the beneficiary address.
     * @dev Only the contract owner may call this.
     */
    function selfDestruct() external onlyOwner {
        require(selfDestructInitiated, "Self Destruct not yet initiated");
        require(initiationTime + SELFDESTRUCT_DELAY < now, "Self destruct delay not met");
        emit SelfDestructed(selfDestructBeneficiary);
        selfdestruct(address(uint160(selfDestructBeneficiary)));
    }

    event SelfDestructTerminated();
    event SelfDestructed(address beneficiary);
    event SelfDestructInitiated(uint selfDestructDelay);
    event SelfDestructBeneficiaryUpdated(address newBeneficiary);
}


interface IAddressResolver {
    function getAddress(bytes32 name) external view returns (address);

    function getSynth(bytes32 key) external view returns (address);

    function requireAndGetAddress(bytes32 name, string calldata reason) external view returns (address);
}


interface ISynth {
    // Views
    function currencyKey() external view returns (bytes32);

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

    // Mutative functions
    function transferAndSettle(address to, uint value) external returns (bool);

    function transferFromAndSettle(
        address from,
        address to,
        uint value
    ) external returns (bool);

    // Restricted: used internally to Synthetix
    function burn(address account, uint amount) external;

    function issue(address account, uint amount) external;
}


interface IIssuer {
    // Views
    function anySynthOrSNXRateIsStale() external view returns (bool anyRateStale);

    function availableCurrencyKeys() external view returns (bytes32[] memory);

    function availableSynthCount() external view returns (uint);

    function availableSynths(uint index) external view returns (ISynth);

    function canBurnSynths(address account) external view returns (bool);

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

    function collateralisationRatio(address issuer) external view returns (uint);

    function collateralisationRatioAndAnyRatesStale(address _issuer)
        external
        view
        returns (uint cratio, bool anyRateIsStale);

    function debtBalanceOf(address issuer, bytes32 currencyKey) external view returns (uint debtBalance);

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

    function maxIssuableSynths(address issuer) external view returns (uint maxIssuable);

    function remainingIssuableSynths(address issuer)
        external
        view
        returns (
            uint maxIssuable,
            uint alreadyIssued,
            uint totalSystemDebt
        );

    function synths(bytes32 currencyKey) external view returns (ISynth);

    function synthsByAddress(address synthAddress) external view returns (bytes32);

    function totalIssuedSynths(bytes32 currencyKey, bool excludeEtherCollateral) external view returns (uint);

    function transferableSynthetixAndAnyRateIsStale(address account, uint balance)
        external
        view
        returns (uint transferable, bool anyRateIsStale);

    // Restricted: used internally to Synthetix
    function issueSynths(address from, uint amount) external;

    function issueSynthsOnBehalf(
        address issueFor,
        address from,
        uint amount
    ) external;

    function issueMaxSynths(address from) external;

    function issueMaxSynthsOnBehalf(address issueFor, address from) external;

    function burnSynths(address from, uint amount) external;

    function burnSynthsOnBehalf(
        address burnForAddress,
        address from,
        uint amount
    ) external;

    function burnSynthsToTarget(address from) external;

    function burnSynthsToTargetOnBehalf(address burnForAddress, address from) external;

    function liquidateDelinquentAccount(address account, uint susdAmount, address liquidator) external returns (uint totalRedeemed, uint amountToLiquidate);
}


// Inheritance


// https://docs.synthetix.io/contracts/AddressResolver
contract AddressResolver is Owned, IAddressResolver {
    mapping(bytes32 => address) public repository;

    constructor(address _owner) public Owned(_owner) {}

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

    function importAddresses(bytes32[] calldata names, address[] calldata destinations) external onlyOwner {
        require(names.length == destinations.length, "Input lengths must match");

        for (uint i = 0; i < names.length; i++) {
            repository[names[i]] = destinations[i];
        }
    }

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

    function getAddress(bytes32 name) external view returns (address) {
        return repository[name];
    }

    function requireAndGetAddress(bytes32 name, string calldata reason) external view returns (address) {
        address _foundAddress = repository[name];
        require(_foundAddress != address(0), reason);
        return _foundAddress;
    }

    function getSynth(bytes32 key) external view returns (address) {
        IIssuer issuer = IIssuer(repository["Issuer"]);
        require(address(issuer) != address(0), "Cannot find Issuer address");
        return address(issuer.synths(key));
    }
}


// Inheritance


// Internal references


// https://docs.synthetix.io/contracts/MixinResolver
contract MixinResolver is Owned {
    AddressResolver public resolver;

    mapping(bytes32 => address) private addressCache;

    bytes32[] public resolverAddressesRequired;

    uint public constant MAX_ADDRESSES_FROM_RESOLVER = 24;

    constructor(address _resolver, bytes32[MAX_ADDRESSES_FROM_RESOLVER] memory _addressesToCache) internal {
        // This contract is abstract, and thus cannot be instantiated directly
        require(owner != address(0), "Owner must be set");

        for (uint i = 0; i < _addressesToCache.length; i++) {
            if (_addressesToCache[i] != bytes32(0)) {
                resolverAddressesRequired.push(_addressesToCache[i]);
            } else {
                // End early once an empty item is found - assumes there are no empty slots in
                // _addressesToCache
                break;
            }
        }
        resolver = AddressResolver(_resolver);
        // Do not sync the cache as addresses may not be in the resolver yet
    }

    /* ========== SETTERS ========== */
    function setResolverAndSyncCache(AddressResolver _resolver) external onlyOwner {
        resolver = _resolver;

        for (uint i = 0; i < resolverAddressesRequired.length; i++) {
            bytes32 name = resolverAddressesRequired[i];
            // Note: can only be invoked once the resolver has all the targets needed added
            addressCache[name] = resolver.requireAndGetAddress(name, "Resolver missing target");
        }
    }

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

    function requireAndGetAddress(bytes32 name, string memory reason) internal view returns (address) {
        address _foundAddress = addressCache[name];
        require(_foundAddress != address(0), reason);
        return _foundAddress;
    }

    // Note: this could be made external in a utility contract if addressCache was made public
    // (used for deployment)
    function isResolverCached(AddressResolver _resolver) external view returns (bool) {
        if (resolver != _resolver) {
            return false;
        }

        // otherwise, check everything
        for (uint i = 0; i < resolverAddressesRequired.length; i++) {
            bytes32 name = resolverAddressesRequired[i];
            // false if our cache is invalid or if the resolver doesn't have the required address
            if (resolver.getAddress(name) != addressCache[name] || addressCache[name] == address(0)) {
                return false;
            }
        }

        return true;
    }

    // Note: can be made external into a utility contract (used for deployment)
    function getResolverAddressesRequired()
        external
        view
        returns (bytes32[MAX_ADDRESSES_FROM_RESOLVER] memory addressesRequired)
    {
        for (uint i = 0; i < resolverAddressesRequired.length; i++) {
            addressesRequired[i] = resolverAddressesRequired[i];
        }
    }

    /* ========== INTERNAL FUNCTIONS ========== */
    function appendToAddressCache(bytes32 name) internal {
        resolverAddressesRequired.push(name);
        require(resolverAddressesRequired.length < MAX_ADDRESSES_FROM_RESOLVER, "Max resolver cache size met");
        // Because this is designed to be called internally in constructors, we don't
        // check the address exists already in the resolver
        addressCache[name] = resolver.getAddress(name);
    }
}


interface IERC20 {
    // ERC20 Optional Views
    function name() external view returns (string memory);

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

    function decimals() external view returns (uint8);

    // Views
    function totalSupply() external view returns (uint);

    function balanceOf(address owner) external view returns (uint);

    function allowance(address owner, address spender) external view returns (uint);

    // Mutative functions
    function transfer(address to, uint value) external returns (bool);

    function approve(address spender, uint value) external returns (bool);

    function transferFrom(
        address from,
        address to,
        uint value
    ) external returns (bool);

    // Events
    event Transfer(address indexed from, address indexed to, uint value);

    event Approval(address indexed owner, address indexed spender, uint value);
}


interface IBinaryOption {
    /* ========== VIEWS / VARIABLES ========== */

    function market() external view returns (IBinaryOptionMarket);

    function bidOf(address account) external view returns (uint);
    function totalBids() external view returns (uint);

    function balanceOf(address account) external view returns (uint);
    function totalSupply() external view returns (uint);

    function claimableBalanceOf(address account) external view returns (uint);
    function totalClaimableSupply() external view returns (uint);
}


interface IBinaryOptionMarket {
    /* ========== TYPES ========== */

    enum Phase { Bidding, Trading, Maturity, Expiry }
    enum Side { Long, Short }

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

    function options() external view returns (IBinaryOption long, IBinaryOption short);
    function prices() external view returns (uint long, uint short);
    function times() external view returns (uint biddingEnd, uint maturity, uint destructino);
    function oracleDetails() external view returns (bytes32 key, uint strikePrice, uint finalPrice);
    function fees() external view returns (uint poolFee, uint creatorFee, uint refundFee);
    function creatorLimits() external view returns (uint capitalRequirement, uint skewLimit);

    function deposited() external view returns (uint);
    function creator() external view returns (address);
    function resolved() external view returns (bool);
    function refundsEnabled() external view returns (bool);

    function phase() external view returns (Phase);
    function oraclePriceAndTimestamp() external view returns (uint price, uint updatedAt);
    function canResolve() external view returns (bool);
    function result() external view returns (Side);

    function pricesAfterBidOrRefund(Side side, uint value, bool refund) external view returns (uint long, uint short);
    function bidOrRefundForPrice(Side bidSide, Side priceSide, uint price, bool refund) external view returns (uint);

    function bidsOf(address account) external view returns (uint long, uint short);
    function totalBids() external view returns (uint long, uint short);
    function claimableBalancesOf(address account) external view returns (uint long, uint short);
    function totalClaimableSupplies() external view returns (uint long, uint short);
    function balancesOf(address account) external view returns (uint long, uint short);
    function totalSupplies() external view returns (uint long, uint short);
    function exercisableDeposits() external view returns (uint);

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

    function bid(Side side, uint value) external;
    function refund(Side side, uint value) external returns (uint refundMinusFee);

    function claimOptions() external returns (uint longClaimed, uint shortClaimed);
    function exerciseOptions() external returns (uint);
}


interface IBinaryOptionMarketManager {
    /* ========== VIEWS / VARIABLES ========== */

    function fees() external view returns (uint poolFee, uint creatorFee, uint refundFee);
    function durations() external view returns (uint maxOraclePriceAge, uint expiryDuration, uint maxTimeToMaturity);
    function creatorLimits() external view returns (uint capitalRequirement, uint skewLimit);

    function marketCreationEnabled() external view returns (bool);
    function totalDeposited() external view returns (uint);

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

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

    function createMarket(
        bytes32 oracleKey, uint strikePrice, bool refundsEnabled,
        uint[2] calldata times, // [biddingEnd, maturity]
        uint[2] calldata bids // [longBid, shortBid]
    ) external returns (IBinaryOptionMarket);
    function resolveMarket(address market) external;
    function cancelMarket(address market) external;
    function expireMarkets(address[] calldata market) external;
}


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

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

    function getPage(
        AddressList storage list,
        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 > list.elements.length) {
            endIndex = list.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] = list.elements[i + index];
        }
        return page;
    }

    function push(AddressList storage list, address element) internal {
        list.indices[element] = list.elements.length;
        list.elements.push(element);
    }

    function remove(AddressList storage list, address element) internal {
        require(contains(list, element), "Element not in list.");
        // Replace the removed element with the last element of the list.
        uint index = list.indices[element];
        uint lastIndex = list.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 = list.elements[lastIndex];
            list.elements[index] = shiftedElement;
            list.indices[shiftedElement] = index;
        }
        list.elements.pop();
        delete list.indices[element];
    }
}


/**
 * @dev Wrappers over Solidity's arithmetic operations with added overflow
 * checks.
 *
 * Arithmetic operations in Solidity wrap on overflow. This can easily result
 * in bugs, because programmers usually assume that an overflow raises an
 * error, which is the standard behavior in high level programming languages.
 * `SafeMath` restores this intuition by reverting the transaction when an
 * operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 */
library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");

        return c;
    }

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

        return c;
    }

    /**
     * @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) {
        // 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-solidity/pull/522
        if (a == 0) {
            return 0;
        }

        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");

        return c;
    }

    /**
     * @dev Returns the integer division of two unsigned integers. Reverts on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        // Solidity only automatically asserts when dividing by 0
        require(b > 0, "SafeMath: division by zero");
        uint256 c = a / b;
        // assert(a == b * c + a % b); // There is no case in which this doesn't hold

        return c;
    }

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


// Libraries


// https://docs.synthetix.io/contracts/SafeDecimalMath
library SafeDecimalMath {
    using SafeMath for uint;

    /* Number of decimal places in the representations. */
    uint8 public constant decimals = 18;
    uint8 public constant highPrecisionDecimals = 27;

    /* The number representing 1.0. */
    uint public constant UNIT = 10**uint(decimals);

    /* The number representing 1.0 for higher fidelity numbers. */
    uint public constant PRECISE_UNIT = 10**uint(highPrecisionDecimals);
    uint private constant UNIT_TO_HIGH_PRECISION_CONVERSION_FACTOR = 10**uint(highPrecisionDecimals - decimals);

    /**
     * @return Provides an interface to UNIT.
     */
    function unit() external pure returns (uint) {
        return UNIT;
    }

    /**
     * @return Provides an interface to PRECISE_UNIT.
     */
    function preciseUnit() external pure returns (uint) {
        return PRECISE_UNIT;
    }

    /**
     * @return The result of multiplying x and y, interpreting the operands as fixed-point
     * decimals.
     *
     * @dev A unit factor is divided out after the product of x and y is evaluated,
     * so that product must be less than 2**256. As this is an integer division,
     * the internal division always rounds down. This helps save on gas. Rounding
     * is more expensive on gas.
     */
    function multiplyDecimal(uint x, uint y) internal pure returns (uint) {
        /* Divide by UNIT to remove the extra factor introduced by the product. */
        return x.mul(y) / UNIT;
    }

    /**
     * @return The result of safely multiplying x and y, interpreting the operands
     * as fixed-point decimals of the specified precision unit.
     *
     * @dev The operands should be in the form of a the specified unit factor which will be
     * divided out after the product of x and y is evaluated, so that product must be
     * less than 2**256.
     *
     * Unlike multiplyDecimal, this function rounds the result to the nearest increment.
     * Rounding is useful when you need to retain fidelity for small decimal numbers
     * (eg. small fractions or percentages).
     */
    function _multiplyDecimalRound(
        uint x,
        uint y,
        uint precisionUnit
    ) private pure returns (uint) {
        /* Divide by UNIT to remove the extra factor introduced by the product. */
        uint quotientTimesTen = x.mul(y) / (precisionUnit / 10);

        if (quotientTimesTen % 10 >= 5) {
            quotientTimesTen += 10;
        }

        return quotientTimesTen / 10;
    }

    /**
     * @return The result of safely multiplying x and y, interpreting the operands
     * as fixed-point decimals of a precise unit.
     *
     * @dev The operands should be in the precise unit factor which will be
     * divided out after the product of x and y is evaluated, so that product must be
     * less than 2**256.
     *
     * Unlike multiplyDecimal, this function rounds the result to the nearest increment.
     * Rounding is useful when you need to retain fidelity for small decimal numbers
     * (eg. small fractions or percentages).
     */
    function multiplyDecimalRoundPrecise(uint x, uint y) internal pure returns (uint) {
        return _multiplyDecimalRound(x, y, PRECISE_UNIT);
    }

    /**
     * @return The result of safely multiplying x and y, interpreting the operands
     * as fixed-point decimals of a standard unit.
     *
     * @dev The operands should be in the standard unit factor which will be
     * divided out after the product of x and y is evaluated, so that product must be
     * less than 2**256.
     *
     * Unlike multiplyDecimal, this function rounds the result to the nearest increment.
     * Rounding is useful when you need to retain fidelity for small decimal numbers
     * (eg. small fractions or percentages).
     */
    function multiplyDecimalRound(uint x, uint y) internal pure returns (uint) {
        return _multiplyDecimalRound(x, y, UNIT);
    }

    /**
     * @return The result of safely dividing x and y. The return value is a high
     * precision decimal.
     *
     * @dev y is divided after the product of x and the standard precision unit
     * is evaluated, so the product of x and UNIT must be less than 2**256. As
     * this is an integer division, the result is always rounded down.
     * This helps save on gas. Rounding is more expensive on gas.
     */
    function divideDecimal(uint x, uint y) internal pure returns (uint) {
        /* Reintroduce the UNIT factor that will be divided out by y. */
        return x.mul(UNIT).div(y);
    }

    /**
     * @return The result of safely dividing x and y. The return value is as a rounded
     * decimal in the precision unit specified in the parameter.
     *
     * @dev y is divided after the product of x and the specified precision unit
     * is evaluated, so the product of x and the specified precision unit must
     * be less than 2**256. The result is rounded to the nearest increment.
     */
    function _divideDecimalRound(
        uint x,
        uint y,
        uint precisionUnit
    ) private pure returns (uint) {
        uint resultTimesTen = x.mul(precisionUnit * 10).div(y);

        if (resultTimesTen % 10 >= 5) {
            resultTimesTen += 10;
        }

        return resultTimesTen / 10;
    }

    /**
     * @return The result of safely dividing x and y. The return value is as a rounded
     * standard precision decimal.
     *
     * @dev y is divided after the product of x and the standard precision unit
     * is evaluated, so the product of x and the standard precision unit must
     * be less than 2**256. The result is rounded to the nearest increment.
     */
    function divideDecimalRound(uint x, uint y) internal pure returns (uint) {
        return _divideDecimalRound(x, y, UNIT);
    }

    /**
     * @return The result of safely dividing x and y. The return value is as a rounded
     * high precision decimal.
     *
     * @dev y is divided after the product of x and the high precision unit
     * is evaluated, so the product of x and the high precision unit must
     * be less than 2**256. The result is rounded to the nearest increment.
     */
    function divideDecimalRoundPrecise(uint x, uint y) internal pure returns (uint) {
        return _divideDecimalRound(x, y, PRECISE_UNIT);
    }

    /**
     * @dev Convert a standard decimal representation to a high precision one.
     */
    function decimalToPreciseDecimal(uint i) internal pure returns (uint) {
        return i.mul(UNIT_TO_HIGH_PRECISION_CONVERSION_FACTOR);
    }

    /**
     * @dev Convert a high precision decimal to a standard decimal representation.
     */
    function preciseDecimalToDecimal(uint i) internal pure returns (uint) {
        uint quotientTimesTen = i / (UNIT_TO_HIGH_PRECISION_CONVERSION_FACTOR / 10);

        if (quotientTimesTen % 10 >= 5) {
            quotientTimesTen += 10;
        }

        return quotientTimesTen / 10;
    }
}


// Inheritance


// Libraries


// Internal references


contract BinaryOption is IERC20, IBinaryOption {
    /* ========== LIBRARIES ========== */

    using SafeMath for uint;
    using SafeDecimalMath for uint;

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

    string public constant name = "SNX Binary Option";
    string public constant symbol = "sOPT";
    uint8 public constant decimals = 18;

    BinaryOptionMarket public market;

    mapping(address => uint) public bidOf;
    uint public totalBids;

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

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

    // Enforce a 1 cent minimum bid balance
    uint internal constant _MINIMUM_BID = 1e16;

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

    constructor(address initialBidder, uint initialBid) public {
        market = BinaryOptionMarket(msg.sender);
        bidOf[initialBidder] = initialBid;
        totalBids = initialBid;
    }

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

    function _claimableBalanceOf(
        uint _bid,
        uint price,
        uint exercisableDeposits
    ) internal view returns (uint) {
        uint owed = _bid.divideDecimal(price);
        uint supply = _totalClaimableSupply(exercisableDeposits);

        /* The last claimant might be owed slightly more or less than the actual remaining deposit
           based on rounding errors with the price.
           Therefore if the user's bid is the entire rest of the pot, just give them everything that's left.
           If there is no supply, then this option lost, and we'll return 0.
           */
        if ((_bid == totalBids && _bid != 0) || supply == 0) {
            return supply;
        }

        /* Note that option supply on the losing side and deposits can become decoupled,
           but losing options are not claimable, therefore we only need to worry about
           the situation where supply < owed on the winning side.

           If somehow a user who is not the last bidder is owed more than what's available,
           subsequent bidders will be disadvantaged. Given that the minimum bid is 10^16 wei,
           this should never occur in reality. */
        require(owed <= supply, "supply < claimable");
        return owed;
    }

    function claimableBalanceOf(address account) external view returns (uint) {
        (uint price, uint exercisableDeposits) = market.senderPriceAndExercisableDeposits();
        return _claimableBalanceOf(bidOf[account], price, exercisableDeposits);
    }

    function _totalClaimableSupply(uint exercisableDeposits) internal view returns (uint) {
        uint _totalSupply = totalSupply;
        // We'll avoid throwing an exception here to avoid breaking any dapps, but this case
        // should never occur given the minimum bid size.
        if (exercisableDeposits <= _totalSupply) {
            return 0;
        }
        return exercisableDeposits.sub(_totalSupply);
    }

    function totalClaimableSupply() external view returns (uint) {
        (, uint exercisableDeposits) = market.senderPriceAndExercisableDeposits();
        return _totalClaimableSupply(exercisableDeposits);
    }

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

    function _requireMinimumBid(uint bid) internal pure returns (uint) {
        require(bid >= _MINIMUM_BID || bid == 0, "Balance < $0.01");
        return bid;
    }

    // This must only be invoked during bidding.
    function bid(address bidder, uint newBid) external onlyMarket {
        bidOf[bidder] = _requireMinimumBid(bidOf[bidder].add(newBid));
        totalBids = totalBids.add(newBid);
    }

    // This must only be invoked during bidding.
    function refund(address bidder, uint newRefund) external onlyMarket {
        // The safe subtraction will catch refunds that are too large.
        bidOf[bidder] = _requireMinimumBid(bidOf[bidder].sub(newRefund));
        totalBids = totalBids.sub(newRefund);
    }

    // This must only be invoked after bidding.
    function claim(
        address claimant,
        uint price,
        uint depositsRemaining
    ) external onlyMarket returns (uint optionsClaimed) {
        uint _bid = bidOf[claimant];
        uint claimable = _claimableBalanceOf(_bid, price, depositsRemaining);
        // No options to claim? Nothing happens.
        if (claimable == 0) {
            return 0;
        }

        totalBids = totalBids.sub(_bid);
        bidOf[claimant] = 0;

        totalSupply = totalSupply.add(claimable);
        balanceOf[claimant] = balanceOf[claimant].add(claimable); // Increment rather than assigning since a transfer may have occurred.

        emit Transfer(address(0), claimant, claimable);
        emit Issued(claimant, claimable);

        return claimable;
    }

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

        if (balance == 0) {
            return;
        }

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

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

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

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

    // This should only operate after bidding;
    // Since options can't be claimed until after bidding, all balances are zero until that time.
    // So we don't need to explicitly check the timestamp to prevent transfers.
    function _transfer(
        address _from,
        address _to,
        uint _value
    ) internal returns (bool success) {
        market.requireActiveAndUnpaused();
        require(_to != address(0) && _to != address(this), "Invalid address");

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

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

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

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

    function transferFrom(
        address _from,
        address _to,
        uint _value
    ) external returns (bool success) {
        uint fromAllowance = allowance[_from][msg.sender];
        require(_value <= fromAllowance, "Insufficient allowance");

        allowance[_from][msg.sender] = fromAllowance.sub(_value);
        return _transfer(_from, _to, _value);
    }

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

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

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

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

    event Issued(address indexed account, uint value);
    event Burned(address indexed account, uint value);
    event Transfer(address indexed from, address indexed to, uint value);
    event Approval(address indexed owner, address indexed spender, uint value);
}


// https://docs.synthetix.io/contracts/source/interfaces/IExchangeRates
interface IExchangeRates {
    // Views
    function aggregators(bytes32 currencyKey) external view returns (address);

    function anyRateIsStale(bytes32[] calldata currencyKeys) external view returns (bool);

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

    function effectiveValue(
        bytes32 sourceCurrencyKey,
        uint sourceAmount,
        bytes32 destinationCurrencyKey
    ) external view returns (uint value);

    function effectiveValueAndRates(
        bytes32 sourceCurrencyKey,
        uint sourceAmount,
        bytes32 destinationCurrencyKey
    )
        external
        view
        returns (
            uint value,
            uint sourceRate,
            uint destinationRate
        );

    function effectiveValueAtRound(
        bytes32 sourceCurrencyKey,
        uint sourceAmount,
        bytes32 destinationCurrencyKey,
        uint roundIdForSrc,
        uint roundIdForDest
    ) external view returns (uint value);

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

    function getLastRoundIdBeforeElapsedSecs(
        bytes32 currencyKey,
        uint startingRoundId,
        uint startingTimestamp,
        uint timediff
    ) external view returns (uint);

    function inversePricing(bytes32 currencyKey)
        external
        view
        returns (
            uint entryPoint,
            uint upperLimit,
            uint lowerLimit,
            bool frozen
        );

    function lastRateUpdateTimes(bytes32 currencyKey) external view returns (uint256);

    function oracle() external view returns (address);

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

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

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

    function rateIsFrozen(bytes32 currencyKey) external view returns (bool);

    function rateIsStale(bytes32 currencyKey) external view returns (bool);

    function rateStalePeriod() external view returns (uint);

    function ratesAndUpdatedTimeForCurrencyLastNRounds(bytes32 currencyKey, uint numRounds)
        external
        view
        returns (uint[] memory rates, uint[] memory times);

    function ratesAndStaleForCurrencies(bytes32[] calldata currencyKeys) external view returns (uint[] memory, bool);

    function ratesForCurrencies(bytes32[] calldata currencyKeys) external view returns (uint[] memory);
}


interface IFeePool {
    // Views
    function getExchangeFeeRateForSynth(bytes32 synthKey) external view returns (uint);

    // solhint-disable-next-line func-name-mixedcase
    function FEE_ADDRESS() external view returns (address);

    function feesAvailable(address account) external view returns (uint, uint);

    function isFeesClaimable(address account) external view returns (bool);

    function totalFeesAvailable() external view returns (uint);

    function totalRewardsAvailable() external view returns (uint);

    // Mutative Functions
    function claimFees() external returns (bool);

    function claimOnBehalf(address claimingForAddress) external returns (bool);

    function closeCurrentFeePeriod() external;

    // Restricted: used internally to Synthetix
    function appendAccountIssuanceRecord(
        address account,
        uint lockedAmount,
        uint debtEntryIndex
    ) external;

    function recordFeePaid(uint sUSDAmount) external;

    function setRewardsToDistribute(uint amount) external;
}


// Inheritance


// Libraries


// Internal references


contract BinaryOptionMarket is Owned, MixinResolver, IBinaryOptionMarket {
    /* ========== LIBRARIES ========== */

    using SafeMath for uint;
    using SafeDecimalMath for uint;

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

    struct Options {
        BinaryOption long;
        BinaryOption short;
    }

    struct Prices {
        uint long;
        uint short;
    }

    struct Times {
        uint biddingEnd;
        uint maturity;
        uint expiry;
    }

    struct OracleDetails {
        bytes32 key;
        uint strikePrice;
        uint finalPrice;
    }

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

    Options public options;
    Prices public prices;
    Times public times;
    OracleDetails public oracleDetails;
    BinaryOptionMarketManager.Fees public fees;
    BinaryOptionMarketManager.CreatorLimits public creatorLimits;

    // `deposited` tracks the sum of open bids on short and long, plus withheld refund fees.
    // This must explicitly be kept, in case tokens are transferred to the contract directly.
    uint public deposited;
    address public creator;
    bool public resolved;
    bool public refundsEnabled;

    uint internal _feeMultiplier;

    /* ---------- Address Resolver Configuration ---------- */

    bytes32 internal constant CONTRACT_SYSTEMSTATUS = "SystemStatus";
    bytes32 internal constant CONTRACT_EXRATES = "ExchangeRates";
    bytes32 internal constant CONTRACT_SYNTHSUSD = "SynthsUSD";
    bytes32 internal constant CONTRACT_FEEPOOL = "FeePool";

    bytes32[24] internal addressesToCache = [CONTRACT_SYSTEMSTATUS, CONTRACT_EXRATES, CONTRACT_SYNTHSUSD, CONTRACT_FEEPOOL];

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

    constructor(
        address _owner,
        address _creator,
        uint[2] memory _creatorLimits, // [capitalRequirement, skewLimit]
        bytes32 _oracleKey,
        uint _strikePrice,
        bool _refundsEnabled,
        uint[3] memory _times, // [biddingEnd, maturity, expiry]
        uint[2] memory _bids, // [longBid, shortBid]
        uint[3] memory _fees // [poolFee, creatorFee, refundFee]
    )
        public
        Owned(_owner)
        MixinResolver(_owner, addressesToCache) // The resolver is initially set to the owner, but it will be set correctly when the cache is synchronised
    {
        creator = _creator;
        creatorLimits = BinaryOptionMarketManager.CreatorLimits(_creatorLimits[0], _creatorLimits[1]);

        oracleDetails = OracleDetails(_oracleKey, _strikePrice, 0);
        times = Times(_times[0], _times[1], _times[2]);

        refundsEnabled = _refundsEnabled;

        (uint longBid, uint shortBid) = (_bids[0], _bids[1]);
        _checkCreatorLimits(longBid, shortBid);
        emit Bid(Side.Long, _creator, longBid);
        emit Bid(Side.Short, _creator, shortBid);

        // Note that the initial deposit of synths must be made by the manager, otherwise the contract's assumed
        // deposits will fall out of sync with its actual balance. Similarly the total system deposits must be updated in the manager.
        // A balance check isn't performed here since the manager doesn't know the address of the new contract until after it is created.
        uint initialDeposit = longBid.add(shortBid);
        deposited = initialDeposit;

        (uint poolFee, uint creatorFee) = (_fees[0], _fees[1]);
        fees = BinaryOptionMarketManager.Fees(poolFee, creatorFee, _fees[2]);
        _feeMultiplier = SafeDecimalMath.unit().sub(poolFee.add(creatorFee));

        // Compute the prices now that the fees and deposits have been set.
        _updatePrices(longBid, shortBid, initialDeposit);

        // Instantiate the options themselves
        options.long = new BinaryOption(_creator, longBid);
        options.short = new BinaryOption(_creator, shortBid);
    }

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

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

    function _systemStatus() internal view returns (ISystemStatus) {
        return ISystemStatus(requireAndGetAddress(CONTRACT_SYSTEMSTATUS, "Missing SystemStatus"));
    }

    function _exchangeRates() internal view returns (IExchangeRates) {
        return IExchangeRates(requireAndGetAddress(CONTRACT_EXRATES, "Missing ExchangeRates"));
    }

    function _sUSD() internal view returns (IERC20) {
        return IERC20(requireAndGetAddress(CONTRACT_SYNTHSUSD, "Missing SynthsUSD"));
    }

    function _feePool() internal view returns (IFeePool) {
        return IFeePool(requireAndGetAddress(CONTRACT_FEEPOOL, "Missing FeePool"));
    }

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

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

    function _biddingEnded() internal view returns (bool) {
        return times.biddingEnd < now;
    }

    function _matured() internal view returns (bool) {
        return times.maturity < now;
    }

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

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

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

    function _oraclePriceAndTimestamp() internal view returns (uint price, uint updatedAt) {
        return _exchangeRates().rateAndUpdatedTime(oracleDetails.key);
    }

    function oraclePriceAndTimestamp() external view returns (uint price, uint updatedAt) {
        return _oraclePriceAndTimestamp();
    }

    function _isFreshPriceUpdateTime(uint timestamp) internal view returns (bool) {
        (uint maxOraclePriceAge, , ) = _manager().durations();
        return (times.maturity.sub(maxOraclePriceAge)) <= timestamp;
    }

    function canResolve() external view returns (bool) {
        (, uint updatedAt) = _oraclePriceAndTimestamp();
        return !resolved && _matured() && _isFreshPriceUpdateTime(updatedAt);
    }

    function _result() internal view returns (Side) {
        uint price;
        if (resolved) {
            price = oracleDetails.finalPrice;
        } else {
            (price, ) = _oraclePriceAndTimestamp();
        }

        return oracleDetails.strikePrice <= price ? Side.Long : Side.Short;
    }

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

    /* ---------- Option Prices ---------- */

    function _computePrices(
        uint longBids,
        uint shortBids,
        uint _deposited
    ) internal view returns (uint long, uint short) {
        require(longBids != 0 && shortBids != 0, "Bids must be nonzero");
        uint optionsPerSide = _exercisableDeposits(_deposited);

        // The math library rounds up on an exact half-increment -- the price on one side may be an increment too high,
        // but this only implies a tiny extra quantity will go to fees.
        return (longBids.divideDecimalRound(optionsPerSide), shortBids.divideDecimalRound(optionsPerSide));
    }

    function senderPriceAndExercisableDeposits() external view returns (uint price, uint exercisable) {
        // When the market is not yet resolved, both sides might be able to exercise all the options.
        // On the other hand, if the market has resolved, then only the winning side may exercise.
        exercisable = 0;
        if (!resolved || address(_option(_result())) == msg.sender) {
            exercisable = _exercisableDeposits(deposited);
        }

        // Send the correct price for each side of the market.
        if (msg.sender == address(options.long)) {
            price = prices.long;
        } else if (msg.sender == address(options.short)) {
            price = prices.short;
        } else {
            revert("Sender is not an option");
        }
    }

    function pricesAfterBidOrRefund(
        Side side,
        uint value,
        bool refund
    ) external view returns (uint long, uint short) {
        (uint longTotalBids, uint shortTotalBids) = _totalBids();
        // prettier-ignore
        function(uint, uint) pure returns (uint) operation = refund ? SafeMath.sub : SafeMath.add;

        if (side == Side.Long) {
            longTotalBids = operation(longTotalBids, value);
        } else {
            shortTotalBids = operation(shortTotalBids, value);
        }

        if (refund) {
            value = value.multiplyDecimalRound(SafeDecimalMath.unit().sub(fees.refundFee));
        }
        return _computePrices(longTotalBids, shortTotalBids, operation(deposited, value));
    }

    // Returns zero if the result would be negative. See the docs for the formulae this implements.
    function bidOrRefundForPrice(
        Side bidSide,
        Side priceSide,
        uint price,
        bool refund
    ) external view returns (uint) {
        uint adjustedPrice = price.multiplyDecimalRound(_feeMultiplier);
        uint bids = _option(priceSide).totalBids();
        uint _deposited = deposited;
        uint unit = SafeDecimalMath.unit();
        uint refundFeeMultiplier = unit.sub(fees.refundFee);

        if (bidSide == priceSide) {
            uint depositedByPrice = _deposited.multiplyDecimalRound(adjustedPrice);

            // For refunds, the numerator is the negative of the bid case and,
            // in the denominator the adjusted price has an extra factor of (1 - the refundFee).
            if (refund) {
                (depositedByPrice, bids) = (bids, depositedByPrice);
                adjustedPrice = adjustedPrice.multiplyDecimalRound(refundFeeMultiplier);
            }

            // The adjusted price is guaranteed to be less than 1: all its factors are also less than 1.
            return _subToZero(depositedByPrice, bids).divideDecimalRound(unit.sub(adjustedPrice));
        } else {
            uint bidsPerPrice = bids.divideDecimalRound(adjustedPrice);

            // For refunds, the numerator is the negative of the bid case.
            if (refund) {
                (bidsPerPrice, _deposited) = (_deposited, bidsPerPrice);
            }

            uint value = _subToZero(bidsPerPrice, _deposited);
            return refund ? value.divideDecimalRound(refundFeeMultiplier) : value;
        }
    }

    /* ---------- Option Balances and Bids ---------- */

    function _bidsOf(address account) internal view returns (uint long, uint short) {
        return (options.long.bidOf(account), options.short.bidOf(account));
    }

    function bidsOf(address account) external view returns (uint long, uint short) {
        return _bidsOf(account);
    }

    function _totalBids() internal view returns (uint long, uint short) {
        return (options.long.totalBids(), options.short.totalBids());
    }

    function totalBids() external view returns (uint long, uint short) {
        return _totalBids();
    }

    function _claimableBalancesOf(address account) internal view returns (uint long, uint short) {
        return (options.long.claimableBalanceOf(account), options.short.claimableBalanceOf(account));
    }

    function claimableBalancesOf(address account) external view returns (uint long, uint short) {
        return _claimableBalancesOf(account);
    }

    function totalClaimableSupplies() external view returns (uint long, uint short) {
        return (options.long.totalClaimableSupply(), options.short.totalClaimableSupply());
    }

    function _balancesOf(address account) internal view returns (uint long, uint short) {
        return (options.long.balanceOf(account), options.short.balanceOf(account));
    }

    function balancesOf(address account) external view returns (uint long, uint short) {
        return _balancesOf(account);
    }

    function totalSupplies() external view returns (uint long, uint short) {
        return (options.long.totalSupply(), options.short.totalSupply());
    }

    function _exercisableDeposits(uint _deposited) internal view returns (uint) {
        // Fees are deducted at resolution, so remove them if we're still bidding or trading.
        return resolved ? _deposited : _deposited.multiplyDecimalRound(_feeMultiplier);
    }

    function exercisableDeposits() external view returns (uint) {
        return _exercisableDeposits(deposited);
    }

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

    function _chooseSide(
        Side side,
        uint longValue,
        uint shortValue
    ) internal pure returns (uint) {
        if (side == Side.Long) {
            return longValue;
        }
        return shortValue;
    }

    function _option(Side side) internal view returns (BinaryOption) {
        if (side == Side.Long) {
            return options.long;
        }
        return options.short;
    }

    // Returns zero if the result would be negative.
    function _subToZero(uint a, uint b) internal pure returns (uint) {
        return a < b ? 0 : a.sub(b);
    }

    function _checkCreatorLimits(uint longBid, uint shortBid) internal view {
        uint totalBid = longBid.add(shortBid);
        require(creatorLimits.capitalRequirement <= totalBid, "Insufficient capital");
        uint skewLimit = creatorLimits.skewLimit;
        require(
            skewLimit <= longBid.divideDecimal(totalBid) && skewLimit <= shortBid.divideDecimal(totalBid),
            "Bids too skewed"
        );
    }

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

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

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

    function requireActiveAndUnpaused() external view {
        _systemStatus().requireSystemActive();
        _requireManagerNotPaused();
    }

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

    /* ---------- Bidding and Refunding ---------- */

    function _updatePrices(
        uint longBids,
        uint shortBids,
        uint _deposited
    ) internal {
        (uint256 longPrice, uint256 shortPrice) = _computePrices(longBids, shortBids, _deposited);
        prices = Prices(longPrice, shortPrice);
        emit PricesUpdated(longPrice, shortPrice);
    }

    function bid(Side side, uint value) external duringBidding {
        if (value == 0) {
            return;
        }

        _option(side).bid(msg.sender, value);
        emit Bid(side, msg.sender, value);

        uint _deposited = _incrementDeposited(value);
        _sUSD().transferFrom(msg.sender, address(this), value);

        (uint longTotalBids, uint shortTotalBids) = _totalBids();
        _updatePrices(longTotalBids, shortTotalBids, _deposited);
    }

    function refund(Side side, uint value) external duringBidding returns (uint refundMinusFee) {
        require(refundsEnabled, "Refunds disabled");
        if (value == 0) {
            return 0;
        }

        // Require the market creator to leave sufficient capital in the market.
        if (msg.sender == creator) {
            (uint thisBid, uint thatBid) = _bidsOf(msg.sender);
            if (side == Side.Short) {
                (thisBid, thatBid) = (thatBid, thisBid);
            }
            _checkCreatorLimits(thisBid.sub(value), thatBid);
        }

        // Safe subtraction here and in related contracts will fail if either the
        // total supply, deposits, or wallet balance are too small to support the refund.
        refundMinusFee = value.multiplyDecimalRound(SafeDecimalMath.unit().sub(fees.refundFee));

        _option(side).refund(msg.sender, value);
        emit Refund(side, msg.sender, refundMinusFee, value.sub(refundMinusFee));

        uint _deposited = _decrementDeposited(refundMinusFee);
        _sUSD().transfer(msg.sender, refundMinusFee);

        (uint longTotalBids, uint shortTotalBids) = _totalBids();
        _updatePrices(longTotalBids, shortTotalBids, _deposited);
    }

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

    function resolve() external onlyOwner afterMaturity systemActive managerNotPaused {
        require(!resolved, "Market already resolved");

        // We don't need to perform stale price checks, so long as the price was
        // last updated recently enough before the maturity date.
        (uint price, uint updatedAt) = _oraclePriceAndTimestamp();
        require(_isFreshPriceUpdateTime(updatedAt), "Price is stale");

        oracleDetails.finalPrice = price;
        resolved = true;

        // Now remit any collected fees.
        // Since the constructor enforces that creatorFee + poolFee < 1, the balance
        // in the contract will be sufficient to cover these transfers.
        IERC20 sUSD = _sUSD();

        uint _deposited = deposited;
        uint poolFees = _deposited.multiplyDecimalRound(fees.poolFee);
        uint creatorFees = _deposited.multiplyDecimalRound(fees.creatorFee);
        _decrementDeposited(creatorFees.add(poolFees));
        sUSD.transfer(_feePool().FEE_ADDRESS(), poolFees);
        sUSD.transfer(creator, creatorFees);

        emit MarketResolved(_result(), price, updatedAt, deposited, poolFees, creatorFees);
    }

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

    function _claimOptions()
        internal
        systemActive
        managerNotPaused
        afterBidding
        returns (uint longClaimed, uint shortClaimed)
    {
        uint exercisable = _exercisableDeposits(deposited);
        Side outcome = _result();
        bool _resolved = resolved;

        // Only claim options if we aren't resolved, and only claim the winning side.
        uint longOptions;
        uint shortOptions;
        if (!_resolved || outcome == Side.Long) {
            longOptions = options.long.claim(msg.sender, prices.long, exercisable);
        }
        if (!_resolved || outcome == Side.Short) {
            shortOptions = options.short.claim(msg.sender, prices.short, exercisable);
        }

        require(longOptions != 0 || shortOptions != 0, "Nothing to claim");
        emit OptionsClaimed(msg.sender, longOptions, shortOptions);
        return (longOptions, shortOptions);
    }

    function claimOptions() external returns (uint longClaimed, uint shortClaimed) {
        return _claimOptions();
    }

    function exerciseOptions() external returns (uint) {
        // The market must be resolved if it has not been.
        if (!resolved) {
            _manager().resolveMarket(address(this));
        }

        // If there are options to be claimed, claim them and proceed.
        (uint claimableLong, uint claimableShort) = _claimableBalancesOf(msg.sender);
        if (claimableLong != 0 || claimableShort != 0) {
            _claimOptions();
        }

        // If the account holds no options, revert.
        (uint longBalance, uint shortBalance) = _balancesOf(msg.sender);
        require(longBalance != 0 || shortBalance != 0, "Nothing to exercise");

        // Each option only needs to be exercised if the account holds any of it.
        if (longBalance != 0) {
            options.long.exercise(msg.sender);
        }
        if (shortBalance != 0) {
            options.short.exercise(msg.sender);
        }

        // Only pay out the side that won.
        uint payout = _chooseSide(_result(), longBalance, shortBalance);
        emit OptionsExercised(msg.sender, payout);
        if (payout != 0) {
            _decrementDeposited(payout);
            _sUSD().transfer(msg.sender, payout);
        }
        return payout;
    }

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

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

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

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

    function cancel(address payable beneficiary) external onlyOwner duringBidding {
        (uint longTotalBids, uint shortTotalBids) = _totalBids();
        (uint creatorLongBids, uint creatorShortBids) = _bidsOf(creator);
        bool cancellable = longTotalBids == creatorLongBids && shortTotalBids == creatorShortBids;
        require(cancellable, "Not cancellable");
        _selfDestruct(beneficiary);
    }

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

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

    modifier duringBidding() {
        require(!_biddingEnded(), "Bidding inactive");
        _;
    }

    modifier afterBidding() {
        require(_biddingEnded(), "Bidding incomplete");
        _;
    }

    modifier afterMaturity() {
        require(_matured(), "Not yet mature");
        _;
    }

    modifier systemActive() {
        _systemStatus().requireSystemActive();
        _;
    }

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

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

    event Bid(Side side, address indexed account, uint value);
    event Refund(Side side, address indexed account, uint value, uint fee);
    event PricesUpdated(uint longPrice, uint shortPrice);
    event MarketResolved(
        Side result,
        uint oraclePrice,
        uint oracleTimestamp,
        uint deposited,
        uint poolFees,
        uint creatorFees
    );
    event OptionsClaimed(address indexed account, uint longOptions, uint shortOptions);
    event OptionsExercised(address indexed account, uint value);
}


// Inheritance


// Internal references


contract BinaryOptionMarketFactory is Owned, SelfDestructible, MixinResolver {
    /* ========== STATE VARIABLES ========== */

    /* ---------- Address Resolver Configuration ---------- */

    bytes32 internal constant CONTRACT_BINARYOPTIONMARKETMANAGER = "BinaryOptionMarketManager";

    bytes32[24] internal addressesToCache = [CONTRACT_BINARYOPTIONMARKETMANAGER];

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

    constructor(address _owner, address _resolver)
        public
        Owned(_owner)
        SelfDestructible()
        MixinResolver(_resolver, addressesToCache)
    {}

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

    /* ---------- Related Contracts ---------- */

    function _manager() internal view returns (address) {
        return requireAndGetAddress(CONTRACT_BINARYOPTIONMARKETMANAGER, "Missing BinaryOptionMarketManager address");
    }

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

    function createMarket(
        address creator,
        uint[2] calldata creatorLimits,
        bytes32 oracleKey,
        uint strikePrice,
        bool refundsEnabled,
        uint[3] calldata times, // [biddingEnd, maturity, expiry]
        uint[2] calldata bids, // [longBid, shortBid]
        uint[3] calldata fees // [poolFee, creatorFee, refundFee]
    ) external returns (BinaryOptionMarket) {
        address manager = _manager();
        require(address(manager) == msg.sender, "Only permitted by the manager.");

        return new BinaryOptionMarket(manager, creator, creatorLimits, oracleKey, strikePrice, refundsEnabled, times, bids, fees);
    }
}


interface ISystemStatus {
    // Views
    function requireSystemActive() external view;

    function requireIssuanceActive() external view;

    function requireExchangeActive() external view;

    function requireSynthActive(bytes32 currencyKey) external view;

    function requireSynthsActive(bytes32 sourceCurrencyKey, bytes32 destinationCurrencyKey) external view;
}


// Inheritance


// Libraries


// Internal references


contract BinaryOptionMarketManager is Owned, Pausable, SelfDestructible, MixinResolver, IBinaryOptionMarketManager {
    /* ========== LIBRARIES ========== */

    using SafeMath for uint;
    using AddressListLib for AddressListLib.AddressList;

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

    struct Fees {
        uint poolFee;
        uint creatorFee;
        uint refundFee;
    }

    struct Durations {
        uint maxOraclePriceAge;
        uint expiryDuration;
        uint maxTimeToMaturity;
    }

    struct CreatorLimits {
        uint capitalRequirement;
        uint skewLimit;
    }

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

    Fees public fees;
    Durations public durations;
    CreatorLimits public creatorLimits;

    bool public marketCreationEnabled = true;
    uint public totalDeposited;

    AddressListLib.AddressList internal _activeMarkets;
    AddressListLib.AddressList internal _maturedMarkets;

    BinaryOptionMarketManager internal _migratingManager;

    /* ---------- Address Resolver Configuration ---------- */

    bytes32 internal constant CONTRACT_SYSTEMSTATUS = "SystemStatus";
    bytes32 internal constant CONTRACT_SYNTHSUSD = "SynthsUSD";
    bytes32 internal constant CONTRACT_EXRATES = "ExchangeRates";
    bytes32 internal constant CONTRACT_BINARYOPTIONMARKETFACTORY = "BinaryOptionMarketFactory";

    bytes32[24] internal addressesToCache = [
        CONTRACT_SYSTEMSTATUS,
        CONTRACT_SYNTHSUSD,
        CONTRACT_EXRATES,
        CONTRACT_BINARYOPTIONMARKETFACTORY
    ];

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

    constructor(
        address _owner,
        address _resolver,
        uint _maxOraclePriceAge,
        uint _expiryDuration,
        uint _maxTimeToMaturity,
        uint _creatorCapitalRequirement,
        uint _creatorSkewLimit,
        uint _poolFee,
        uint _creatorFee,
        uint _refundFee
    ) public Owned(_owner) Pausable() SelfDestructible() MixinResolver(_resolver, addressesToCache) {
        // Temporarily change the owner so that the setters don't revert.
        owner = msg.sender;
        setExpiryDuration(_expiryDuration);
        setMaxOraclePriceAge(_maxOraclePriceAge);
        setMaxTimeToMaturity(_maxTimeToMaturity);
        setCreatorCapitalRequirement(_creatorCapitalRequirement);
        setCreatorSkewLimit(_creatorSkewLimit);
        setPoolFee(_poolFee);
        setCreatorFee(_creatorFee);
        setRefundFee(_refundFee);
        owner = _owner;
    }

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

    /* ---------- Related Contracts ---------- */

    function _systemStatus() internal view returns (ISystemStatus) {
        return ISystemStatus(requireAndGetAddress(CONTRACT_SYSTEMSTATUS, "Missing SystemStatus address"));
    }

    function _sUSD() internal view returns (IERC20) {
        return IERC20(requireAndGetAddress(CONTRACT_SYNTHSUSD, "Missing SynthsUSD address"));
    }

    function _exchangeRates() internal view returns (IExchangeRates) {
        return IExchangeRates(requireAndGetAddress(CONTRACT_EXRATES, "Missing ExchangeRates"));
    }

    function _factory() internal view returns (BinaryOptionMarketFactory) {
        return
            BinaryOptionMarketFactory(
                requireAndGetAddress(CONTRACT_BINARYOPTIONMARKETFACTORY, "Missing BinaryOptionMarketFactory address")
            );
    }

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

    function _isKnownMarket(address candidate) internal view returns (bool) {
        return _activeMarkets.contains(candidate) || _maturedMarkets.contains(candidate);
    }

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

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

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

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

    function _isValidKey(bytes32 oracleKey) internal view returns (bool) {
        IExchangeRates exchangeRates = _exchangeRates();

        // If it has a rate, then it's possibly a valid key
        if (exchangeRates.rateForCurrency(oracleKey) != 0) {
            // But not sUSD
            if (oracleKey == "sUSD") {
                return false;
            }

            // and not inverse rates
            (uint entryPoint, , , ) = exchangeRates.inversePricing(oracleKey);
            if (entryPoint != 0) {
                return false;
            }

            return true;
        }

        return false;
    }

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

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

    function setMaxOraclePriceAge(uint _maxOraclePriceAge) public onlyOwner {
        durations.maxOraclePriceAge = _maxOraclePriceAge;
        emit MaxOraclePriceAgeUpdated(_maxOraclePriceAge);
    }

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

    function setMaxTimeToMaturity(uint _maxTimeToMaturity) public onlyOwner {
        durations.maxTimeToMaturity = _maxTimeToMaturity;
        emit MaxTimeToMaturityUpdated(_maxTimeToMaturity);
    }

    function setPoolFee(uint _poolFee) public onlyOwner {
        uint totalFee = _poolFee + fees.creatorFee;
        require(totalFee < SafeDecimalMath.unit(), "Total fee must be less than 100%.");
        require(0 < totalFee, "Total fee must be nonzero.");
        fees.poolFee = _poolFee;
        emit PoolFeeUpdated(_poolFee);
    }

    function setCreatorFee(uint _creatorFee) public onlyOwner {
        uint totalFee = _creatorFee + fees.poolFee;
        require(totalFee < SafeDecimalMath.unit(), "Total fee must be less than 100%.");
        require(0 < totalFee, "Total fee must be nonzero.");
        fees.creatorFee = _creatorFee;
        emit CreatorFeeUpdated(_creatorFee);
    }

    function setRefundFee(uint _refundFee) public onlyOwner {
        require(_refundFee <= SafeDecimalMath.unit(), "Refund fee must be no greater than 100%.");
        fees.refundFee = _refundFee;
        emit RefundFeeUpdated(_refundFee);
    }

    function setCreatorCapitalRequirement(uint _creatorCapitalRequirement) public onlyOwner {
        creatorLimits.capitalRequirement = _creatorCapitalRequirement;
        emit CreatorCapitalRequirementUpdated(_creatorCapitalRequirement);
    }

    function setCreatorSkewLimit(uint _creatorSkewLimit) public onlyOwner {
        require(_creatorSkewLimit <= SafeDecimalMath.unit(), "Creator skew limit must be no greater than 1.");
        creatorLimits.skewLimit = _creatorSkewLimit;
        emit CreatorSkewLimitUpdated(_creatorSkewLimit);
    }

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

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

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

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

    function createMarket(
        bytes32 oracleKey,
        uint strikePrice,
        bool refundsEnabled,
        uint[2] calldata times, // [biddingEnd, maturity]
        uint[2] calldata bids // [longBid, shortBid]
    )
        external
        notPaused
        returns (
            IBinaryOptionMarket // no support for returning BinaryOptionMarket polymorphically given the interface
        )
    {
        _systemStatus().requireSystemActive();
        require(marketCreationEnabled, "Market creation is disabled");
        require(_isValidKey(oracleKey), "Invalid key");

        (uint biddingEnd, uint maturity) = (times[0], times[1]);
        require(maturity <= now + durations.maxTimeToMaturity, "Maturity too far in the future");
        uint expiry = maturity.add(durations.expiryDuration);

        uint initialDeposit = bids[0].add(bids[1]);
        require(now < biddingEnd, "End of bidding has passed");
        require(biddingEnd < maturity, "Maturity predates end of bidding");
        // We also require maturity < expiry. But there is no need to check this.
        // Fees being in range are checked in the setters.
        // The market itself validates the capital and skew requirements.

        BinaryOptionMarket market = _factory().createMarket(
            msg.sender,
            [creatorLimits.capitalRequirement, creatorLimits.skewLimit],
            oracleKey,
            strikePrice,
            refundsEnabled,
            [biddingEnd, maturity, expiry],
            bids,
            [fees.poolFee, fees.creatorFee, fees.refundFee]
        );
        market.setResolverAndSyncCache(resolver);
        _activeMarkets.push(address(market));

        // The debt can't be incremented in the new market's constructor because until construction is complete,
        // the manager doesn't know its address in order to grant it permission.
        totalDeposited = totalDeposited.add(initialDeposit);
        _sUSD().transferFrom(msg.sender, address(market), initialDeposit);

        emit MarketCreated(address(market), msg.sender, oracleKey, strikePrice, biddingEnd, maturity, expiry);
        return market;
    }

    function resolveMarket(address market) external {
        require(_activeMarkets.contains(market), "Not an active market");
        BinaryOptionMarket(market).resolve();
        _activeMarkets.remove(market);
        _maturedMarkets.push(market);
    }

    function cancelMarket(address market) external notPaused {
        require(_activeMarkets.contains(market), "Not an active market");
        address creator = BinaryOptionMarket(market).creator();
        require(msg.sender == creator, "Sender not market creator");
        BinaryOptionMarket(market).cancel(msg.sender);
        _activeMarkets.remove(market);
        emit MarketCancelled(market);
    }

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

            // The market itself handles decrementing the total deposits.
            BinaryOptionMarket(market).expire(msg.sender);
            // Note that we required that the market is known, which guarantees
            // its index is defined and that the list of markets is not empty.
            _maturedMarkets.remove(market);
            emit MarketExpired(market);
        }
    }

    /* ---------- Upgrade and Administration ---------- */

    function setResolverAndSyncCacheOnMarkets(AddressResolver _resolver, BinaryOptionMarket[] calldata marketsToSync)
        external
        onlyOwner
    {
        for (uint i = 0; i < marketsToSync.length; i++) {
            marketsToSync[i].setResolverAndSyncCache(_resolver);
        }
    }

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

    function setMigratingManager(BinaryOptionMarketManager manager) public onlyOwner {
        _migratingManager = manager;
    }

    function migrateMarkets(
        BinaryOptionMarketManager receivingManager,
        bool active,
        BinaryOptionMarket[] calldata marketsToMigrate
    ) external onlyOwner {
        uint _numMarkets = marketsToMigrate.length;
        if (_numMarkets == 0) {
            return;
        }
        AddressListLib.AddressList storage markets = active ? _activeMarkets : _maturedMarkets;

        uint runningDepositTotal;
        for (uint i; i < _numMarkets; i++) {
            BinaryOptionMarket market = marketsToMigrate[i];
            require(_isKnownMarket(address(market)), "Market unknown.");

            // Remove it from our list and deposit total.
            markets.remove(address(market));
            runningDepositTotal = runningDepositTotal.add(market.deposited());

            // Prepare to transfer ownership to the new manager.
            market.nominateNewOwner(address(receivingManager));
        }
        // Deduct the total deposits of the migrated markets.
        totalDeposited = totalDeposited.sub(runningDepositTotal);
        emit MarketsMigrated(receivingManager, marketsToMigrate);

        // Now actually transfer the markets over to the new manager.
        receivingManager.receiveMarkets(active, marketsToMigrate);
    }

    function receiveMarkets(bool active, BinaryOptionMarket[] calldata marketsToReceive) external {
        require(msg.sender == address(_migratingManager), "Only permitted for migrating manager.");

        uint _numMarkets = marketsToReceive.length;
        if (_numMarkets == 0) {
            return;
        }
        AddressListLib.AddressList storage markets = active ? _activeMarkets : _maturedMarkets;

        uint runningDepositTotal;
        for (uint i; i < _numMarkets; i++) {
            BinaryOptionMarket market = marketsToReceive[i];
            require(!_isKnownMarket(address(market)), "Market already known.");

            market.acceptOwnership();
            markets.push(address(market));
            // Update the market with the new manager address,
            runningDepositTotal = runningDepositTotal.add(market.deposited());
        }
        totalDeposited = totalDeposited.add(runningDepositTotal);
        emit MarketsReceived(_migratingManager, marketsToReceive);
    }

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

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

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

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

    event MarketCreated(
        address market,
        address indexed creator,
        bytes32 indexed oracleKey,
        uint strikePrice,
        uint biddingEndDate,
        uint maturityDate,
        uint expiryDate
    );
    event MarketExpired(address market);
    event MarketCancelled(address market);
    event MarketsMigrated(BinaryOptionMarketManager receivingManager, BinaryOptionMarket[] markets);
    event MarketsReceived(BinaryOptionMarketManager migratingManager, BinaryOptionMarket[] markets);
    event MarketCreationEnabledUpdated(bool enabled);
    event MaxOraclePriceAgeUpdated(uint duration);
    event ExerciseDurationUpdated(uint duration);
    event ExpiryDurationUpdated(uint duration);
    event MaxTimeToMaturityUpdated(uint duration);
    event CreatorCapitalRequirementUpdated(uint value);
    event CreatorSkewLimitUpdated(uint value);
    event PoolFeeUpdated(uint fee);
    event CreatorFeeUpdated(uint fee);
    event RefundFeeUpdated(uint fee);
}

Contract ABI

[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address","name":"_resolver","type":"address"},{"internalType":"uint256","name":"_maxOraclePriceAge","type":"uint256"},{"internalType":"uint256","name":"_expiryDuration","type":"uint256"},{"internalType":"uint256","name":"_maxTimeToMaturity","type":"uint256"},{"internalType":"uint256","name":"_creatorCapitalRequirement","type":"uint256"},{"internalType":"uint256","name":"_creatorSkewLimit","type":"uint256"},{"internalType":"uint256","name":"_poolFee","type":"uint256"},{"internalType":"uint256","name":"_creatorFee","type":"uint256"},{"internalType":"uint256","name":"_refundFee","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"CreatorCapitalRequirementUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"fee","type":"uint256"}],"name":"CreatorFeeUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"CreatorSkewLimitUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"duration","type":"uint256"}],"name":"ExerciseDurationUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"duration","type":"uint256"}],"name":"ExpiryDurationUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"market","type":"address"}],"name":"MarketCancelled","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"market","type":"address"},{"indexed":true,"internalType":"address","name":"creator","type":"address"},{"indexed":true,"internalType":"bytes32","name":"oracleKey","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"strikePrice","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"biddingEndDate","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"maturityDate","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"expiryDate","type":"uint256"}],"name":"MarketCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"enabled","type":"bool"}],"name":"MarketCreationEnabledUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"market","type":"address"}],"name":"MarketExpired","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract BinaryOptionMarketManager","name":"receivingManager","type":"address"},{"indexed":false,"internalType":"contract BinaryOptionMarket[]","name":"markets","type":"address[]"}],"name":"MarketsMigrated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract BinaryOptionMarketManager","name":"migratingManager","type":"address"},{"indexed":false,"internalType":"contract BinaryOptionMarket[]","name":"markets","type":"address[]"}],"name":"MarketsReceived","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"duration","type":"uint256"}],"name":"MaxOraclePriceAgeUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"duration","type":"uint256"}],"name":"MaxTimeToMaturityUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldOwner","type":"address"},{"indexed":false,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnerChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnerNominated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"isPaused","type":"bool"}],"name":"PauseChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"fee","type":"uint256"}],"name":"PoolFeeUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"fee","type":"uint256"}],"name":"RefundFeeUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newBeneficiary","type":"address"}],"name":"SelfDestructBeneficiaryUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"selfDestructDelay","type":"uint256"}],"name":"SelfDestructInitiated","type":"event"},{"anonymous":false,"inputs":[],"name":"SelfDestructTerminated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"beneficiary","type":"address"}],"name":"SelfDestructed","type":"event"},{"constant":true,"inputs":[],"name":"MAX_ADDRESSES_FROM_RESOLVER","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"SELFDESTRUCT_DELAY","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"acceptOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"index","type":"uint256"},{"internalType":"uint256","name":"pageSize","type":"uint256"}],"name":"activeMarkets","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"market","type":"address"}],"name":"cancelMarket","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes32","name":"oracleKey","type":"bytes32"},{"internalType":"uint256","name":"strikePrice","type":"uint256"},{"internalType":"bool","name":"refundsEnabled","type":"bool"},{"internalType":"uint256[2]","name":"times","type":"uint256[2]"},{"internalType":"uint256[2]","name":"bids","type":"uint256[2]"}],"name":"createMarket","outputs":[{"internalType":"contract IBinaryOptionMarket","name":"","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"creatorLimits","outputs":[{"internalType":"uint256","name":"capitalRequirement","type":"uint256"},{"internalType":"uint256","name":"skewLimit","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"delta","type":"uint256"}],"name":"decrementTotalDeposited","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"durations","outputs":[{"internalType":"uint256","name":"maxOraclePriceAge","type":"uint256"},{"internalType":"uint256","name":"expiryDuration","type":"uint256"},{"internalType":"uint256","name":"maxTimeToMaturity","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address[]","name":"markets","type":"address[]"}],"name":"expireMarkets","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"fees","outputs":[{"internalType":"uint256","name":"poolFee","type":"uint256"},{"internalType":"uint256","name":"creatorFee","type":"uint256"},{"internalType":"uint256","name":"refundFee","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getResolverAddressesRequired","outputs":[{"internalType":"bytes32[24]","name":"addressesRequired","type":"bytes32[24]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"delta","type":"uint256"}],"name":"incrementTotalDeposited","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"initiateSelfDestruct","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"initiationTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"contract AddressResolver","name":"_resolver","type":"address"}],"name":"isResolverCached","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"lastPauseTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"marketCreationEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"index","type":"uint256"},{"internalType":"uint256","name":"pageSize","type":"uint256"}],"name":"maturedMarkets","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"contract BinaryOptionMarketManager","name":"receivingManager","type":"address"},{"internalType":"bool","name":"active","type":"bool"},{"internalType":"contract BinaryOptionMarket[]","name":"marketsToMigrate","type":"address[]"}],"name":"migrateMarkets","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"nominateNewOwner","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"nominatedOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"numActiveMarkets","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"numMaturedMarkets","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"bool","name":"active","type":"bool"},{"internalType":"contract BinaryOptionMarket[]","name":"marketsToReceive","type":"address[]"}],"name":"receiveMarkets","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"market","type":"address"}],"name":"resolveMarket","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"resolver","outputs":[{"internalType":"contract AddressResolver","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"resolverAddressesRequired","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"selfDestruct","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"selfDestructBeneficiary","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"selfDestructInitiated","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"_creatorCapitalRequirement","type":"uint256"}],"name":"setCreatorCapitalRequirement","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"_creatorFee","type":"uint256"}],"name":"setCreatorFee","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"_creatorSkewLimit","type":"uint256"}],"name":"setCreatorSkewLimit","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"_expiryDuration","type":"uint256"}],"name":"setExpiryDuration","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bool","name":"enabled","type":"bool"}],"name":"setMarketCreationEnabled","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"_maxOraclePriceAge","type":"uint256"}],"name":"setMaxOraclePriceAge","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"_maxTimeToMaturity","type":"uint256"}],"name":"setMaxTimeToMaturity","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"contract BinaryOptionMarketManager","name":"manager","type":"address"}],"name":"setMigratingManager","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bool","name":"_paused","type":"bool"}],"name":"setPaused","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"_poolFee","type":"uint256"}],"name":"setPoolFee","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"_refundFee","type":"uint256"}],"name":"setRefundFee","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"contract AddressResolver","name":"_resolver","type":"address"}],"name":"setResolverAndSyncCache","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"contract AddressResolver","name":"_resolver","type":"address"},{"internalType":"contract BinaryOptionMarket[]","name":"marketsToSync","type":"address[]"}],"name":"setResolverAndSyncCacheOnMarkets","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address payable","name":"_beneficiary","type":"address"}],"name":"setSelfDestructBeneficiary","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"terminateSelfDestruct","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"totalDeposited","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"}]

6011805460ff191660011790556101006040526b53797374656d53746174757360a01b60809081526814de5b9d1a1cd554d160ba1b60a0526c45786368616e6765526174657360981b60c0527f42696e6172794f7074696f6e4d61726b6574466163746f72790000000000000060e0526200007f90601890600462000c53565b503480156200008d57600080fd5b5060405162004350380380620043508339818101604052610140811015620000b457600080fd5b50805160208201516040808401516060850151608086015160a087015160c088015160e08901516101008a0151610120909a01518751610300810198899052999a989996989597949693959294919390918a9190601890819081845b8154815260200190600101908083116200011057508f93505050506001600160a01b03811662000187576040805162461bcd60e51b815260206004820152601960248201527f4f776e657220616464726573732063616e6e6f74206265203000000000000000604482015290519081900360640190fd5b600080546001600160a01b0319166001600160a01b038316908117825560408051928352602083019190915280517fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c9281900390910190a1506000546001600160a01b031662000232576040805162461bcd60e51b815260206004820152601160248201527013dddb995c881b5d5cdd081899481cd95d607a1b604482015290519081900360640190fd5b6000546001600160a01b031662000284576040805162461bcd60e51b815260206004820152601160248201527013dddb995c881b5d5cdd081899481cd95d607a1b604482015290519081900360640190fd5b60005460058054610100600160a81b0319166101006001600160a01b0390931692830217905560408051918252517fd5da63a0b864b315bc04128dedbc93888c8529ee6cf47ce664dc204339228c53916020908290030190a16000546001600160a01b03166200032f576040805162461bcd60e51b815260206004820152601160248201527013dddb995c881b5d5cdd081899481cd95d607a1b604482015290519081900360640190fd5b60005b6018811015620003975760008282601881106200034b57fe5b602002015114620003885760088282601881106200036557fe5b60209081029190910151825460018101845560009384529190922001556200038e565b62000397565b60010162000332565b5050600680546001600160a01b039092166001600160a01b03199283161790556000805490911633179055620003d6876001600160e01b036200049316565b620003ea886001600160e01b036200051916565b620003fe866001600160e01b036200059f16565b62000412856001600160e01b036200062516565b62000426846001600160e01b03620006ab16565b6200043a836001600160e01b03620007e416565b6200044e826001600160e01b036200097f16565b62000462816001600160e01b0362000b1a16565b5050600080546001600160a01b0319166001600160a01b0399909916989098179097555062000cb695505050505050565b6000546001600160a01b03163314620004de5760405162461bcd60e51b815260040180806020018281038252602f815260200180620042f9602f913960400191505060405180910390fd5b600d8190556040805182815290517ff378a0fd4ad3ffd9d7d50986f16b04acd2dc42691c4f412f34e8eefe883e66529181900360200190a150565b6000546001600160a01b03163314620005645760405162461bcd60e51b815260040180806020018281038252602f815260200180620042f9602f913960400191505060405180910390fd5b600c8190556040805182815290517f5a2f2eae84f9e787d8159d363a776fa2b61d084686190cdc5a2c1ea833480b099181900360200190a150565b6000546001600160a01b03163314620005ea5760405162461bcd60e51b815260040180806020018281038252602f815260200180620042f9602f913960400191505060405180910390fd5b600e8190556040805182815290517f6de18e808fc4e6cb9c8910cf4bdc188ddbbdab65faecff65dab871720e8484899181900360200190a150565b6000546001600160a01b03163314620006705760405162461bcd60e51b815260040180806020018281038252602f815260200180620042f9602f913960400191505060405180910390fd5b600f8190556040805182815290517fdf7a26ae2e2eb953b81fd76b72fcdc74ebff7c21faa8f8f55323183d9785f52d9181900360200190a150565b6000546001600160a01b03163314620006f65760405162461bcd60e51b815260040180806020018281038252602f815260200180620042f9602f913960400191505060405180910390fd5b7334a5ef81d18f3a305ae9c2d7df42beef4c79031c63907af6c06040518163ffffffff1660e01b815260040160206040518083038186803b1580156200073b57600080fd5b505af415801562000750573d6000803e3d6000fd5b505050506040513d60208110156200076757600080fd5b5051811115620007a95760405162461bcd60e51b815260040180806020018281038252602d815260200180620042ab602d913960400191505060405180910390fd5b60108190556040805182815290517fd39cfbe31b20dbb6d995a675cf5c369555bf8bb908b6efc03873907fe9e133cf9181900360200190a150565b6000546001600160a01b031633146200082f5760405162461bcd60e51b815260040180806020018281038252602f815260200180620042f9602f913960400191505060405180910390fd5b6000600960010154820190507334a5ef81d18f3a305ae9c2d7df42beef4c79031c63907af6c06040518163ffffffff1660e01b815260040160206040518083038186803b1580156200088057600080fd5b505af415801562000895573d6000803e3d6000fd5b505050506040513d6020811015620008ac57600080fd5b50518110620008ed5760405162461bcd60e51b8152600401808060200182810382526021815260200180620042d86021913960400191505060405180910390fd5b8060001062000943576040805162461bcd60e51b815260206004820152601a60248201527f546f74616c20666565206d757374206265206e6f6e7a65726f2e000000000000604482015290519081900360640190fd5b60098290556040805183815290517f7b30e8f8e3de254785fbcb3068449dc18060f1fdb37b02731ecada99a78492c39181900360200190a15050565b6000546001600160a01b03163314620009ca5760405162461bcd60e51b815260040180806020018281038252602f815260200180620042f9602f913960400191505060405180910390fd5b6000600960000154820190507334a5ef81d18f3a305ae9c2d7df42beef4c79031c63907af6c06040518163ffffffff1660e01b815260040160206040518083038186803b15801562000a1b57600080fd5b505af415801562000a30573d6000803e3d6000fd5b505050506040513d602081101562000a4757600080fd5b5051811062000a885760405162461bcd60e51b8152600401808060200182810382526021815260200180620042d86021913960400191505060405180910390fd5b8060001062000ade576040805162461bcd60e51b815260206004820152601a60248201527f546f74616c20666565206d757374206265206e6f6e7a65726f2e000000000000604482015290519081900360640190fd5b600a8290556040805183815290517f8c14462add32e0ae0fbfcf9e60711ecae573da337dc9127fff98fb7cfb3973b49181900360200190a15050565b6000546001600160a01b0316331462000b655760405162461bcd60e51b815260040180806020018281038252602f815260200180620042f9602f913960400191505060405180910390fd5b7334a5ef81d18f3a305ae9c2d7df42beef4c79031c63907af6c06040518163ffffffff1660e01b815260040160206040518083038186803b15801562000baa57600080fd5b505af415801562000bbf573d6000803e3d6000fd5b505050506040513d602081101562000bd657600080fd5b505181111562000c185760405162461bcd60e51b8152600401808060200182810382526028815260200180620043286028913960400191505060405180910390fd5b600b8190556040805182815290517f01634ac4e9f09be1ef87b8d09e14926870261dcb9a0929d2d6460af6e4c5ad1e9181900360200190a150565b826018810192821562000c84579160200282015b8281111562000c8457825182559160200191906001019062000c67565b5062000c9292915062000c96565b5090565b62000cb391905b8082111562000c92576000815560010162000c9d565b90565b6135e58062000cc66000396000f3fe608060405234801561001057600080fd5b50600436106102bb5760003560e01c806379ba509711610182578063aeab5849116100e9578063c095daf2116100a2578063e3235c911161007c578063e3235c9114610905578063e73efc9b1461090d578063fe40c47014610930578063ff50abdc14610956576102bb565b8063c095daf2146108c3578063c58aaae6146108e0578063c6c9d828146108e8576102bb565b8063aeab5849146107ea578063b8225dec14610807578063bd32aa441461080f578063bd6a10b814610817578063be5af9fe14610834578063c014fb8414610855576102bb565b80639af1d35a1161013b5780639af1d35a146107125780639cb8a26a1461071a578063a461fc8214610722578063ab49848c1461072a578063ac60c4861461076b578063adfd31af14610773576102bb565b806379ba50971461063557806389c6318d1461063d5780638da5cb5b146106b057806391b4ded9146106b857806394fcf3c3146106c05780639501dc87146106f5576102bb565b806339ab4c4111610226578063631e1444116101df578063631e14441461058a57806364af2d87146105b057806364cf34bd146105b85780636b3a0984146105d557806373b7de15146105f25780637859f4101461060f576102bb565b806339ab4c411461047d5780633be99e6f1461049c5780634a41d89d146104c257806353a47bb7146104e8578063543d6c74146104f05780635c975abb1461056e576102bb565b806316c38b3c1161027857806316c38b3c146103e557806317c70de4146104045780631f3f10b01461040c57806320714f88146104325780633278c9601461045857806336fd711e14610460576102bb565b806302610c50146102c057806303ff6018146102da57806304f3bcec146103615780630dd16fd51461038557806315502840146103a25780631627540c146103bf575b600080fd5b6102c861095e565b60408051918252519081900360200190f35b61035f600480360360608110156102f057600080fd5b6001600160a01b03823516916020810135151591810190606081016040820135600160201b81111561032157600080fd5b82018360208201111561033357600080fd5b803590602001918460208302840111600160201b8311171561035457600080fd5b509092509050610964565b005b610369610c77565b604080516001600160a01b039092168252519081900360200190f35b61035f6004803603602081101561039b57600080fd5b5035610c86565b61035f600480360360208110156103b857600080fd5b5035610e19565b61035f600480360360208110156103d557600080fd5b50356001600160a01b0316610e9d565b61035f600480360360208110156103fb57600080fd5b50351515610f3a565b6102c8610ff5565b61035f6004803603602081101561042257600080fd5b50356001600160a01b0316610ffb565b61035f6004803603602081101561044857600080fd5b50356001600160a01b0316611066565b61035f611166565b61035f6004803603602081101561047657600080fd5b50356111e9565b61035f6004803603602081101561049357600080fd5b5035151561131b565b61035f600480360360208110156104b257600080fd5b50356001600160a01b03166113bb565b6104ca611529565b60408051938452602084019290925282820152519081900360600190f35b610369611535565b61035f6004803603604081101561050657600080fd5b6001600160a01b038235169190810190604081016020820135600160201b81111561053057600080fd5b82018360208201111561054257600080fd5b803590602001918460208302840111600160201b8311171561056357600080fd5b509092509050611544565b61057661162f565b604080519115158252519081900360200190f35b610576600480360360208110156105a057600080fd5b50356001600160a01b0316611638565b610576611755565b61035f600480360360208110156105ce57600080fd5b503561175e565b61035f600480360360208110156105eb57600080fd5b50356117e2565b61035f6004803603602081101561060857600080fd5b50356118da565b61035f6004803603602081101561062557600080fd5b50356001600160a01b0316611a0c565b61035f611add565b6106606004803603604081101561065357600080fd5b5080359060200135611b99565b60408051602080825283518183015283519192839290830191858101910280838360005b8381101561069c578181015183820152602001610684565b505050509050019250505060405180910390f35b610369611bb6565b6102c8611bc5565b610369600480360360e08110156106d657600080fd5b508035906020810135906040810135151590606081019060a001611bcb565b61035f6004803603602081101561070b57600080fd5b503561217d565b6104ca612310565b61035f61231c565b6102c861246e565b610732612475565b604051808261030080838360005b83811015610758578181015183820152602001610740565b5050505090500191505060405180910390f35b6102c86124bf565b61035f6004803603604081101561078957600080fd5b813515159190810190604081016020820135600160201b8111156107ac57600080fd5b8201836020820111156107be57600080fd5b803590602001918460208302840111600160201b831117156107df57600080fd5b5090925090506124c5565b61035f6004803603602081101561080057600080fd5b50356126f6565b6105766127f0565b61035f6127f9565b61035f6004803603602081101561082d57600080fd5b503561288b565b61083c61290f565b6040805192835260208301919091528051918290030190f35b61035f6004803603602081101561086b57600080fd5b810190602081018135600160201b81111561088557600080fd5b82018360208201111561089757600080fd5b803590602001918460208302840111600160201b831117156108b857600080fd5b509092509050612918565b61035f600480360360208110156108d957600080fd5b5035612a4e565b610369612ad2565b6102c8600480360360208110156108fe57600080fd5b5035612ae6565b6102c8612b04565b6106606004803603604081101561092357600080fd5b5080359060200135612b09565b61035f6004803603602081101561094657600080fd5b50356001600160a01b0316612b1d565b6102c8612d31565b60135490565b6000546001600160a01b031633146109ad5760405162461bcd60e51b815260040180806020018281038252602f8152602001806134d0602f913960400191505060405180910390fd5b80806109b95750610c71565b6000846109c75760156109ca565b60135b90506000805b83811015610b485760008686838181106109e657fe5b905060200201356001600160a01b03169050610a0181612d37565b610a44576040805162461bcd60e51b815260206004820152600f60248201526e26b0b935b2ba103ab735b737bbb71760891b604482015290519081900360640190fd5b610a54848263ffffffff612d6116565b610ac9816001600160a01b031663eef49ee36040518163ffffffff1660e01b815260040160206040518083038186803b158015610a9057600080fd5b505afa158015610aa4573d6000803e3d6000fd5b505050506040513d6020811015610aba57600080fd5b5051849063ffffffff612ea316565b9250806001600160a01b0316631627540c8a6040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b03168152602001915050600060405180830381600087803b158015610b2357600080fd5b505af1158015610b37573d6000803e3d6000fd5b5050600190930192506109d0915050565b50601254610b5c908263ffffffff612efd16565b601255604080516001600160a01b038916815260208082018381529282018790527f3e429aa34462b428d3f7277acb67e1c83d80a57faab2a47924369b5060f35679928a92899289929060608301908590850280828437600083820152604051601f909101601f1916909201829003965090945050505050a16040805163adfd31af60e01b81528715156004820190815260248201928352604482018790526001600160a01b038a169263adfd31af928a928a928a92606401846020850280828437600081840152601f19601f820116905080830192505050945050505050600060405180830381600087803b158015610c5557600080fd5b505af1158015610c69573d6000803e3d6000fd5b505050505050505b50505050565b6006546001600160a01b031681565b6000546001600160a01b03163314610ccf5760405162461bcd60e51b815260040180806020018281038252602f8152602001806134d0602f913960400191505060405180910390fd5b6000600960000154820190507334a5ef81d18f3a305ae9c2d7df42beef4c79031c63907af6c06040518163ffffffff1660e01b815260040160206040518083038186803b158015610d1f57600080fd5b505af4158015610d33573d6000803e3d6000fd5b505050506040513d6020811015610d4957600080fd5b50518110610d885760405162461bcd60e51b815260040180806020018281038252602181526020018061346c6021913960400191505060405180910390fd5b80600010610ddd576040805162461bcd60e51b815260206004820152601a60248201527f546f74616c20666565206d757374206265206e6f6e7a65726f2e000000000000604482015290519081900360640190fd5b600a8290556040805183815290517f8c14462add32e0ae0fbfcf9e60711ecae573da337dc9127fff98fb7cfb3973b49181900360200190a15050565b6000546001600160a01b03163314610e625760405162461bcd60e51b815260040180806020018281038252602f8152602001806134d0602f913960400191505060405180910390fd5b600d8190556040805182815290517ff378a0fd4ad3ffd9d7d50986f16b04acd2dc42691c4f412f34e8eefe883e66529181900360200190a150565b6000546001600160a01b03163314610ee65760405162461bcd60e51b815260040180806020018281038252602f8152602001806134d0602f913960400191505060405180910390fd5b600180546001600160a01b0383166001600160a01b0319909116811790915560408051918252517f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce229181900360200190a150565b6000546001600160a01b03163314610f835760405162461bcd60e51b815260040180806020018281038252602f8152602001806134d0602f913960400191505060405180910390fd5b60035460ff1615158115151415610f9957610ff2565b6003805460ff1916821515179081905560ff1615610fb657426002555b6003546040805160ff90921615158252517f8fb6c181ee25a520cf3dd6565006ef91229fcfe5a989566c2a3b8c115570cec59181900360200190a15b50565b60045481565b6000546001600160a01b031633146110445760405162461bcd60e51b815260040180806020018281038252602f8152602001806134d0602f913960400191505060405180910390fd5b601780546001600160a01b0319166001600160a01b0392909216919091179055565b6000546001600160a01b031633146110af5760405162461bcd60e51b815260040180806020018281038252602f8152602001806134d0602f913960400191505060405180910390fd5b6001600160a01b03811661110a576040805162461bcd60e51b815260206004820152601c60248201527f42656e6566696369617279206d757374206e6f74206265207a65726f00000000604482015290519081900360640190fd5b600580546001600160a01b0383166101008102610100600160a81b03199092169190911790915560408051918252517fd5da63a0b864b315bc04128dedbc93888c8529ee6cf47ce664dc204339228c539181900360200190a150565b6000546001600160a01b031633146111af5760405162461bcd60e51b815260040180806020018281038252602f8152602001806134d0602f913960400191505060405180910390fd5b600060048190556005805460ff191690556040517f6adcc7125002935e0aa31697538ebbd65cfddf20431eb6ecdcfc3e238bfd082c9190a1565b6000546001600160a01b031633146112325760405162461bcd60e51b815260040180806020018281038252602f8152602001806134d0602f913960400191505060405180910390fd5b7334a5ef81d18f3a305ae9c2d7df42beef4c79031c63907af6c06040518163ffffffff1660e01b815260040160206040518083038186803b15801561127657600080fd5b505af415801561128a573d6000803e3d6000fd5b505050506040513d60208110156112a057600080fd5b50518111156112e05760405162461bcd60e51b81526004018080602001828103825260288152602001806135896028913960400191505060405180910390fd5b600b8190556040805182815290517f01634ac4e9f09be1ef87b8d09e14926870261dcb9a0929d2d6460af6e4c5ad1e9181900360200190a150565b6000546001600160a01b031633146113645760405162461bcd60e51b815260040180806020018281038252602f8152602001806134d0602f913960400191505060405180910390fd5b60115460ff16151581151514610ff2576011805482151560ff19909116811790915560408051918252517fcc590b6309435383b617aaa0cae6aba938f2ee471cfb539201dd7655a23caff99181900360200190a150565b6000546001600160a01b031633146114045760405162461bcd60e51b815260040180806020018281038252602f8152602001806134d0602f913960400191505060405180910390fd5b600680546001600160a01b0319166001600160a01b03831617905560005b6008548110156115255760006008828154811061143b57fe5b600091825260209182902001546006546040805163dacb2d0160e01b81526004810184905260248101829052601760448201527f5265736f6c766572206d697373696e6720746172676574000000000000000000606482015290519294506001600160a01b039091169263dacb2d0192608480840193829003018186803b1580156114c557600080fd5b505afa1580156114d9573d6000803e3d6000fd5b505050506040513d60208110156114ef57600080fd5b505160009182526007602052604090912080546001600160a01b0319166001600160a01b03909216919091179055600101611422565b5050565b600c54600d54600e5483565b6001546001600160a01b031681565b6000546001600160a01b0316331461158d5760405162461bcd60e51b815260040180806020018281038252602f8152602001806134d0602f913960400191505060405180910390fd5b60005b81811015610c71578282828181106115a457fe5b905060200201356001600160a01b03166001600160a01b0316633be99e6f856040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b03168152602001915050600060405180830381600087803b15801561160b57600080fd5b505af115801561161f573d6000803e3d6000fd5b5050600190920191506115909050565b60035460ff1681565b6006546000906001600160a01b0383811691161461165857506000611750565b60005b60085481101561174a5760006008828154811061167457fe5b6000918252602080832090910154808352600782526040928390205460065484516321f8a72160e01b81526004810184905294519295506001600160a01b03918216949116926321f8a72192602480840193829003018186803b1580156116da57600080fd5b505afa1580156116ee573d6000803e3d6000fd5b505050506040513d602081101561170457600080fd5b50516001600160a01b031614158061173157506000818152600760205260409020546001600160a01b0316155b1561174157600092505050611750565b5060010161165b565b50600190505b919050565b60115460ff1681565b6000546001600160a01b031633146117a75760405162461bcd60e51b815260040180806020018281038252602f8152602001806134d0602f913960400191505060405180910390fd5b600e8190556040805182815290517f6de18e808fc4e6cb9c8910cf4bdc188ddbbdab65faecff65dab871720e8484899181900360200190a150565b6117eb33612d37565b6118265760405162461bcd60e51b81526004018080602001828103825260218152602001806134af6021913960400191505060405180910390fd5b60035460ff16156118685760405162461bcd60e51b815260040180806020018281038252603c815260200180613524603c913960400191505060405180910390fd5b611870612f5a565b6001600160a01b031663086dabd16040518163ffffffff1660e01b815260040160006040518083038186803b1580156118a857600080fd5b505afa1580156118bc573d6000803e3d6000fd5b50506012546118d4925090508263ffffffff612efd16565b60125550565b6000546001600160a01b031633146119235760405162461bcd60e51b815260040180806020018281038252602f8152602001806134d0602f913960400191505060405180910390fd5b7334a5ef81d18f3a305ae9c2d7df42beef4c79031c63907af6c06040518163ffffffff1660e01b815260040160206040518083038186803b15801561196757600080fd5b505af415801561197b573d6000803e3d6000fd5b505050506040513d602081101561199157600080fd5b50518111156119d15760405162461bcd60e51b815260040180806020018281038252602d81526020018061343f602d913960400191505060405180910390fd5b60108190556040805182815290517fd39cfbe31b20dbb6d995a675cf5c369555bf8bb908b6efc03873907fe9e133cf9181900360200190a150565b611a1d60138263ffffffff612faf16565b611a65576040805162461bcd60e51b8152602060048201526014602482015273139bdd08185b881858dd1a5d99481b585c9ad95d60621b604482015290519081900360640190fd5b806001600160a01b0316632810e1d66040518163ffffffff1660e01b8152600401600060405180830381600087803b158015611aa057600080fd5b505af1158015611ab4573d6000803e3d6000fd5b50505050611acc816013612d6190919063ffffffff16565b610ff260158263ffffffff61301d16565b6001546001600160a01b03163314611b265760405162461bcd60e51b815260040180806020018281038252603581526020018061340a6035913960400191505060405180910390fd5b600054600154604080516001600160a01b03938416815292909116602083015280517fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c9281900390910190a160018054600080546001600160a01b03199081166001600160a01b03841617909155169055565b6060611bad6015848463ffffffff61306016565b90505b92915050565b6000546001600160a01b031681565b60025481565b60035460009060ff1615611c105760405162461bcd60e51b815260040180806020018281038252603c815260200180613524603c913960400191505060405180910390fd5b611c18612f5a565b6001600160a01b031663086dabd16040518163ffffffff1660e01b815260040160006040518083038186803b158015611c5057600080fd5b505afa158015611c64573d6000803e3d6000fd5b505060115460ff169150611cc19050576040805162461bcd60e51b815260206004820152601b60248201527f4d61726b6574206372656174696f6e2069732064697361626c65640000000000604482015290519081900360640190fd5b611cca86613136565b611d09576040805162461bcd60e51b815260206004820152600b60248201526a496e76616c6964206b657960a81b604482015290519081900360640190fd5b600e548335906020850135904201811115611d6b576040805162461bcd60e51b815260206004820152601e60248201527f4d6174757269747920746f6f2066617220696e20746865206675747572650000604482015290519081900360640190fd5b600d54600090611d8290839063ffffffff612ea316565b90506000611d9586356020880135612ea3565b9050834210611deb576040805162461bcd60e51b815260206004820152601960248201527f456e64206f662062696464696e67206861732070617373656400000000000000604482015290519081900360640190fd5b828410611e3f576040805162461bcd60e51b815260206004820181905260248201527f4d6174757269747920707265646174657320656e64206f662062696464696e67604482015290519081900360640190fd5b6000611e4961326a565b6001600160a01b031663130efa50336040518060400160405280600f600001548152602001600f600101548152508e8e8e60405180606001604052808d81526020018c81526020018b8152508e6040518060600160405280600960000154815260200160096001015481526020016009600201548152506040518963ffffffff1660e01b815260040180896001600160a01b03166001600160a01b0316815260200188600260200280838360005b83811015611f0f578181015183820152602001611ef7565b505050509050018781526020018681526020018515151515815260200184600360200280838360005b83811015611f50578181015183820152602001611f38565b5050505090500183600260200280828437600081840152601f19601f82011690508083019250505082600360200280838360005b83811015611f9c578181015183820152602001611f84565b5050505090500198505050505050505050602060405180830381600087803b158015611fc757600080fd5b505af1158015611fdb573d6000803e3d6000fd5b505050506040513d6020811015611ff157600080fd5b505160065460408051633be99e6f60e01b81526001600160a01b039283166004820152905192935090831691633be99e6f9160248082019260009290919082900301818387803b15801561204457600080fd5b505af1158015612058573d6000803e3d6000fd5b5050505061207081601361301d90919063ffffffff16565b601254612083908363ffffffff612ea316565b60125561208e6132ae565b604080516323b872dd60e01b81523360048201526001600160a01b03848116602483015260448201869052915192909116916323b872dd916064808201926020929091908290030181600087803b1580156120e857600080fd5b505af11580156120fc573d6000803e3d6000fd5b505050506040513d602081101561211257600080fd5b5050604080516001600160a01b0383168152602081018c9052808201879052606081018690526080810185905290518c9133917fbcd154709bbe69680012cadcd07d57bd4a0ec64a033c2a3e31d2d0fadb38d3a89181900360a00190a39a9950505050505050505050565b6000546001600160a01b031633146121c65760405162461bcd60e51b815260040180806020018281038252602f8152602001806134d0602f913960400191505060405180910390fd5b6000600960010154820190507334a5ef81d18f3a305ae9c2d7df42beef4c79031c63907af6c06040518163ffffffff1660e01b815260040160206040518083038186803b15801561221657600080fd5b505af415801561222a573d6000803e3d6000fd5b505050506040513d602081101561224057600080fd5b5051811061227f5760405162461bcd60e51b815260040180806020018281038252602181526020018061346c6021913960400191505060405180910390fd5b806000106122d4576040805162461bcd60e51b815260206004820152601a60248201527f546f74616c20666565206d757374206265206e6f6e7a65726f2e000000000000604482015290519081900360640190fd5b60098290556040805183815290517f7b30e8f8e3de254785fbcb3068449dc18060f1fdb37b02731ecada99a78492c39181900360200190a15050565b600954600a54600b5483565b6000546001600160a01b031633146123655760405162461bcd60e51b815260040180806020018281038252602f8152602001806134d0602f913960400191505060405180910390fd5b60055460ff166123bc576040805162461bcd60e51b815260206004820152601f60248201527f53656c66204465737472756374206e6f742079657420696e6974696174656400604482015290519081900360640190fd5b426224ea006004540110612417576040805162461bcd60e51b815260206004820152601b60248201527f53656c662064657374727563742064656c6179206e6f74206d65740000000000604482015290519081900360640190fd5b600554604080516101009092046001600160a01b03168252517f8a09e1677ced846cb537dc2b172043bd05a1a81ad7e0033a7ef8ba762df990b7916020908290030190a160055461010090046001600160a01b0316ff5b6224ea0081565b61247d6133ea565b60005b6008548110156124bb576008818154811061249757fe5b90600052602060002001548282601881106124ae57fe5b6020020152600101612480565b5090565b60155490565b6017546001600160a01b0316331461250e5760405162461bcd60e51b81526004018080602001828103825260258152602001806134ff6025913960400191505060405180910390fd5b808061251a57506126f1565b60008461252857601561252b565b60135b90506000805b8381101561265957600086868381811061254757fe5b905060200201356001600160a01b0316905061256281612d37565b156125ac576040805162461bcd60e51b815260206004820152601560248201527426b0b935b2ba1030b63932b0b23c9035b737bbb71760591b604482015290519081900360640190fd5b806001600160a01b03166379ba50976040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156125e757600080fd5b505af11580156125fb573d6000803e3d6000fd5b50505050612612818561301d90919063ffffffff16565b61264e816001600160a01b031663eef49ee36040518163ffffffff1660e01b815260040160206040518083038186803b158015610a9057600080fd5b925050600101612531565b5060125461266d908263ffffffff612ea316565b601255601754604080516001600160a01b0390921680835260208084018381529284018890527fea7a4e14e72ba7db7e2fd406278900badf50b2ce7d9def39d613cc08054c537b9391928992899290919060608301908590850280828437600083820152604051601f909101601f1916909201829003965090945050505050a15050505b505050565b61270760133363ffffffff612faf16565b6127425760405162461bcd60e51b815260040180806020018281038252602281526020018061348d6022913960400191505060405180910390fd5b60035460ff16156127845760405162461bcd60e51b815260040180806020018281038252603c815260200180613524603c913960400191505060405180910390fd5b61278c612f5a565b6001600160a01b031663086dabd16040518163ffffffff1660e01b815260040160006040518083038186803b1580156127c457600080fd5b505afa1580156127d8573d6000803e3d6000fd5b50506012546118d4925090508263ffffffff612ea316565b60055460ff1681565b6000546001600160a01b031633146128425760405162461bcd60e51b815260040180806020018281038252602f8152602001806134d0602f913960400191505060405180910390fd5b426004556005805460ff19166001179055604080516224ea00815290517fcbd94ca75b8dc45c9d80c77e851670e78843c0d75180cb81db3e2158228fa9a69181900360200190a1565b6000546001600160a01b031633146128d45760405162461bcd60e51b815260040180806020018281038252602f8152602001806134d0602f913960400191505060405180910390fd5b600c8190556040805182815290517f5a2f2eae84f9e787d8159d363a776fa2b61d084686190cdc5a2c1ea833480b099181900360200190a150565b600f5460105482565b60035460ff161561295a5760405162461bcd60e51b815260040180806020018281038252603c815260200180613524603c913960400191505060405180910390fd5b60005b818110156126f157600083838381811061297357fe5b905060200201356001600160a01b03169050806001600160a01b031663c8db233e336040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b03168152602001915050600060405180830381600087803b1580156129dd57600080fd5b505af11580156129f1573d6000803e3d6000fd5b50505050612a09816015612d6190919063ffffffff16565b604080516001600160a01b038316815290517f16e62064e42f5aec62df22ae895ef539f153e0d4ea290e2cc4e0e8f708f2fbbc9181900360200190a15060010161295d565b6000546001600160a01b03163314612a975760405162461bcd60e51b815260040180806020018281038252602f8152602001806134d0602f913960400191505060405180910390fd5b600f8190556040805182815290517fdf7a26ae2e2eb953b81fd76b72fcdc74ebff7c21faa8f8f55323183d9785f52d9181900360200190a150565b60055461010090046001600160a01b031681565b60088181548110612af357fe5b600091825260209091200154905081565b601881565b6060611bad6013848463ffffffff61306016565b60035460ff1615612b5f5760405162461bcd60e51b815260040180806020018281038252603c815260200180613524603c913960400191505060405180910390fd5b612b7060138263ffffffff612faf16565b612bb8576040805162461bcd60e51b8152602060048201526014602482015273139bdd08185b881858dd1a5d99481b585c9ad95d60621b604482015290519081900360640190fd5b6000816001600160a01b03166302d05d3f6040518163ffffffff1660e01b815260040160206040518083038186803b158015612bf357600080fd5b505afa158015612c07573d6000803e3d6000fd5b505050506040513d6020811015612c1d57600080fd5b50519050336001600160a01b03821614612c7e576040805162461bcd60e51b815260206004820152601960248201527f53656e646572206e6f74206d61726b65742063726561746f7200000000000000604482015290519081900360640190fd5b6040805163130cffa560e21b815233600482015290516001600160a01b03841691634c33fe9491602480830192600092919082900301818387803b158015612cc557600080fd5b505af1158015612cd9573d6000803e3d6000fd5b50505050612cf1826013612d6190919063ffffffff16565b604080516001600160a01b038416815290517f996fafab197beb99fff6fdc975bb6cf90352f2c733c76ef37c2e27f17d7d424b9181900360200190a15050565b60125481565b6000612d4a60138363ffffffff612faf16565b80611bb05750611bb060158363ffffffff612faf16565b612d6b8282612faf565b612db3576040805162461bcd60e51b815260206004820152601460248201527322b632b6b2b73a103737ba1034b7103634b9ba1760611b604482015290519081900360640190fd5b6001600160a01b0381166000908152600183016020526040902054825460001901808214612e52576000846000018281548110612dec57fe5b60009182526020909120015485546001600160a01b0390911691508190869085908110612e1557fe5b600091825260208083209190910180546001600160a01b0319166001600160a01b0394851617905592909116815260018601909152604090208290555b8354849080612e5d57fe5b60008281526020808220830160001990810180546001600160a01b03191690559092019092556001600160a01b0394909416815260019490940190925250506040812055565b600082820183811015611bad576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b600082821115612f54576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b6000612faa6b53797374656d53746174757360a01b6040518060400160405280601c81526020017f4d697373696e672053797374656d5374617475732061646472657373000000008152506132f7565b905090565b8154600090612fc057506000611bb0565b6001600160a01b0382166000908152600184016020526040902054801515806130155750826001600160a01b031684600001600081548110612ffe57fe5b6000918252602090912001546001600160a01b0316145b949350505050565b81546001600160a01b03909116600081815260018085016020908152604083208590559084018555938152929092200180546001600160a01b0319169091179055565b825460609083830190811115613074575083545b83811161309157505060408051600081526020810190915261312f565b6040805185830380825260208082028301019092526060908280156130c0578160200160208202803883390190505b50905060005b828110156131295787600001878201815481106130df57fe5b9060005260206000200160009054906101000a90046001600160a01b031682828151811061310957fe5b6001600160a01b03909216602092830291909101909101526001016130c6565b50925050505b9392505050565b6000806131416133a1565b9050806001600160a01b031663ac82f608846040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b15801561318757600080fd5b505afa15801561319b573d6000803e3d6000fd5b505050506040513d60208110156131b157600080fd5b5051156132615782631cd554d160e21b14156131d1576000915050611750565b6000816001600160a01b031663728dec29856040518263ffffffff1660e01b81526004018082815260200191505060806040518083038186803b15801561321757600080fd5b505afa15801561322b573d6000803e3d6000fd5b505050506040513d608081101561324157600080fd5b50519050801561325657600092505050611750565b600192505050611750565b50600092915050565b6000612faa7f42696e6172794f7074696f6e4d61726b6574466163746f727900000000000000604051806060016040528060298152602001613560602991396132f7565b6000612faa6814de5b9d1a1cd554d160ba1b6040518060400160405280601981526020017f4d697373696e672053796e7468735553442061646472657373000000000000008152505b6000828152600760205260408120546001600160a01b031682816133995760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561335e578181015183820152602001613346565b50505050905090810190601f16801561338b5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b509392505050565b6000612faa6c45786368616e6765526174657360981b604051806040016040528060158152602001744d697373696e672045786368616e6765526174657360581b8152506132f7565b604051806103000160405280601890602082028038833950919291505056fe596f75206d757374206265206e6f6d696e61746564206265666f726520796f752063616e20616363657074206f776e65727368697043726561746f7220736b6577206c696d6974206d757374206265206e6f2067726561746572207468616e20312e546f74616c20666565206d757374206265206c657373207468616e20313030252e5065726d6974746564206f6e6c7920666f7220616374697665206d61726b6574732e5065726d6974746564206f6e6c7920666f72206b6e6f776e206d61726b6574732e4f6e6c792074686520636f6e7472616374206f776e6572206d617920706572666f726d207468697320616374696f6e4f6e6c79207065726d697474656420666f72206d6967726174696e67206d616e616765722e5468697320616374696f6e2063616e6e6f7420626520706572666f726d6564207768696c652074686520636f6e7472616374206973207061757365644d697373696e672042696e6172794f7074696f6e4d61726b6574466163746f72792061646472657373526566756e6420666565206d757374206265206e6f2067726561746572207468616e20313030252ea265627a7a723158208c6f2d5c104e7d0f7eabee5658bc77bb767f6feff5010f95ff782e5b5e584fd464736f6c6343000510003243726561746f7220736b6577206c696d6974206d757374206265206e6f2067726561746572207468616e20312e546f74616c20666565206d757374206265206c657373207468616e20313030252e4f6e6c792074686520636f6e7472616374206f776e6572206d617920706572666f726d207468697320616374696f6e526566756e6420666565206d757374206265206e6f2067726561746572207468616e20313030252e000000000000000000000000b64ff7a4a33acdf48d97dab0d764afd0f6176882000000000000000000000000c6f404c96aa136b0ba11d40db17394f09b0f20f10000000000000000000000000000000000000000000000000000000000001c200000000000000000000000000000000000000000000000000000000000eff1000000000000000000000000000000000000000000000000000000000003c2670000000000000000000000000000000000000000000000003635c9adc5dea0000000000000000000000000000000000000000000000000000000b1a2bc2ec50000000000000000000000000000000000000000000000000000001c6bf52634000000000000000000000000000000000000000000000000000000071afd498d000000000000000000000000000000000000000000000000000000b1a2bc2ec50000

Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)

000000000000000000000000b64ff7a4a33acdf48d97dab0d764afd0f6176882000000000000000000000000c6f404c96aa136b0ba11d40db17394f09b0f20f10000000000000000000000000000000000000000000000000000000000001c200000000000000000000000000000000000000000000000000000000000eff1000000000000000000000000000000000000000000000000000000000003c2670000000000000000000000000000000000000000000000003635c9adc5dea0000000000000000000000000000000000000000000000000000000b1a2bc2ec50000000000000000000000000000000000000000000000000000001c6bf52634000000000000000000000000000000000000000000000000000000071afd498d000000000000000000000000000000000000000000000000000000b1a2bc2ec50000

-----Decoded View---------------
Arg [0] : _owner (address): 0xb64ff7a4a33acdf48d97dab0d764afd0f6176882
Arg [1] : _resolver (address): 0xc6f404c96aa136b0ba11d40db17394f09b0f20f1
Arg [2] : _maxOraclePriceAge (uint256): 7200
Arg [3] : _expiryDuration (uint256): 15724800
Arg [4] : _maxTimeToMaturity (uint256): 63072000
Arg [5] : _creatorCapitalRequirement (uint256): 1000000000000000000000
Arg [6] : _creatorSkewLimit (uint256): 50000000000000000
Arg [7] : _poolFee (uint256): 8000000000000000
Arg [8] : _creatorFee (uint256): 2000000000000000
Arg [9] : _refundFee (uint256): 50000000000000000

-----Encoded View---------------
10 Constructor Arguments found :
Arg [0] : 000000000000000000000000b64ff7a4a33acdf48d97dab0d764afd0f6176882
Arg [1] : 000000000000000000000000c6f404c96aa136b0ba11d40db17394f09b0f20f1
Arg [2] : 0000000000000000000000000000000000000000000000000000000000001c20
Arg [3] : 0000000000000000000000000000000000000000000000000000000000eff100
Arg [4] : 0000000000000000000000000000000000000000000000000000000003c26700
Arg [5] : 00000000000000000000000000000000000000000000003635c9adc5dea00000
Arg [6] : 00000000000000000000000000000000000000000000000000b1a2bc2ec50000
Arg [7] : 000000000000000000000000000000000000000000000000001c6bf526340000
Arg [8] : 00000000000000000000000000000000000000000000000000071afd498d0000
Arg [9] : 00000000000000000000000000000000000000000000000000b1a2bc2ec50000


Library Used

SafeDecimalMath : 0x34a5ef81d18f3a305ae9c2d7df42beef4c79031c

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