ETH Price: $3,256.35 (+2.18%)

Contract

0xe5109CC91F2c236Fbee3752AF06dC92d4BDddC84
 

Overview

ETH Balance

0 ETH

ETH Value

$0.00

Sponsored

Transaction Hash
Method
Block
From
To
Value
0x6080604084699272022-05-17 13:54:41707 days ago1652795681IN
 Create: RangedMarketMastercopy
0 ETH0.000002510.001

Latest 25 internal transactions (View All)

Advanced mode:
Parent Transaction Hash Block From To Value
1075550882023-07-30 9:22:33268 days ago1690708953
0xe5109CC9...d4BDddC84
0 ETH
1075550882023-07-30 9:22:33268 days ago1690708953
0xe5109CC9...d4BDddC84
0 ETH
1075550882023-07-30 9:22:33268 days ago1690708953
0xe5109CC9...d4BDddC84
0 ETH
1075550882023-07-30 9:22:33268 days ago1690708953
0xe5109CC9...d4BDddC84
0 ETH
1075550882023-07-30 9:22:33268 days ago1690708953
0xe5109CC9...d4BDddC84
0 ETH
1075550882023-07-30 9:22:33268 days ago1690708953
0xe5109CC9...d4BDddC84
0 ETH
1075550882023-07-30 9:22:33268 days ago1690708953
0xe5109CC9...d4BDddC84
0 ETH
1075550882023-07-30 9:22:33268 days ago1690708953
0xe5109CC9...d4BDddC84
0 ETH
1075550882023-07-30 9:22:33268 days ago1690708953
0xe5109CC9...d4BDddC84
0 ETH
1075550882023-07-30 9:22:33268 days ago1690708953
0xe5109CC9...d4BDddC84
0 ETH
1075550882023-07-30 9:22:33268 days ago1690708953
0xe5109CC9...d4BDddC84
0 ETH
1075550882023-07-30 9:22:33268 days ago1690708953
0xe5109CC9...d4BDddC84
0 ETH
1075532112023-07-30 8:19:59268 days ago1690705199
0xe5109CC9...d4BDddC84
0 ETH
1075532112023-07-30 8:19:59268 days ago1690705199
0xe5109CC9...d4BDddC84
0 ETH
1075532112023-07-30 8:19:59268 days ago1690705199
0xe5109CC9...d4BDddC84
0 ETH
1075532112023-07-30 8:19:59268 days ago1690705199
0xe5109CC9...d4BDddC84
0 ETH
1075532112023-07-30 8:19:59268 days ago1690705199
0xe5109CC9...d4BDddC84
0 ETH
1075532112023-07-30 8:19:59268 days ago1690705199
0xe5109CC9...d4BDddC84
0 ETH
1075532112023-07-30 8:19:59268 days ago1690705199
0xe5109CC9...d4BDddC84
0 ETH
1075532112023-07-30 8:19:59268 days ago1690705199
0xe5109CC9...d4BDddC84
0 ETH
1075532112023-07-30 8:19:59268 days ago1690705199
0xe5109CC9...d4BDddC84
0 ETH
1075532112023-07-30 8:19:59268 days ago1690705199
0xe5109CC9...d4BDddC84
0 ETH
1075531792023-07-30 8:18:55268 days ago1690705135
0xe5109CC9...d4BDddC84
0 ETH
1075531792023-07-30 8:18:55268 days ago1690705135
0xe5109CC9...d4BDddC84
0 ETH
1075531792023-07-30 8:18:55268 days ago1690705135
0xe5109CC9...d4BDddC84
0 ETH
View All Internal Transactions

Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
RangedMarketMastercopy

Compiler Version
v0.8.4+commit.c7e474f2

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity Standard Json-Input format)

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

// Inheritance
import "./RangedMarket.sol";

contract RangedMarketMastercopy is RangedMarket {
    constructor() {
        // Freeze mastercopy on deployment so it can never be initialized with real arguments
        initialized = true;
    }
}

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

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

// Internal references
import "./RangedPosition.sol";
import "./RangedMarketsAMM.sol";
import "../interfaces/IPositionalMarket.sol";
import "../interfaces/IPositionalMarketManager.sol";

contract RangedMarket {
    using SafeERC20 for IERC20;

    enum Position {In, Out}

    IPositionalMarket public leftMarket;
    IPositionalMarket public rightMarket;

    struct Positions {
        RangedPosition inp;
        RangedPosition outp;
    }

    Positions public positions;

    RangedMarketsAMM public rangedMarketsAMM;

    bool public resolved = false;

    uint finalPrice;

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

    bool public initialized = false;

    function initialize(
        address _leftMarket,
        address _rightMarket,
        address _in,
        address _out,
        address _rangedMarketsAMM
    ) external {
        require(!initialized, "Ranged Market already initialized");
        initialized = true;
        leftMarket = IPositionalMarket(_leftMarket);
        rightMarket = IPositionalMarket(_rightMarket);
        positions.inp = RangedPosition(_in);
        positions.outp = RangedPosition(_out);
        rangedMarketsAMM = RangedMarketsAMM(_rangedMarketsAMM);
    }

    function mint(
        uint value,
        Position _position,
        address minter
    ) external onlyAMM {
        if (value == 0) {
            return;
        }
        _mint(minter, value, _position);
    }

    function _mint(
        address minter,
        uint amount,
        Position _position
    ) internal {
        if (_position == Position.In) {
            positions.inp.mint(minter, amount);
        } else {
            positions.outp.mint(minter, amount);
        }
        emit Mint(minter, amount, _position);
    }

    function burnIn(uint value, address claimant) external onlyAMM {
        if (value == 0) {
            return;
        }
        (IPosition up, ) = IPositionalMarket(leftMarket).getOptions();
        IERC20(address(up)).safeTransfer(msg.sender, value / 2);

        (, IPosition down1) = IPositionalMarket(rightMarket).getOptions();
        IERC20(address(down1)).safeTransfer(msg.sender, value / 2);

        positions.inp.burn(claimant, value);
    }

    function burnOut(uint value, address claimant) external onlyAMM {
        if (value == 0) {
            return;
        }
        (, IPosition down) = IPositionalMarket(leftMarket).getOptions();
        IERC20(address(down)).safeTransfer(msg.sender, value);

        (IPosition up1, ) = IPositionalMarket(rightMarket).getOptions();
        IERC20(address(up1)).safeTransfer(msg.sender, value);

        positions.outp.burn(claimant, value);
    }

    function _burn(
        uint value,
        Position _position,
        address claimant
    ) private {
        if (value == 0) {
            return;
        }
        if (_position == Position.Out) {
            (, IPosition down) = IPositionalMarket(leftMarket).getOptions();
            IERC20(address(down)).safeTransfer(msg.sender, value);

            (IPosition up1, ) = IPositionalMarket(rightMarket).getOptions();
            IERC20(address(up1)).safeTransfer(msg.sender, value);

            positions.outp.burn(claimant, value);
        } else {
            (IPosition up, ) = IPositionalMarket(leftMarket).getOptions();
            IERC20(address(up)).safeTransfer(msg.sender, value / 2);

            (, IPosition down1) = IPositionalMarket(rightMarket).getOptions();
            IERC20(address(down1)).safeTransfer(msg.sender, value / 2);

            positions.inp.burn(claimant, value);
        }
        emit Burn(claimant, value, _position);
    }

    function canExercisePositions() external view returns (bool) {
        if (!leftMarket.resolved() && !leftMarket.canResolve()) {
            return false;
        }
        if (!rightMarket.resolved() && !rightMarket.canResolve()) {
            return false;
        }

        uint inBalance = positions.inp.balanceOf(msg.sender);
        uint outBalance = positions.outp.balanceOf(msg.sender);

        if (inBalance == 0 && outBalance == 0) {
            return false;
        }

        return true;
    }

    function exercisePositions() external {
        if (leftMarket.canResolve()) {
            IPositionalMarketManager(rangedMarketsAMM.thalesAmm().manager()).resolveMarket(address(leftMarket));
        }
        if (rightMarket.canResolve()) {
            IPositionalMarketManager(rangedMarketsAMM.thalesAmm().manager()).resolveMarket(address(rightMarket));
        }
        require(leftMarket.resolved() && rightMarket.resolved(), "Left or Right market not resolved yet!");

        uint inBalance = positions.inp.balanceOf(msg.sender);
        uint outBalance = positions.outp.balanceOf(msg.sender);

        require(inBalance != 0 || outBalance != 0, "Nothing to exercise");

        if (!resolved) {
            resolveMarket();
        }

        // Each option only needs to be exercised if the account holds any of it.
        if (inBalance != 0) {
            positions.inp.burn(msg.sender, inBalance);
        }
        if (outBalance != 0) {
            positions.outp.burn(msg.sender, outBalance);
        }

        Position result = Position.Out;
        if ((leftMarket.result() == IPositionalMarket.Side.Up) && (rightMarket.result() == IPositionalMarket.Side.Down)) {
            result = Position.In;
        }

        // Only pay out the side that won.
        uint payout = (result == Position.In) ? inBalance : outBalance;
        if (payout != 0) {
            rangedMarketsAMM.transferSusdTo(msg.sender, payout);
        }
        emit Exercised(msg.sender, payout, result);
    }

    function canResolve() external view returns (bool) {
        // The markets must be resolved
        if (!leftMarket.resolved() && !leftMarket.canResolve()) {
            return false;
        }
        if (!rightMarket.resolved() && !rightMarket.canResolve()) {
            return false;
        }

        return !resolved;
    }

    function resolveMarket() public {
        // The markets must be resolved
        if (leftMarket.canResolve()) {
            IPositionalMarketManager(rangedMarketsAMM.thalesAmm().manager()).resolveMarket(address(leftMarket));
        }
        if (rightMarket.canResolve()) {
            IPositionalMarketManager(rangedMarketsAMM.thalesAmm().manager()).resolveMarket(address(rightMarket));
        }
        require(leftMarket.resolved() && rightMarket.resolved(), "Left or Right market not resolved yet!");
        require(!resolved, "Already resolved!");

        if (positions.inp.totalSupply() > 0 || positions.outp.totalSupply() > 0) {
            leftMarket.exerciseOptions();
            rightMarket.exerciseOptions();
        }
        resolved = true;

        if (rangedMarketsAMM.sUSD().balanceOf(address(this)) > 0) {
            rangedMarketsAMM.sUSD().transfer(address(rangedMarketsAMM), rangedMarketsAMM.sUSD().balanceOf(address(this)));
        }

        (, , uint _finalPrice) = leftMarket.getOracleDetails();
        finalPrice = _finalPrice;
        emit Resolved(result(), finalPrice);
    }

    function result() public view returns (Position) {
        Position result = Position.Out;
        if ((leftMarket.result() == IPositionalMarket.Side.Up) && (rightMarket.result() == IPositionalMarket.Side.Down)) {
            result = Position.In;
        }
        return result;
    }

    function withdrawCollateral(address recipient) external onlyAMM {
        rangedMarketsAMM.sUSD().transfer(recipient, rangedMarketsAMM.sUSD().balanceOf(address(this)));
    }

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

    event Mint(address minter, uint amount, Position _position);
    event Burn(address burner, uint amount, Position _position);
    event Exercised(address exerciser, uint amount, Position _position);
    event Resolved(Position winningPosition, uint finalPrice);
}

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

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

File 5 of 27 : RangedPosition.sol
// in position collaterized by 0.5 UP on the left leg and 0.5 DOWN on the right leg

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

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

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

contract RangedPosition is IERC20 {
    /* ========== STATE VARIABLES ========== */

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

    RangedMarket public rangedMarket;

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

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

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

    address public thalesRangedAMM;
    /* ========== CONSTRUCTOR ========== */

    bool public initialized = false;

    function initialize(
        address market,
        string calldata _name,
        string calldata _symbol,
        address _thalesRangedAMM
    ) external {
        require(!initialized, "Ranged Market already initialized");
        initialized = true;
        rangedMarket = RangedMarket(market);
        name = _name;
        symbol = _symbol;
        // add through constructor
        thalesRangedAMM = _thalesRangedAMM;
    }

    function allowance(address owner, address spender) external view override returns (uint256) {
        if (spender == thalesRangedAMM) {
            return type(uint256).max;
        } else {
            return allowances[owner][spender];
        }
    }

    function burn(address claimant, uint amount) external onlyRangedMarket {
        balanceOf[claimant] = balanceOf[claimant] - amount;
        totalSupply = totalSupply - amount;
        emit Burned(claimant, amount);
        emit Transfer(claimant, address(0), amount);
    }

    function mint(address minter, uint amount) external onlyRangedMarket {
        _requireMinimumAmount(amount);
        totalSupply = totalSupply + amount;
        balanceOf[minter] = balanceOf[minter] + amount; // Increment rather than assigning since a transfer may have occurred.
        emit Mint(minter, amount);
        emit Transfer(address(0), minter, amount);
    }

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

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

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

        balanceOf[_from] = fromBalance - _value;
        balanceOf[_to] = balanceOf[_to] + _value;

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

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

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

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

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

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

    modifier onlyRangedMarket {
        require(msg.sender == address(rangedMarket), "only the Ranged Market may perform these methods");
        _;
    }

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

    event Mint(address minter, uint amount);
    event Burned(address burner, uint amount);
}

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

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

// interfaces
import "../interfaces/IPriceFeed.sol";
import "../interfaces/IThalesAMM.sol";

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

import "./RangedPosition.sol";
import "./RangedPosition.sol";
import "./RangedMarket.sol";
import "../interfaces/IPositionalMarket.sol";
import "../interfaces/IStakingThales.sol";

contract RangedMarketsAMM is Initializable, ProxyOwned, ProxyPausable, ProxyReentrancyGuard {
    using AddressSetLib for AddressSetLib.AddressSet;
    using SafeERC20Upgradeable for IERC20Upgradeable;

    uint private constant ONE = 1e18;
    uint private constant ONE_PERCENT = 1e16;

    IThalesAMM public thalesAmm;

    uint public rangedAmmFee;

    mapping(address => mapping(address => address)) public createdRangedMarkets;
    AddressSetLib.AddressSet internal _knownMarkets;

    address public rangedMarketMastercopy;
    address public rangedPositionMastercopy;

    IERC20Upgradeable public sUSD;

    mapping(address => uint) public spentOnMarket;

    // IMPORTANT: AMM risks only half or the payout effectively, but it risks the whole amount on price movements
    uint public capPerMarket;

    uint public minSupportedPrice;
    uint public maxSupportedPrice;

    address public safeBox;
    uint public safeBoxImpact;

    uint public minimalDifBetweenStrikes;

    IStakingThales public stakingThales;

    uint public maximalDifBetweenStrikes;

    function initialize(
        address _owner,
        IThalesAMM _thalesAmm,
        uint _rangedAmmFee,
        uint _capPerMarket,
        IERC20Upgradeable _sUSD,
        address _safeBox,
        uint _safeBoxImpact
    ) public initializer {
        setOwner(_owner);
        initNonReentrant();
        thalesAmm = _thalesAmm;
        capPerMarket = _capPerMarket;
        rangedAmmFee = _rangedAmmFee;
        sUSD = _sUSD;
        safeBox = _safeBox;
        safeBoxImpact = _safeBoxImpact;

        sUSD.approve(address(thalesAmm), type(uint256).max);
    }

    function createRangedMarket(address leftMarket, address rightMarket) external nonReentrant notPaused {
        require(canCreateRangedMarket(leftMarket, rightMarket), "Can't create such a ranged market!");

        RangedMarket rm = RangedMarket(Clones.clone(rangedMarketMastercopy));
        createdRangedMarkets[leftMarket][rightMarket] = address(rm);

        RangedPosition inp = RangedPosition(Clones.clone(rangedPositionMastercopy));
        inp.initialize(address(rm), "Position IN", "IN", address(this));

        RangedPosition outp = RangedPosition(Clones.clone(rangedPositionMastercopy));
        outp.initialize(address(rm), "Position OUT", "OUT", address(this));

        rm.initialize(leftMarket, rightMarket, address(inp), address(outp), address(this));

        _knownMarkets.add(address(rm));

        emit RangedMarketCreated(address(rm), leftMarket, rightMarket);
    }

    function canCreateRangedMarket(address leftMarket, address rightMarket) public view returns (bool) {
        if (!thalesAmm.isMarketInAMMTrading(leftMarket) || !thalesAmm.isMarketInAMMTrading(rightMarket)) {
            return false;
        }
        (uint maturityLeft, ) = IPositionalMarket(leftMarket).times();
        (uint maturityRight, ) = IPositionalMarket(rightMarket).times();
        if (maturityLeft != maturityRight) {
            return false;
        }

        (bytes32 leftkey, uint leftstrikePrice, ) = IPositionalMarket(leftMarket).getOracleDetails();
        (bytes32 rightkey, uint rightstrikePrice, ) = IPositionalMarket(rightMarket).getOracleDetails();
        if (leftkey != rightkey) {
            return false;
        }
        if (leftstrikePrice >= rightstrikePrice) {
            return false;
        }

        if (!(((ONE + minimalDifBetweenStrikes * ONE_PERCENT) * leftstrikePrice) / ONE < rightstrikePrice)) {
            return false;
        }

        if (!(((ONE + maximalDifBetweenStrikes * ONE_PERCENT) * leftstrikePrice) / ONE > rightstrikePrice)) {
            return false;
        }

        if (createdRangedMarkets[leftMarket][rightMarket] != address(0)) {
            return false;
        }

        return true;
    }

    function _availableToBuyFromAMMOnlyRanged(RangedMarket rangedMarket, RangedMarket.Position position)
        internal
        view
        knownRangedMarket(address(rangedMarket))
        returns (uint)
    {
        if (position == RangedMarket.Position.Out) {
            return type(uint256).max;
        } else {
            return _availableToBuyFromAMMInOnlyRanged(rangedMarket);
        }
    }

    function availableToBuyFromAMM(RangedMarket rangedMarket, RangedMarket.Position position)
        public
        view
        knownRangedMarket(address(rangedMarket))
        returns (uint)
    {
        if (position == RangedMarket.Position.Out) {
            return _availableToBuyFromAMMOut(rangedMarket);
        } else {
            return _availableToBuyFromAMMIn(rangedMarket);
        }
    }

    function _availableToBuyFromAMMOut(RangedMarket rangedMarket) internal view returns (uint) {
        uint availableLeft = thalesAmm.availableToBuyFromAMM(address(rangedMarket.leftMarket()), IThalesAMM.Position.Down);
        uint availableRight = thalesAmm.availableToBuyFromAMM(address(rangedMarket.rightMarket()), IThalesAMM.Position.Up);
        return availableLeft < availableRight ? availableLeft : availableRight;
    }

    function _availableToBuyFromAMMIn(RangedMarket rangedMarket) internal view returns (uint) {
        uint availableLeft = thalesAmm.availableToBuyFromAMM(address(rangedMarket.leftMarket()), IThalesAMM.Position.Up);
        uint availableRight = thalesAmm.availableToBuyFromAMM(address(rangedMarket.rightMarket()), IThalesAMM.Position.Down);
        uint availableThalesAMM = (availableLeft < availableRight ? availableLeft : availableRight) * 2;
        uint availableRangedAmm = _availableToBuyFromAMMInOnlyRanged(rangedMarket);
        return availableThalesAMM > availableRangedAmm ? availableRangedAmm : availableThalesAMM;
    }

    function _availableToBuyFromAMMInOnlyRanged(RangedMarket rangedMarket) internal view returns (uint) {
        uint leftoverOnMarket = capPerMarket - spentOnMarket[address(rangedMarket)];
        uint minPrice = minInPrice(rangedMarket);
        if (minPrice <= minSupportedPrice || minPrice >= maxSupportedPrice) {
            return 0;
        }
        uint rangedAMMRisk = ONE - minInPrice(rangedMarket);
        uint availableRangedAmm = (leftoverOnMarket * ONE) / rangedAMMRisk;
        return availableRangedAmm;
    }

    function minInPrice(RangedMarket rangedMarket) public view knownRangedMarket(address(rangedMarket)) returns (uint) {
        uint leftQuote = thalesAmm.buyFromAmmQuote(address(rangedMarket.leftMarket()), IThalesAMM.Position.Up, ONE);
        uint rightQuote = thalesAmm.buyFromAmmQuote(address(rangedMarket.rightMarket()), IThalesAMM.Position.Down, ONE);
        uint quotedPrice = ((leftQuote + rightQuote) - ((ONE - leftQuote) + (ONE - rightQuote))) / 2;
        return quotedPrice;
    }

    function buyFromAmmQuote(
        RangedMarket rangedMarket,
        RangedMarket.Position position,
        uint amount
    ) public view knownRangedMarket(address(rangedMarket)) returns (uint) {
        (uint sUSDPaid, , ) = buyFromAmmQuoteDetailed(rangedMarket, position, amount);
        uint basePrice = (sUSDPaid * ONE) / amount;
        if (basePrice < minSupportedPrice || basePrice >= ONE) {
            return 0;
        }
        return sUSDPaid;
    }

    function buyFromAmmQuoteDetailed(
        RangedMarket rangedMarket,
        RangedMarket.Position position,
        uint amount
    )
        public
        view
        knownRangedMarket(address(rangedMarket))
        returns (
            uint,
            uint,
            uint
        )
    {
        if (position == RangedMarket.Position.Out) {
            uint leftQuote = thalesAmm.buyFromAmmQuote(address(rangedMarket.leftMarket()), IThalesAMM.Position.Down, amount);
            uint rightQuote = thalesAmm.buyFromAmmQuote(address(rangedMarket.rightMarket()), IThalesAMM.Position.Up, amount);
            uint quoteWithoutFees = leftQuote + rightQuote;
            uint quoteWithFees = (quoteWithoutFees * (rangedAmmFee + ONE)) / ONE;
            return (quoteWithFees, leftQuote, rightQuote);
        } else {
            uint leftQuote =
                thalesAmm.buyFromAmmQuote(address(rangedMarket.leftMarket()), IThalesAMM.Position.Up, amount / 2);
            uint rightQuote =
                thalesAmm.buyFromAmmQuote(address(rangedMarket.rightMarket()), IThalesAMM.Position.Down, amount / 2);
            uint quoteWithoutFees = ((leftQuote + rightQuote) - ((amount / 2 - leftQuote) + (amount / 2 - rightQuote)));
            uint quoteWithFees = (quoteWithoutFees * (rangedAmmFee + safeBoxImpact + ONE)) / ONE;
            return (quoteWithFees, leftQuote, rightQuote);
        }
    }

    function buyFromAMM(
        RangedMarket rangedMarket,
        RangedMarket.Position position,
        uint amount,
        uint expectedPayout,
        uint additionalSlippage
    ) public knownRangedMarket(address(rangedMarket)) nonReentrant notPaused {
        require(amount <= _availableToBuyFromAMMOnlyRanged(rangedMarket, position), "Not enough liquidity");

        (uint sUSDPaid, uint leftQuote, uint rightQuote) = buyFromAmmQuoteDetailed(rangedMarket, position, amount);

        uint basePrice = (sUSDPaid * ONE) / amount;
        require(basePrice > minSupportedPrice && basePrice < ONE, "Invalid price");
        require((sUSDPaid * ONE) / expectedPayout <= (ONE + additionalSlippage), "Slippage too high");

        sUSD.safeTransferFrom(msg.sender, address(this), sUSDPaid);

        address target;
        (RangedPosition inp, RangedPosition outp) = rangedMarket.positions();

        if (position == RangedMarket.Position.Out) {
            target = address(outp);

            _buyOUT(rangedMarket, amount, leftQuote, rightQuote, additionalSlippage);

            rangedMarket.mint(amount, RangedMarket.Position.Out, msg.sender);
        } else {
            target = address(inp);

            _buyIN(rangedMarket, amount, leftQuote, rightQuote, additionalSlippage);

            rangedMarket.mint(amount, RangedMarket.Position.In, msg.sender);
            _updateSpentOnMarketAndSafeBoxOnBuy(address(rangedMarket), amount, sUSDPaid);
        }
        if (address(stakingThales) != address(0)) {
            stakingThales.updateVolume(msg.sender, sUSDPaid);
        }
        emit BoughtFromAmm(msg.sender, address(rangedMarket), position, amount, sUSDPaid, address(sUSD), target);
    }

    function _buyOUT(
        RangedMarket rangedMarket,
        uint amount,
        uint leftQuote,
        uint rightQuote,
        uint additionalSlippage
    ) internal {
        thalesAmm.buyFromAMM(
            address(rangedMarket.leftMarket()),
            IThalesAMM.Position.Down,
            amount,
            leftQuote,
            additionalSlippage
        );

        thalesAmm.buyFromAMM(
            address(rangedMarket.rightMarket()),
            IThalesAMM.Position.Up,
            amount,
            rightQuote,
            additionalSlippage
        );
        (, IPosition down) = IPositionalMarket(rangedMarket.leftMarket()).getOptions();
        IERC20Upgradeable(address(down)).safeTransfer(address(rangedMarket), amount);

        (IPosition up1, ) = IPositionalMarket(rangedMarket.rightMarket()).getOptions();
        IERC20Upgradeable(address(up1)).safeTransfer(address(rangedMarket), amount);
    }

    function _buyIN(
        RangedMarket rangedMarket,
        uint amount,
        uint leftQuote,
        uint rightQuote,
        uint additionalSlippage
    ) internal {
        thalesAmm.buyFromAMM(
            address(rangedMarket.leftMarket()),
            IThalesAMM.Position.Up,
            amount / 2,
            leftQuote,
            additionalSlippage
        );

        thalesAmm.buyFromAMM(
            address(rangedMarket.rightMarket()),
            IThalesAMM.Position.Down,
            amount / 2,
            rightQuote,
            additionalSlippage
        );
        (IPosition up, ) = IPositionalMarket(rangedMarket.leftMarket()).getOptions();
        IERC20Upgradeable(address(up)).safeTransfer(address(rangedMarket), amount / 2);

        (, IPosition down1) = IPositionalMarket(rangedMarket.rightMarket()).getOptions();
        IERC20Upgradeable(address(down1)).safeTransfer(address(rangedMarket), amount / 2);
    }

    function _updateSpentOnMarketAndSafeBoxOnBuy(
        address rangedMarket,
        uint amount,
        uint sUSDPaid
    ) internal {
        uint safeBoxShare = sUSDPaid - ((sUSDPaid * ONE) / (ONE + safeBoxImpact));
        if (safeBoxImpact > 0) {
            sUSD.transfer(safeBox, safeBoxShare);
        } else {
            safeBoxShare = 0;
        }

        spentOnMarket[rangedMarket] = spentOnMarket[rangedMarket] + amount + safeBoxShare - sUSDPaid;
    }

    function availableToSellToAMM(RangedMarket rangedMarket, RangedMarket.Position position)
        public
        view
        knownRangedMarket(address(rangedMarket))
        returns (uint)
    {
        if (position == RangedMarket.Position.Out) {
            uint availableLeft =
                thalesAmm.availableToSellToAMM(address(rangedMarket.leftMarket()), IThalesAMM.Position.Down);
            uint availableRight =
                thalesAmm.availableToSellToAMM(address(rangedMarket.rightMarket()), IThalesAMM.Position.Up);
            return availableLeft < availableRight ? availableLeft : availableRight;
        } else {
            uint availableLeft = thalesAmm.availableToSellToAMM(address(rangedMarket.leftMarket()), IThalesAMM.Position.Up);
            uint availableRight =
                thalesAmm.availableToSellToAMM(address(rangedMarket.rightMarket()), IThalesAMM.Position.Down);
            uint min = availableLeft < availableRight ? availableLeft : availableRight;
            return min * 2;
        }
    }

    function sellToAmmQuote(
        RangedMarket rangedMarket,
        RangedMarket.Position position,
        uint amount
    ) public view knownRangedMarket(address(rangedMarket)) returns (uint) {
        (uint pricePaid, , ) = sellToAmmQuoteDetailed(rangedMarket, position, amount);
        return pricePaid;
    }

    function sellToAmmQuoteDetailed(
        RangedMarket rangedMarket,
        RangedMarket.Position position,
        uint amount
    )
        public
        view
        knownRangedMarket(address(rangedMarket))
        returns (
            uint,
            uint,
            uint
        )
    {
        if (position == RangedMarket.Position.Out) {
            uint leftQuote = thalesAmm.sellToAmmQuote(address(rangedMarket.leftMarket()), IThalesAMM.Position.Down, amount);
            uint rightQuote = thalesAmm.sellToAmmQuote(address(rangedMarket.rightMarket()), IThalesAMM.Position.Up, amount);
            uint quoteWithoutFees = leftQuote + rightQuote;
            uint quoteWithFees = (quoteWithoutFees * (ONE - rangedAmmFee)) / ONE;
            return (quoteWithFees, leftQuote, rightQuote);
        } else {
            uint leftQuote =
                thalesAmm.sellToAmmQuote(address(rangedMarket.leftMarket()), IThalesAMM.Position.Up, amount / 2);
            uint rightQuote =
                thalesAmm.sellToAmmQuote(address(rangedMarket.rightMarket()), IThalesAMM.Position.Down, amount / 2);
            uint quoteWithoutFees = ((leftQuote + rightQuote) - ((amount / 2 - leftQuote) + (amount / 2 - rightQuote)));
            uint quoteWithFees = (quoteWithoutFees * (ONE - rangedAmmFee - safeBoxImpact)) / ONE;
            return (quoteWithFees, leftQuote, rightQuote);
        }
    }

    function sellToAMM(
        RangedMarket rangedMarket,
        RangedMarket.Position position,
        uint amount,
        uint expectedPayout,
        uint additionalSlippage
    ) public knownRangedMarket(address(rangedMarket)) nonReentrant notPaused {
        uint availableToSellToAMMATM = availableToSellToAMM(rangedMarket, position);
        require(availableToSellToAMMATM > 0 && amount <= availableToSellToAMMATM, "Not enough liquidity.");

        (uint pricePaid, uint leftQuote, uint rightQuote) = sellToAmmQuoteDetailed(rangedMarket, position, amount);
        require((expectedPayout * ONE) / pricePaid <= (ONE + additionalSlippage), "Slippage too high");

        address target;
        (RangedPosition inp, RangedPosition outp) = rangedMarket.positions();

        if (position == RangedMarket.Position.Out) {
            target = address(outp);
            rangedMarket.burnOut(amount, msg.sender);
            _sellOUT(rangedMarket, amount, leftQuote, rightQuote, additionalSlippage);
        } else {
            target = address(inp);
            rangedMarket.burnIn(amount, msg.sender);

            _sellIN(rangedMarket, amount, leftQuote, rightQuote, additionalSlippage);

            _updateSpentOnMarketAndSafeBoxOnSell(amount, rangedMarket, pricePaid);
        }

        sUSD.safeTransfer(msg.sender, pricePaid);

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

        emit SoldToAMM(msg.sender, address(rangedMarket), position, amount, pricePaid, address(sUSD), target);
    }

    function _sellOUT(
        RangedMarket rangedMarket,
        uint amount,
        uint leftQuote,
        uint rightQuote,
        uint additionalSlippage
    ) internal {
        //TODO: remove this after Positional Market have the correct AMM address
        (, IPosition down) = IPositionalMarket(rangedMarket.leftMarket()).getOptions();
        (IPosition up, ) = IPositionalMarket(rangedMarket.rightMarket()).getOptions();
        IERC20Upgradeable(address(down)).approve(address(thalesAmm), type(uint256).max);
        IERC20Upgradeable(address(up)).approve(address(thalesAmm), type(uint256).max);
        //TODO: to here

        thalesAmm.sellToAMM(
            address(rangedMarket.leftMarket()),
            IThalesAMM.Position.Down,
            amount,
            leftQuote,
            additionalSlippage
        );

        thalesAmm.sellToAMM(
            address(rangedMarket.rightMarket()),
            IThalesAMM.Position.Up,
            amount,
            rightQuote,
            additionalSlippage
        );
    }

    function _sellIN(
        RangedMarket rangedMarket,
        uint amount,
        uint leftQuote,
        uint rightQuote,
        uint additionalSlippage
    ) internal {
        //TODO: remove this after Positional Market have the correct AMM address
        (IPosition up, ) = IPositionalMarket(rangedMarket.leftMarket()).getOptions();
        (, IPosition down) = IPositionalMarket(rangedMarket.rightMarket()).getOptions();
        IERC20Upgradeable(address(down)).approve(address(thalesAmm), type(uint256).max);
        IERC20Upgradeable(address(up)).approve(address(thalesAmm), type(uint256).max);
        //TODO: to here
        thalesAmm.sellToAMM(
            address(rangedMarket.leftMarket()),
            IThalesAMM.Position.Up,
            amount / 2,
            leftQuote,
            additionalSlippage
        );

        thalesAmm.sellToAMM(
            address(rangedMarket.rightMarket()),
            IThalesAMM.Position.Down,
            amount / 2,
            rightQuote,
            additionalSlippage
        );
    }

    function _updateSpentOnMarketAndSafeBoxOnSell(
        uint amount,
        RangedMarket rangedMarket,
        uint sUSDPaid
    ) internal {
        uint safeBoxShare = ((sUSDPaid * ONE) / (ONE - safeBoxImpact)) - sUSDPaid;

        if (safeBoxImpact > 0) {
            sUSD.transfer(safeBox, safeBoxShare);
        } else {
            safeBoxShare = 0;
        }

        // consider that amount might be 18 decimals
        if (amount > (spentOnMarket[address(rangedMarket)] + sUSDPaid + safeBoxShare)) {
            spentOnMarket[address(rangedMarket)] = 0;
        } else {
            spentOnMarket[address(rangedMarket)] = spentOnMarket[address(rangedMarket)] + sUSDPaid + safeBoxShare - amount;
        }
    }

    function transferSusdTo(address receiver, uint amount) external {
        require(_knownMarkets.contains(msg.sender), "Not a known ranged market");
        sUSD.safeTransfer(receiver, amount);
    }

    function retrieveSUSD(address payable account) external onlyOwner {
        sUSD.transfer(account, sUSD.balanceOf(address(this)));
    }

    function retrieveSUSDAmount(address payable account, uint amount) external onlyOwner {
        sUSD.transfer(account, amount);
    }

    function setRangedMarketMastercopy(address _rangedMarketMastercopy) external onlyOwner {
        rangedMarketMastercopy = _rangedMarketMastercopy;
    }

    function setRangedPositionMastercopy(address _rangedPositionMastercopy) external onlyOwner {
        rangedPositionMastercopy = _rangedPositionMastercopy;
    }

    function setMinMaxSupportedPrice(
        uint _minSupportedPrice,
        uint _maxSupportedPrice,
        uint _minDiffBetweenStrikes,
        uint _maxDiffBetweenStrikes
    ) public onlyOwner {
        minSupportedPrice = _minSupportedPrice;
        maxSupportedPrice = _maxSupportedPrice;
        minimalDifBetweenStrikes = _minDiffBetweenStrikes;
        maximalDifBetweenStrikes = _maxDiffBetweenStrikes;
        emit SetMinSupportedPrice(minSupportedPrice);
        emit SetMaxSupportedPrice(maxSupportedPrice);
        emit SetMinimalDifBetweenStrikes(minimalDifBetweenStrikes);
        emit SetMaxinalDifBetweenStrikes(maximalDifBetweenStrikes);
    }

    function setSafeBoxData(address _safeBox, uint _safeBoxImpact) external onlyOwner {
        safeBoxImpact = _safeBoxImpact;
        safeBox = _safeBox;
        emit SetSafeBoxImpact(_safeBoxImpact);
        emit SetSafeBox(_safeBox);
    }

    function setCapPerMarketAndRangedAMMFee(uint _capPerMarket, uint _rangedAMMFee) external onlyOwner {
        capPerMarket = _capPerMarket;
        rangedAmmFee = _rangedAMMFee;
        emit SetCapPerMarket(capPerMarket);
        emit SetRangedAmmFee(rangedAmmFee);
    }

    function setThalesAMM(address _thalesAMM) external onlyOwner {
        thalesAmm = IThalesAMM(_thalesAMM);
        sUSD.approve(address(thalesAmm), type(uint256).max);
        emit SetThalesAMM(_thalesAMM);
    }

    function setStakingThales(IStakingThales _stakingThales) external onlyOwner {
        stakingThales = _stakingThales;
        emit SetStakingThales(address(_stakingThales));
    }

    modifier knownRangedMarket(address market) {
        require(_knownMarkets.contains(market), "Not a known ranged market");
        _;
    }

    event SoldToAMM(
        address seller,
        address market,
        RangedMarket.Position position,
        uint amount,
        uint sUSDPaid,
        address susd,
        address asset
    );
    event BoughtFromAmm(
        address buyer,
        address market,
        RangedMarket.Position position,
        uint amount,
        uint sUSDPaid,
        address susd,
        address asset
    );

    event SetAmm(address amm);
    event SetSUSD(address sUSD);
    event SetThalesAMM(address amm);
    event RangedMarketCreated(address market, address leftMarket, address rightMarket);
    event SetSafeBoxImpact(uint _safeBoxImpact);
    event SetSafeBox(address _safeBox);
    event SetMinSupportedPrice(uint _spread);
    event SetMaxSupportedPrice(uint _spread);
    event SetMinimalDifBetweenStrikes(uint _spread);
    event SetMaxinalDifBetweenStrikes(uint _spread);
    event SetCapPerMarket(uint capPerMarket);
    event SetRangedAmmFee(uint rangedAmmFee);
    event SetStakingThales(address _stakingThales);
}

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

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

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

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

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

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

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

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

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

    function deposited() external view returns (uint);

    function creator() external view returns (address);

    function resolved() external view returns (bool);

    function phase() external view returns (Phase);

    function oraclePrice() external view returns (uint);

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

    function canResolve() external view returns (bool);

    function result() external view returns (Side);

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

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

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

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

    function mint(uint value) external;

    function exerciseOptions() external returns (uint);

    function burnOptions(uint amount) external;

    function burnOptionsMaximum() external;
}

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

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

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

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

    function capitalRequirement() external view returns (uint);

    function marketCreationEnabled() external view returns (bool);

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

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

    function totalDeposited() external view returns (uint);

    function numActiveMarkets() external view returns (uint);

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

    function numMaturedMarkets() external view returns (uint);

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

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

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

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

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

    function resolveMarket(address market) external;

    function expireMarkets(address[] calldata market) external;

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

File 9 of 27 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Address.sol)

pragma solidity ^0.8.0;

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

        uint256 size;
        assembly {
            size := extcodesize(account)
        }
        return size > 0;
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

import "./IPositionalMarket.sol";

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

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

    function getTotalSupply() external view returns (uint);

}

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

interface IPriceFeed {
     // Structs
    struct RateAndUpdatedTime {
        uint216 rate;
        uint40 time;
    }
    
    // Mutative functions
    function addAggregator(bytes32 currencyKey, address aggregatorAddress) external;

    function removeAggregator(bytes32 currencyKey) external;

    // Views

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

/**
 * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
 * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an
 * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
 * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
 *
 * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
 * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
 *
 * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
 * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
 *
 * [CAUTION]
 * ====
 * Avoid leaving a contract uninitialized.
 *
 * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
 * contract, which may impact the proxy. To initialize the implementation contract, you can either invoke the
 * initializer manually, or you can include a constructor to automatically mark it as initialized when it is deployed:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * /// @custom:oz-upgrades-unsafe-allow constructor
 * constructor() initializer {}
 * ```
 * ====
 */
abstract contract Initializable {
    /**
     * @dev Indicates that the contract has been initialized.
     */
    bool private _initialized;

    /**
     * @dev Indicates that the contract is in the process of being initialized.
     */
    bool private _initializing;

    /**
     * @dev Modifier to protect an initializer function from being invoked twice.
     */
    modifier initializer() {
        // If the contract is initializing we ignore whether _initialized is set in order to support multiple
        // inheritance patterns, but we only do this in the context of a constructor, because in other contexts the
        // contract may have been reentered.
        require(_initializing ? _isConstructor() : !_initialized, "Initializable: contract is already initialized");

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

        _;

        if (isTopLevelCall) {
            _initializing = false;
        }
    }

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20Upgradeable {
    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

    bool private _paused;

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

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

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

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

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

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

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

File 19 of 27 : Clones.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (proxy/Clones.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

interface IThalesAMM {
    enum Position {Up, Down}

    function manager() external view returns (address);

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

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

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

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

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

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

    function isMarketInAMMTrading(address market) external view returns (bool);
}

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

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

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

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

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

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

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

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

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

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

    modifier onlyOwner {
        _onlyOwner();
        _;
    }

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

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

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

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

// Clone of syntetix contract without constructor

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

    

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

        // Set our paused state.
        paused = _paused;

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

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

    event PauseChanged(bool isPaused);

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

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

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

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

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

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

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

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

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

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

interface IStakingThales {
    function updateVolume(address account, uint amount) external;
    
    /* ========== VIEWS / VARIABLES ========== */
    function totalStakedAmount() external view returns (uint);

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

    function currentPeriodRewards() external view returns (uint);

    function currentPeriodFees() external view returns (uint);

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

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

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

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

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

    function getContractRewardFunds() external view returns (uint);

    function getContractFeeFunds() external view returns (uint);

    
}

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

pragma solidity ^0.8.0;

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

        uint256 size;
        assembly {
            size := extcodesize(account)
        }
        return size > 0;
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Contract Security Audit

Contract ABI

[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"burner","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"enum RangedMarket.Position","name":"_position","type":"uint8"}],"name":"Burn","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"exerciser","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"enum RangedMarket.Position","name":"_position","type":"uint8"}],"name":"Exercised","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"minter","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"enum RangedMarket.Position","name":"_position","type":"uint8"}],"name":"Mint","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"enum RangedMarket.Position","name":"winningPosition","type":"uint8"},{"indexed":false,"internalType":"uint256","name":"finalPrice","type":"uint256"}],"name":"Resolved","type":"event"},{"inputs":[{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"address","name":"claimant","type":"address"}],"name":"burnIn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"address","name":"claimant","type":"address"}],"name":"burnOut","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"canExercisePositions","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"canResolve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"exercisePositions","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_leftMarket","type":"address"},{"internalType":"address","name":"_rightMarket","type":"address"},{"internalType":"address","name":"_in","type":"address"},{"internalType":"address","name":"_out","type":"address"},{"internalType":"address","name":"_rangedMarketsAMM","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"initialized","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"leftMarket","outputs":[{"internalType":"contract IPositionalMarket","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"enum RangedMarket.Position","name":"_position","type":"uint8"},{"internalType":"address","name":"minter","type":"address"}],"name":"mint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"positions","outputs":[{"internalType":"contract RangedPosition","name":"inp","type":"address"},{"internalType":"contract RangedPosition","name":"outp","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rangedMarketsAMM","outputs":[{"internalType":"contract RangedMarketsAMM","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"resolveMarket","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"resolved","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"result","outputs":[{"internalType":"enum RangedMarket.Position","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rightMarket","outputs":[{"internalType":"contract IPositionalMarket","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"}],"name":"withdrawCollateral","outputs":[],"stateMutability":"nonpayable","type":"function"}]

60806040526004805460ff60a01b191690556006805460ff1916905534801561002757600080fd5b506006805460ff19166001179055612c01806100446000396000f3fe608060405234801561001057600080fd5b50600436106101005760003560e01c80638033491c11610097578063ba5b798211610066578063ba5b7982146101f4578063d06a750c1461022e578063f8fdd17c14610236578063fe5072321461024957600080fd5b80638033491c146101b3578063928d300e146101c657806392902ea9146101d9578063ac3791e3146101ec57600080fd5b80632b9b55b3116100d35780632b9b55b31461017a5780633f6fa6551461018257806359f7f7fe14610196578063653721471461019e57600080fd5b8063059692b21461010557806307b00005146101355780631459457a14610148578063158ef93e1461015d575b600080fd5b600054610118906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b600454610118906001600160a01b031681565b61015b61015636600461285e565b61025c565b005b60065461016a9060ff1681565b604051901515815260200161012c565b61015b61032b565b60045461016a90600160a01b900460ff1681565b61016a610e31565b6101a6611194565b60405161012c9190612a68565b61015b6101c13660046129ac565b6112fa565b61015b6101d4366004612826565b61133e565b600154610118906001600160a01b031681565b61016a611563565b60025460035461020e916001600160a01b03908116911682565b604080516001600160a01b0393841681529290911660208301520161012c565b61015b6117b6565b61015b610244366004612988565b612102565b61015b610257366004612988565b6122c9565b60065460ff16156102be5760405162461bcd60e51b815260206004820152602160248201527f52616e676564204d61726b657420616c726561647920696e697469616c697a656044820152601960fa1b60648201526084015b60405180910390fd5b6006805460ff19166001908117909155600080546001600160a01b039788166001600160a01b031991821617909155815495871695811695909517905560028054938616938516939093179092556003805491851691841691909117905560048054919093169116179055565b60008054906101000a90046001600160a01b03166001600160a01b031663ac3791e36040518163ffffffff1660e01b815260040160206040518083038186803b15801561037757600080fd5b505afa15801561038b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103af91906128ce565b156104fd576004805460408051632773edf160e11b815290516001600160a01b0390921692634ee7dbe2928282019260209290829003018186803b1580156103f657600080fd5b505afa15801561040a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061042e9190612842565b6001600160a01b031663481c6a756040518163ffffffff1660e01b815260040160206040518083038186803b15801561046657600080fd5b505afa15801561047a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061049e9190612842565b6000546040516307859f4160e41b81526001600160a01b039182166004820152911690637859f41090602401600060405180830381600087803b1580156104e457600080fd5b505af11580156104f8573d6000803e3d6000fd5b505050505b600160009054906101000a90046001600160a01b03166001600160a01b031663ac3791e36040518163ffffffff1660e01b815260040160206040518083038186803b15801561054b57600080fd5b505afa15801561055f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061058391906128ce565b156106d1576004805460408051632773edf160e11b815290516001600160a01b0390921692634ee7dbe2928282019260209290829003018186803b1580156105ca57600080fd5b505afa1580156105de573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106029190612842565b6001600160a01b031663481c6a756040518163ffffffff1660e01b815260040160206040518083038186803b15801561063a57600080fd5b505afa15801561064e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106729190612842565b6001546040516307859f4160e41b81526001600160a01b039182166004820152911690637859f41090602401600060405180830381600087803b1580156106b857600080fd5b505af11580156106cc573d6000803e3d6000fd5b505050505b60008054906101000a90046001600160a01b03166001600160a01b0316633f6fa6556040518163ffffffff1660e01b815260040160206040518083038186803b15801561071d57600080fd5b505afa158015610731573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061075591906128ce565b80156107e25750600160009054906101000a90046001600160a01b03166001600160a01b0316633f6fa6556040518163ffffffff1660e01b815260040160206040518083038186803b1580156107aa57600080fd5b505afa1580156107be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107e291906128ce565b6107fe5760405162461bcd60e51b81526004016102b590612b10565b600454600160a01b900460ff161561084c5760405162461bcd60e51b8152602060048201526011602482015270416c7265616479207265736f6c7665642160781b60448201526064016102b5565b600254604080516318160ddd60e01b815290516000926001600160a01b0316916318160ddd916004808301926020929190829003018186803b15801561089157600080fd5b505afa1580156108a5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108c99190612970565b118061094f5750600354604080516318160ddd60e01b815290516000926001600160a01b0316916318160ddd916004808301926020929190829003018186803b15801561091557600080fd5b505afa158015610929573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061094d9190612970565b115b15610a655760008054906101000a90046001600160a01b03166001600160a01b031663851492586040518163ffffffff1660e01b8152600401602060405180830381600087803b1580156109a257600080fd5b505af11580156109b6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109da9190612970565b50600160009054906101000a90046001600160a01b03166001600160a01b031663851492586040518163ffffffff1660e01b8152600401602060405180830381600087803b158015610a2b57600080fd5b505af1158015610a3f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a639190612970565b505b6004805460ff60a01b198116600160a01b17825560408051639324cac760e01b815290516000936001600160a01b0390931692639324cac792808201926020929091829003018186803b158015610abb57600080fd5b505afa158015610acf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610af39190612842565b6040516370a0823160e01b81523060048201526001600160a01b0391909116906370a082319060240160206040518083038186803b158015610b3457600080fd5b505afa158015610b48573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b6c9190612970565b1115610d5a576004805460408051639324cac760e01b815290516001600160a01b0390921692639324cac7928282019260209290829003018186803b158015610bb457600080fd5b505afa158015610bc8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bec9190612842565b6004805460408051639324cac760e01b815290516001600160a01b039485169463a9059cbb949316928392639324cac79281830192602092829003018186803b158015610c3857600080fd5b505afa158015610c4c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c709190612842565b6040516370a0823160e01b81523060048201526001600160a01b0391909116906370a082319060240160206040518083038186803b158015610cb157600080fd5b505afa158015610cc5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ce99190612970565b6040518363ffffffff1660e01b8152600401610d06929190612a2b565b602060405180830381600087803b158015610d2057600080fd5b505af1158015610d34573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d5891906128ce565b505b60008060009054906101000a90046001600160a01b03166001600160a01b03166341bc7b1f6040518163ffffffff1660e01b815260040160606040518083038186803b158015610da957600080fd5b505afa158015610dbd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610de191906128ee565b92505050806005819055507fcb06b84a152f7fe5c230b7a607ec296812d6f2656f32720215281f7eefb9a107610e15611194565b600554604051610e26929190612a7c565b60405180910390a150565b60008060009054906101000a90046001600160a01b03166001600160a01b0316633f6fa6556040518163ffffffff1660e01b815260040160206040518083038186803b158015610e8057600080fd5b505afa158015610e94573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610eb891906128ce565b158015610f46575060008054906101000a90046001600160a01b03166001600160a01b031663ac3791e36040518163ffffffff1660e01b815260040160206040518083038186803b158015610f0c57600080fd5b505afa158015610f20573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f4491906128ce565b155b15610f515750600090565b600160009054906101000a90046001600160a01b03166001600160a01b0316633f6fa6556040518163ffffffff1660e01b815260040160206040518083038186803b158015610f9f57600080fd5b505afa158015610fb3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fd791906128ce565b1580156110675750600160009054906101000a90046001600160a01b03166001600160a01b031663ac3791e36040518163ffffffff1660e01b815260040160206040518083038186803b15801561102d57600080fd5b505afa158015611041573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061106591906128ce565b155b156110725750600090565b6002546040516370a0823160e01b81523360048201526000916001600160a01b0316906370a082319060240160206040518083038186803b1580156110b657600080fd5b505afa1580156110ca573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110ee9190612970565b6003546040516370a0823160e01b81523360048201529192506000916001600160a01b03909116906370a082319060240160206040518083038186803b15801561113757600080fd5b505afa15801561114b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061116f9190612970565b90508115801561117d575080155b1561118b5760009250505090565b60019250505090565b600060018160008054906101000a90046001600160a01b03166001600160a01b031663653721476040518163ffffffff1660e01b815260040160206040518083038186803b1580156111e557600080fd5b505afa1580156111f9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061121d9190612954565b600181111561123c57634e487b7160e01b600052602160045260246000fd5b1480156112ec575060018060009054906101000a90046001600160a01b03166001600160a01b031663653721476040518163ffffffff1660e01b815260040160206040518083038186803b15801561129357600080fd5b505afa1580156112a7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112cb9190612954565b60018111156112ea57634e487b7160e01b600052602160045260246000fd5b145b156112f5575060005b919050565b6004546001600160a01b031633146113245760405162461bcd60e51b81526004016102b590612aca565b8261132e57505050565b611339818484612451565b505050565b6004546001600160a01b031633146113685760405162461bcd60e51b81526004016102b590612aca565b6004805460408051639324cac760e01b815290516001600160a01b0390921692639324cac7928282019260209290829003018186803b1580156113aa57600080fd5b505afa1580156113be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113e29190612842565b6001600160a01b031663a9059cbb82600460009054906101000a90046001600160a01b03166001600160a01b0316639324cac76040518163ffffffff1660e01b815260040160206040518083038186803b15801561143f57600080fd5b505afa158015611453573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114779190612842565b6040516370a0823160e01b81523060048201526001600160a01b0391909116906370a082319060240160206040518083038186803b1580156114b857600080fd5b505afa1580156114cc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114f09190612970565b6040518363ffffffff1660e01b815260040161150d929190612a2b565b602060405180830381600087803b15801561152757600080fd5b505af115801561153b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061155f91906128ce565b5050565b60008060009054906101000a90046001600160a01b03166001600160a01b0316633f6fa6556040518163ffffffff1660e01b815260040160206040518083038186803b1580156115b257600080fd5b505afa1580156115c6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115ea91906128ce565b158015611678575060008054906101000a90046001600160a01b03166001600160a01b031663ac3791e36040518163ffffffff1660e01b815260040160206040518083038186803b15801561163e57600080fd5b505afa158015611652573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061167691906128ce565b155b156116835750600090565b600160009054906101000a90046001600160a01b03166001600160a01b0316633f6fa6556040518163ffffffff1660e01b815260040160206040518083038186803b1580156116d157600080fd5b505afa1580156116e5573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061170991906128ce565b1580156117995750600160009054906101000a90046001600160a01b03166001600160a01b031663ac3791e36040518163ffffffff1660e01b815260040160206040518083038186803b15801561175f57600080fd5b505afa158015611773573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061179791906128ce565b155b156117a45750600090565b50600454600160a01b900460ff161590565b60008054906101000a90046001600160a01b03166001600160a01b031663ac3791e36040518163ffffffff1660e01b815260040160206040518083038186803b15801561180257600080fd5b505afa158015611816573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061183a91906128ce565b15611988576004805460408051632773edf160e11b815290516001600160a01b0390921692634ee7dbe2928282019260209290829003018186803b15801561188157600080fd5b505afa158015611895573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118b99190612842565b6001600160a01b031663481c6a756040518163ffffffff1660e01b815260040160206040518083038186803b1580156118f157600080fd5b505afa158015611905573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119299190612842565b6000546040516307859f4160e41b81526001600160a01b039182166004820152911690637859f41090602401600060405180830381600087803b15801561196f57600080fd5b505af1158015611983573d6000803e3d6000fd5b505050505b600160009054906101000a90046001600160a01b03166001600160a01b031663ac3791e36040518163ffffffff1660e01b815260040160206040518083038186803b1580156119d657600080fd5b505afa1580156119ea573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a0e91906128ce565b15611b5c576004805460408051632773edf160e11b815290516001600160a01b0390921692634ee7dbe2928282019260209290829003018186803b158015611a5557600080fd5b505afa158015611a69573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a8d9190612842565b6001600160a01b031663481c6a756040518163ffffffff1660e01b815260040160206040518083038186803b158015611ac557600080fd5b505afa158015611ad9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611afd9190612842565b6001546040516307859f4160e41b81526001600160a01b039182166004820152911690637859f41090602401600060405180830381600087803b158015611b4357600080fd5b505af1158015611b57573d6000803e3d6000fd5b505050505b60008054906101000a90046001600160a01b03166001600160a01b0316633f6fa6556040518163ffffffff1660e01b815260040160206040518083038186803b158015611ba857600080fd5b505afa158015611bbc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611be091906128ce565b8015611c6d5750600160009054906101000a90046001600160a01b03166001600160a01b0316633f6fa6556040518163ffffffff1660e01b815260040160206040518083038186803b158015611c3557600080fd5b505afa158015611c49573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c6d91906128ce565b611c895760405162461bcd60e51b81526004016102b590612b10565b6002546040516370a0823160e01b81523360048201526000916001600160a01b0316906370a082319060240160206040518083038186803b158015611ccd57600080fd5b505afa158015611ce1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d059190612970565b6003546040516370a0823160e01b81523360048201529192506000916001600160a01b03909116906370a082319060240160206040518083038186803b158015611d4e57600080fd5b505afa158015611d62573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d869190612970565b905081151580611d9557508015155b611dd75760405162461bcd60e51b81526020600482015260136024820152724e6f7468696e6720746f20657865726369736560681b60448201526064016102b5565b600454600160a01b900460ff16611df057611df061032b565b8115611e5b57600254604051632770a7eb60e21b81526001600160a01b0390911690639dc29fac90611e289033908690600401612a2b565b600060405180830381600087803b158015611e4257600080fd5b505af1158015611e56573d6000803e3d6000fd5b505050505b8015611ec657600354604051632770a7eb60e21b81526001600160a01b0390911690639dc29fac90611e939033908590600401612a2b565b600060405180830381600087803b158015611ead57600080fd5b505af1158015611ec1573d6000803e3d6000fd5b505050505b60016000808054906101000a90046001600160a01b03166001600160a01b031663653721476040518163ffffffff1660e01b815260040160206040518083038186803b158015611f1557600080fd5b505afa158015611f29573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f4d9190612954565b6001811115611f6c57634e487b7160e01b600052602160045260246000fd5b14801561201c575060018060009054906101000a90046001600160a01b03166001600160a01b031663653721476040518163ffffffff1660e01b815260040160206040518083038186803b158015611fc357600080fd5b505afa158015611fd7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ffb9190612954565b600181111561201a57634e487b7160e01b600052602160045260246000fd5b145b15612025575060005b60008082600181111561204857634e487b7160e01b600052602160045260246000fd5b146120535782612055565b835b905080156120c15760048054604051632d2636e760e11b81526001600160a01b0390911691635a4c6dce9161208e913391869101612a2b565b600060405180830381600087803b1580156120a857600080fd5b505af11580156120bc573d6000803e3d6000fd5b505050505b7fe10723980362293f7a08e5193521f5f556e665690be76404573641b4dd887a0a3382846040516120f493929190612a44565b60405180910390a150505050565b6004546001600160a01b0316331461212c5760405162461bcd60e51b81526004016102b590612aca565b81612135575050565b600080546040805163661770cb60e11b815281516001600160a01b039093169263cc2ee19692600480840193919291829003018186803b15801561217857600080fd5b505afa15801561218c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121b0919061291b565b5090506121d3336121c2600286612b56565b6001600160a01b0384169190612587565b6001546040805163661770cb60e11b815281516000936001600160a01b03169263cc2ee1969260048082019391829003018186803b15801561221457600080fd5b505afa158015612228573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061224c919061291b565b915061225f9050336121c2600287612b56565b600254604051632770a7eb60e21b81526001600160a01b0390911690639dc29fac906122919086908890600401612a2b565b600060405180830381600087803b1580156122ab57600080fd5b505af11580156122bf573d6000803e3d6000fd5b5050505050505050565b6004546001600160a01b031633146122f35760405162461bcd60e51b81526004016102b590612aca565b816122fc575050565b600080546040805163661770cb60e11b815281516001600160a01b039093169263cc2ee19692600480840193919291829003018186803b15801561233f57600080fd5b505afa158015612353573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612377919061291b565b915061238f90506001600160a01b0382163385612587565b6001546040805163661770cb60e11b815281516000936001600160a01b03169263cc2ee1969260048082019391829003018186803b1580156123d057600080fd5b505afa1580156123e4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612408919061291b565b50905061241f6001600160a01b0382163386612587565b600354604051632770a7eb60e21b81526001600160a01b0390911690639dc29fac906122919086908890600401612a2b565b600081600181111561247357634e487b7160e01b600052602160045260246000fd5b14156124e2576002546040516340c10f1960e01b81526001600160a01b03909116906340c10f19906124ab9086908690600401612a2b565b600060405180830381600087803b1580156124c557600080fd5b505af11580156124d9573d6000803e3d6000fd5b50505050612547565b6003546040516340c10f1960e01b81526001600160a01b03909116906340c10f19906125149086908690600401612a2b565b600060405180830381600087803b15801561252e57600080fd5b505af1158015612542573d6000803e3d6000fd5b505050505b7f29600984795369456176b31dad545cb35585021faea93dcc568a467a737ad42583838360405161257a93929190612a44565b60405180910390a1505050565b6113398363a9059cbb60e01b84846040516024016125a6929190612a2b565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152600061262d826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166126aa9092919063ffffffff16565b805190915015611339578080602001905181019061264b91906128ce565b6113395760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016102b5565b60606126b984846000856126c3565b90505b9392505050565b6060824710156127245760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016102b5565b843b6127725760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016102b5565b600080866001600160a01b0316858760405161278e9190612a0f565b60006040518083038185875af1925050503d80600081146127cb576040519150601f19603f3d011682016040523d82523d6000602084013e6127d0565b606091505b50915091506127e08282866127ed565b925050505b949350505050565b606083156127fc5750816126bc565b82511561280c5782518084602001fd5b8160405162461bcd60e51b81526004016102b59190612a97565b600060208284031215612837578081fd5b81356126bc81612ba6565b600060208284031215612853578081fd5b81516126bc81612ba6565b600080600080600060a08688031215612875578081fd5b853561288081612ba6565b9450602086013561289081612ba6565b935060408601356128a081612ba6565b925060608601356128b081612ba6565b915060808601356128c081612ba6565b809150509295509295909350565b6000602082840312156128df578081fd5b815180151581146126bc578182fd5b600080600060608486031215612902578283fd5b8351925060208401519150604084015190509250925092565b6000806040838503121561292d578182fd5b825161293881612ba6565b602084015190925061294981612ba6565b809150509250929050565b600060208284031215612965578081fd5b81516126bc81612bbe565b600060208284031215612981578081fd5b5051919050565b6000806040838503121561299a578182fd5b82359150602083013561294981612ba6565b6000806000606084860312156129c0578283fd5b8335925060208401356129d281612bbe565b915060408401356129e281612ba6565b809150509250925092565b60028110612a0b57634e487b7160e01b600052602160045260246000fd5b9052565b60008251612a21818460208701612b76565b9190910192915050565b6001600160a01b03929092168252602082015260400190565b6001600160a01b038416815260208101839052606081016127e560408301846129ed565b60208101612a7682846129ed565b92915050565b60408101612a8a82856129ed565b8260208301529392505050565b6020815260008251806020840152612ab6816040850160208701612b76565b601f01601f19169190910160400192915050565b60208082526026908201527f6f6e6c792074686520414d4d206d617920706572666f726d207468657365206d6040820152656574686f647360d01b606082015260800190565b60208082526026908201527f4c656674206f72205269676874206d61726b6574206e6f74207265736f6c766560408201526564207965742160d01b606082015260800190565b600082612b7157634e487b7160e01b81526012600452602481fd5b500490565b60005b83811015612b91578181015183820152602001612b79565b83811115612ba0576000848401525b50505050565b6001600160a01b0381168114612bbb57600080fd5b50565b60028110612bbb57600080fdfea2646970667358221220990e3bacb0a2df48e1d94e9d7fd984095c70b004b8d1081f9c0d4bedd494476d64736f6c63430008040033

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106101005760003560e01c80638033491c11610097578063ba5b798211610066578063ba5b7982146101f4578063d06a750c1461022e578063f8fdd17c14610236578063fe5072321461024957600080fd5b80638033491c146101b3578063928d300e146101c657806392902ea9146101d9578063ac3791e3146101ec57600080fd5b80632b9b55b3116100d35780632b9b55b31461017a5780633f6fa6551461018257806359f7f7fe14610196578063653721471461019e57600080fd5b8063059692b21461010557806307b00005146101355780631459457a14610148578063158ef93e1461015d575b600080fd5b600054610118906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b600454610118906001600160a01b031681565b61015b61015636600461285e565b61025c565b005b60065461016a9060ff1681565b604051901515815260200161012c565b61015b61032b565b60045461016a90600160a01b900460ff1681565b61016a610e31565b6101a6611194565b60405161012c9190612a68565b61015b6101c13660046129ac565b6112fa565b61015b6101d4366004612826565b61133e565b600154610118906001600160a01b031681565b61016a611563565b60025460035461020e916001600160a01b03908116911682565b604080516001600160a01b0393841681529290911660208301520161012c565b61015b6117b6565b61015b610244366004612988565b612102565b61015b610257366004612988565b6122c9565b60065460ff16156102be5760405162461bcd60e51b815260206004820152602160248201527f52616e676564204d61726b657420616c726561647920696e697469616c697a656044820152601960fa1b60648201526084015b60405180910390fd5b6006805460ff19166001908117909155600080546001600160a01b039788166001600160a01b031991821617909155815495871695811695909517905560028054938616938516939093179092556003805491851691841691909117905560048054919093169116179055565b60008054906101000a90046001600160a01b03166001600160a01b031663ac3791e36040518163ffffffff1660e01b815260040160206040518083038186803b15801561037757600080fd5b505afa15801561038b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103af91906128ce565b156104fd576004805460408051632773edf160e11b815290516001600160a01b0390921692634ee7dbe2928282019260209290829003018186803b1580156103f657600080fd5b505afa15801561040a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061042e9190612842565b6001600160a01b031663481c6a756040518163ffffffff1660e01b815260040160206040518083038186803b15801561046657600080fd5b505afa15801561047a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061049e9190612842565b6000546040516307859f4160e41b81526001600160a01b039182166004820152911690637859f41090602401600060405180830381600087803b1580156104e457600080fd5b505af11580156104f8573d6000803e3d6000fd5b505050505b600160009054906101000a90046001600160a01b03166001600160a01b031663ac3791e36040518163ffffffff1660e01b815260040160206040518083038186803b15801561054b57600080fd5b505afa15801561055f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061058391906128ce565b156106d1576004805460408051632773edf160e11b815290516001600160a01b0390921692634ee7dbe2928282019260209290829003018186803b1580156105ca57600080fd5b505afa1580156105de573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106029190612842565b6001600160a01b031663481c6a756040518163ffffffff1660e01b815260040160206040518083038186803b15801561063a57600080fd5b505afa15801561064e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106729190612842565b6001546040516307859f4160e41b81526001600160a01b039182166004820152911690637859f41090602401600060405180830381600087803b1580156106b857600080fd5b505af11580156106cc573d6000803e3d6000fd5b505050505b60008054906101000a90046001600160a01b03166001600160a01b0316633f6fa6556040518163ffffffff1660e01b815260040160206040518083038186803b15801561071d57600080fd5b505afa158015610731573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061075591906128ce565b80156107e25750600160009054906101000a90046001600160a01b03166001600160a01b0316633f6fa6556040518163ffffffff1660e01b815260040160206040518083038186803b1580156107aa57600080fd5b505afa1580156107be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107e291906128ce565b6107fe5760405162461bcd60e51b81526004016102b590612b10565b600454600160a01b900460ff161561084c5760405162461bcd60e51b8152602060048201526011602482015270416c7265616479207265736f6c7665642160781b60448201526064016102b5565b600254604080516318160ddd60e01b815290516000926001600160a01b0316916318160ddd916004808301926020929190829003018186803b15801561089157600080fd5b505afa1580156108a5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108c99190612970565b118061094f5750600354604080516318160ddd60e01b815290516000926001600160a01b0316916318160ddd916004808301926020929190829003018186803b15801561091557600080fd5b505afa158015610929573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061094d9190612970565b115b15610a655760008054906101000a90046001600160a01b03166001600160a01b031663851492586040518163ffffffff1660e01b8152600401602060405180830381600087803b1580156109a257600080fd5b505af11580156109b6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109da9190612970565b50600160009054906101000a90046001600160a01b03166001600160a01b031663851492586040518163ffffffff1660e01b8152600401602060405180830381600087803b158015610a2b57600080fd5b505af1158015610a3f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a639190612970565b505b6004805460ff60a01b198116600160a01b17825560408051639324cac760e01b815290516000936001600160a01b0390931692639324cac792808201926020929091829003018186803b158015610abb57600080fd5b505afa158015610acf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610af39190612842565b6040516370a0823160e01b81523060048201526001600160a01b0391909116906370a082319060240160206040518083038186803b158015610b3457600080fd5b505afa158015610b48573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b6c9190612970565b1115610d5a576004805460408051639324cac760e01b815290516001600160a01b0390921692639324cac7928282019260209290829003018186803b158015610bb457600080fd5b505afa158015610bc8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bec9190612842565b6004805460408051639324cac760e01b815290516001600160a01b039485169463a9059cbb949316928392639324cac79281830192602092829003018186803b158015610c3857600080fd5b505afa158015610c4c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c709190612842565b6040516370a0823160e01b81523060048201526001600160a01b0391909116906370a082319060240160206040518083038186803b158015610cb157600080fd5b505afa158015610cc5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ce99190612970565b6040518363ffffffff1660e01b8152600401610d06929190612a2b565b602060405180830381600087803b158015610d2057600080fd5b505af1158015610d34573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d5891906128ce565b505b60008060009054906101000a90046001600160a01b03166001600160a01b03166341bc7b1f6040518163ffffffff1660e01b815260040160606040518083038186803b158015610da957600080fd5b505afa158015610dbd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610de191906128ee565b92505050806005819055507fcb06b84a152f7fe5c230b7a607ec296812d6f2656f32720215281f7eefb9a107610e15611194565b600554604051610e26929190612a7c565b60405180910390a150565b60008060009054906101000a90046001600160a01b03166001600160a01b0316633f6fa6556040518163ffffffff1660e01b815260040160206040518083038186803b158015610e8057600080fd5b505afa158015610e94573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610eb891906128ce565b158015610f46575060008054906101000a90046001600160a01b03166001600160a01b031663ac3791e36040518163ffffffff1660e01b815260040160206040518083038186803b158015610f0c57600080fd5b505afa158015610f20573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f4491906128ce565b155b15610f515750600090565b600160009054906101000a90046001600160a01b03166001600160a01b0316633f6fa6556040518163ffffffff1660e01b815260040160206040518083038186803b158015610f9f57600080fd5b505afa158015610fb3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fd791906128ce565b1580156110675750600160009054906101000a90046001600160a01b03166001600160a01b031663ac3791e36040518163ffffffff1660e01b815260040160206040518083038186803b15801561102d57600080fd5b505afa158015611041573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061106591906128ce565b155b156110725750600090565b6002546040516370a0823160e01b81523360048201526000916001600160a01b0316906370a082319060240160206040518083038186803b1580156110b657600080fd5b505afa1580156110ca573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110ee9190612970565b6003546040516370a0823160e01b81523360048201529192506000916001600160a01b03909116906370a082319060240160206040518083038186803b15801561113757600080fd5b505afa15801561114b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061116f9190612970565b90508115801561117d575080155b1561118b5760009250505090565b60019250505090565b600060018160008054906101000a90046001600160a01b03166001600160a01b031663653721476040518163ffffffff1660e01b815260040160206040518083038186803b1580156111e557600080fd5b505afa1580156111f9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061121d9190612954565b600181111561123c57634e487b7160e01b600052602160045260246000fd5b1480156112ec575060018060009054906101000a90046001600160a01b03166001600160a01b031663653721476040518163ffffffff1660e01b815260040160206040518083038186803b15801561129357600080fd5b505afa1580156112a7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112cb9190612954565b60018111156112ea57634e487b7160e01b600052602160045260246000fd5b145b156112f5575060005b919050565b6004546001600160a01b031633146113245760405162461bcd60e51b81526004016102b590612aca565b8261132e57505050565b611339818484612451565b505050565b6004546001600160a01b031633146113685760405162461bcd60e51b81526004016102b590612aca565b6004805460408051639324cac760e01b815290516001600160a01b0390921692639324cac7928282019260209290829003018186803b1580156113aa57600080fd5b505afa1580156113be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113e29190612842565b6001600160a01b031663a9059cbb82600460009054906101000a90046001600160a01b03166001600160a01b0316639324cac76040518163ffffffff1660e01b815260040160206040518083038186803b15801561143f57600080fd5b505afa158015611453573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114779190612842565b6040516370a0823160e01b81523060048201526001600160a01b0391909116906370a082319060240160206040518083038186803b1580156114b857600080fd5b505afa1580156114cc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114f09190612970565b6040518363ffffffff1660e01b815260040161150d929190612a2b565b602060405180830381600087803b15801561152757600080fd5b505af115801561153b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061155f91906128ce565b5050565b60008060009054906101000a90046001600160a01b03166001600160a01b0316633f6fa6556040518163ffffffff1660e01b815260040160206040518083038186803b1580156115b257600080fd5b505afa1580156115c6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115ea91906128ce565b158015611678575060008054906101000a90046001600160a01b03166001600160a01b031663ac3791e36040518163ffffffff1660e01b815260040160206040518083038186803b15801561163e57600080fd5b505afa158015611652573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061167691906128ce565b155b156116835750600090565b600160009054906101000a90046001600160a01b03166001600160a01b0316633f6fa6556040518163ffffffff1660e01b815260040160206040518083038186803b1580156116d157600080fd5b505afa1580156116e5573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061170991906128ce565b1580156117995750600160009054906101000a90046001600160a01b03166001600160a01b031663ac3791e36040518163ffffffff1660e01b815260040160206040518083038186803b15801561175f57600080fd5b505afa158015611773573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061179791906128ce565b155b156117a45750600090565b50600454600160a01b900460ff161590565b60008054906101000a90046001600160a01b03166001600160a01b031663ac3791e36040518163ffffffff1660e01b815260040160206040518083038186803b15801561180257600080fd5b505afa158015611816573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061183a91906128ce565b15611988576004805460408051632773edf160e11b815290516001600160a01b0390921692634ee7dbe2928282019260209290829003018186803b15801561188157600080fd5b505afa158015611895573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118b99190612842565b6001600160a01b031663481c6a756040518163ffffffff1660e01b815260040160206040518083038186803b1580156118f157600080fd5b505afa158015611905573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119299190612842565b6000546040516307859f4160e41b81526001600160a01b039182166004820152911690637859f41090602401600060405180830381600087803b15801561196f57600080fd5b505af1158015611983573d6000803e3d6000fd5b505050505b600160009054906101000a90046001600160a01b03166001600160a01b031663ac3791e36040518163ffffffff1660e01b815260040160206040518083038186803b1580156119d657600080fd5b505afa1580156119ea573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a0e91906128ce565b15611b5c576004805460408051632773edf160e11b815290516001600160a01b0390921692634ee7dbe2928282019260209290829003018186803b158015611a5557600080fd5b505afa158015611a69573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a8d9190612842565b6001600160a01b031663481c6a756040518163ffffffff1660e01b815260040160206040518083038186803b158015611ac557600080fd5b505afa158015611ad9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611afd9190612842565b6001546040516307859f4160e41b81526001600160a01b039182166004820152911690637859f41090602401600060405180830381600087803b158015611b4357600080fd5b505af1158015611b57573d6000803e3d6000fd5b505050505b60008054906101000a90046001600160a01b03166001600160a01b0316633f6fa6556040518163ffffffff1660e01b815260040160206040518083038186803b158015611ba857600080fd5b505afa158015611bbc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611be091906128ce565b8015611c6d5750600160009054906101000a90046001600160a01b03166001600160a01b0316633f6fa6556040518163ffffffff1660e01b815260040160206040518083038186803b158015611c3557600080fd5b505afa158015611c49573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c6d91906128ce565b611c895760405162461bcd60e51b81526004016102b590612b10565b6002546040516370a0823160e01b81523360048201526000916001600160a01b0316906370a082319060240160206040518083038186803b158015611ccd57600080fd5b505afa158015611ce1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d059190612970565b6003546040516370a0823160e01b81523360048201529192506000916001600160a01b03909116906370a082319060240160206040518083038186803b158015611d4e57600080fd5b505afa158015611d62573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d869190612970565b905081151580611d9557508015155b611dd75760405162461bcd60e51b81526020600482015260136024820152724e6f7468696e6720746f20657865726369736560681b60448201526064016102b5565b600454600160a01b900460ff16611df057611df061032b565b8115611e5b57600254604051632770a7eb60e21b81526001600160a01b0390911690639dc29fac90611e289033908690600401612a2b565b600060405180830381600087803b158015611e4257600080fd5b505af1158015611e56573d6000803e3d6000fd5b505050505b8015611ec657600354604051632770a7eb60e21b81526001600160a01b0390911690639dc29fac90611e939033908590600401612a2b565b600060405180830381600087803b158015611ead57600080fd5b505af1158015611ec1573d6000803e3d6000fd5b505050505b60016000808054906101000a90046001600160a01b03166001600160a01b031663653721476040518163ffffffff1660e01b815260040160206040518083038186803b158015611f1557600080fd5b505afa158015611f29573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f4d9190612954565b6001811115611f6c57634e487b7160e01b600052602160045260246000fd5b14801561201c575060018060009054906101000a90046001600160a01b03166001600160a01b031663653721476040518163ffffffff1660e01b815260040160206040518083038186803b158015611fc357600080fd5b505afa158015611fd7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ffb9190612954565b600181111561201a57634e487b7160e01b600052602160045260246000fd5b145b15612025575060005b60008082600181111561204857634e487b7160e01b600052602160045260246000fd5b146120535782612055565b835b905080156120c15760048054604051632d2636e760e11b81526001600160a01b0390911691635a4c6dce9161208e913391869101612a2b565b600060405180830381600087803b1580156120a857600080fd5b505af11580156120bc573d6000803e3d6000fd5b505050505b7fe10723980362293f7a08e5193521f5f556e665690be76404573641b4dd887a0a3382846040516120f493929190612a44565b60405180910390a150505050565b6004546001600160a01b0316331461212c5760405162461bcd60e51b81526004016102b590612aca565b81612135575050565b600080546040805163661770cb60e11b815281516001600160a01b039093169263cc2ee19692600480840193919291829003018186803b15801561217857600080fd5b505afa15801561218c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121b0919061291b565b5090506121d3336121c2600286612b56565b6001600160a01b0384169190612587565b6001546040805163661770cb60e11b815281516000936001600160a01b03169263cc2ee1969260048082019391829003018186803b15801561221457600080fd5b505afa158015612228573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061224c919061291b565b915061225f9050336121c2600287612b56565b600254604051632770a7eb60e21b81526001600160a01b0390911690639dc29fac906122919086908890600401612a2b565b600060405180830381600087803b1580156122ab57600080fd5b505af11580156122bf573d6000803e3d6000fd5b5050505050505050565b6004546001600160a01b031633146122f35760405162461bcd60e51b81526004016102b590612aca565b816122fc575050565b600080546040805163661770cb60e11b815281516001600160a01b039093169263cc2ee19692600480840193919291829003018186803b15801561233f57600080fd5b505afa158015612353573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612377919061291b565b915061238f90506001600160a01b0382163385612587565b6001546040805163661770cb60e11b815281516000936001600160a01b03169263cc2ee1969260048082019391829003018186803b1580156123d057600080fd5b505afa1580156123e4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612408919061291b565b50905061241f6001600160a01b0382163386612587565b600354604051632770a7eb60e21b81526001600160a01b0390911690639dc29fac906122919086908890600401612a2b565b600081600181111561247357634e487b7160e01b600052602160045260246000fd5b14156124e2576002546040516340c10f1960e01b81526001600160a01b03909116906340c10f19906124ab9086908690600401612a2b565b600060405180830381600087803b1580156124c557600080fd5b505af11580156124d9573d6000803e3d6000fd5b50505050612547565b6003546040516340c10f1960e01b81526001600160a01b03909116906340c10f19906125149086908690600401612a2b565b600060405180830381600087803b15801561252e57600080fd5b505af1158015612542573d6000803e3d6000fd5b505050505b7f29600984795369456176b31dad545cb35585021faea93dcc568a467a737ad42583838360405161257a93929190612a44565b60405180910390a1505050565b6113398363a9059cbb60e01b84846040516024016125a6929190612a2b565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152600061262d826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166126aa9092919063ffffffff16565b805190915015611339578080602001905181019061264b91906128ce565b6113395760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016102b5565b60606126b984846000856126c3565b90505b9392505050565b6060824710156127245760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016102b5565b843b6127725760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016102b5565b600080866001600160a01b0316858760405161278e9190612a0f565b60006040518083038185875af1925050503d80600081146127cb576040519150601f19603f3d011682016040523d82523d6000602084013e6127d0565b606091505b50915091506127e08282866127ed565b925050505b949350505050565b606083156127fc5750816126bc565b82511561280c5782518084602001fd5b8160405162461bcd60e51b81526004016102b59190612a97565b600060208284031215612837578081fd5b81356126bc81612ba6565b600060208284031215612853578081fd5b81516126bc81612ba6565b600080600080600060a08688031215612875578081fd5b853561288081612ba6565b9450602086013561289081612ba6565b935060408601356128a081612ba6565b925060608601356128b081612ba6565b915060808601356128c081612ba6565b809150509295509295909350565b6000602082840312156128df578081fd5b815180151581146126bc578182fd5b600080600060608486031215612902578283fd5b8351925060208401519150604084015190509250925092565b6000806040838503121561292d578182fd5b825161293881612ba6565b602084015190925061294981612ba6565b809150509250929050565b600060208284031215612965578081fd5b81516126bc81612bbe565b600060208284031215612981578081fd5b5051919050565b6000806040838503121561299a578182fd5b82359150602083013561294981612ba6565b6000806000606084860312156129c0578283fd5b8335925060208401356129d281612bbe565b915060408401356129e281612ba6565b809150509250925092565b60028110612a0b57634e487b7160e01b600052602160045260246000fd5b9052565b60008251612a21818460208701612b76565b9190910192915050565b6001600160a01b03929092168252602082015260400190565b6001600160a01b038416815260208101839052606081016127e560408301846129ed565b60208101612a7682846129ed565b92915050565b60408101612a8a82856129ed565b8260208301529392505050565b6020815260008251806020840152612ab6816040850160208701612b76565b601f01601f19169190910160400192915050565b60208082526026908201527f6f6e6c792074686520414d4d206d617920706572666f726d207468657365206d6040820152656574686f647360d01b606082015260800190565b60208082526026908201527f4c656674206f72205269676874206d61726b6574206e6f74207265736f6c766560408201526564207965742160d01b606082015260800190565b600082612b7157634e487b7160e01b81526012600452602481fd5b500490565b60005b83811015612b91578181015183820152602001612b79565b83811115612ba0576000848401525b50505050565b6001600160a01b0381168114612bbb57600080fd5b50565b60028110612bbb57600080fdfea2646970667358221220990e3bacb0a2df48e1d94e9d7fd984095c70b004b8d1081f9c0d4bedd494476d64736f6c63430008040033

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
[ Download: CSV Export  ]
[ Download: CSV Export  ]

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.