Arbitrum Sepolia Testnet

Token

Buffer (BFR)
ERC-721

Overview

Max Total Supply

0 BFR

Holders

0

Market

Onchain Market Cap

-

Circulating Supply Market Cap

-
Balance
0 BFR
0x0000000000000000000000000000000000000000
Loading...
Loading
Loading...
Loading
Loading...
Loading

Click here to update the token information / general information

Contract Source Code Verified (Exact Match)

Contract Name:
BufferBinaryOptions

Compiler Version
v0.8.4+commit.c7e474f2

Optimization Enabled:
Yes with 200 runs

Other Settings:
istanbul EvmVersion, None license

Contract Source Code (Solidity Standard Json-Input format)

// SPDX-License-Identifier: BUSL-1.1

pragma solidity 0.8.4;

import "ReentrancyGuard.sol";
import "ERC721.sol";
import "AccessControl.sol";
import "SafeERC20.sol";
import "Interfaces.sol";
import "OptionMath.sol";

/**
 * @author Heisenberg
 * @title Buffer Options
 * @notice Creates ERC721 Options
 */

contract BufferBinaryOptions is
    IBufferBinaryOptions,
    ReentrancyGuard,
    ERC721,
    AccessControl
{
    using SafeERC20 for ERC20;
    uint256 public nextTokenId = 0;
    uint256 public override totalMarketOI;
    bool public isPaused;
    uint16 public constant stepSize = 25; // Factor of 1e2

    string public override token0;
    string public override token1;
    string public override assetPair;

    ILiquidityPool public override pool;
    IOptionsConfig public override config;
    IReferralStorage public referral;
    AssetCategory public assetCategory;
    ERC20 public override tokenX;

    struct Market {
        bytes32 marketId;
        uint256 contractsUp;
        uint256 contractsDown;
        int256 premiumUp;
        int256 premiumDown;
        uint256 strike;
        uint256 expiration;
        bool isValid;
    }

    mapping(uint256 => Option) public override options;
    mapping(address => uint256[]) public userOptionIds;
    mapping(address => bool) public approvedAddresses;
    mapping(bytes32 => Market) public markets;
    // IMarket public markets;

    bytes32 public constant ROUTER_ROLE = keccak256("ROUTER_ROLE");
    bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");

    constructor() ERC721("Buffer", "BFR") {
        _setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
    }

    /************************************************
     *  INITIALIZATION FUNCTIONS
     ***********************************************/

    function initialize(
        ERC20 _tokenX,
        ILiquidityPool _pool,
        IOptionsConfig _config,
        IReferralStorage _referral,
        AssetCategory _category,
        string memory _token0,
        string memory _token1
    ) external onlyRole(DEFAULT_ADMIN_ROLE) {
        if (address(tokenX) == address(0)) {
            tokenX = _tokenX;
            pool = _pool;
            config = _config;
            referral = _referral;
            assetCategory = _category;
            token0 = _token0;
            token1 = _token1;
            _setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
            assetPair = string(abi.encodePacked(token0, token1));
            emit CreateOptionsContract(
                address(config),
                address(pool),
                address(tokenX),
                token0,
                token1,
                assetCategory
            );
        } else {
            revert("Already initialized");
        }
    }

    /**
     * @notice Grants complete approval from the pool
     */
    function approvePoolToTransferTokenX() public {
        tokenX.approve(address(pool), ~uint256(0));
    }

    /**
     * @notice Pauses/Unpauses the option creation
     */
    function setIsPaused() public {
        if (hasRole(PAUSER_ROLE, msg.sender)) {
            isPaused = true;
        } else if (hasRole(DEFAULT_ADMIN_ROLE, msg.sender)) {
            isPaused = !isPaused;
        } else {
            revert("Wrong role");
        }
        emit Pause(isPaused);
    }

    /************************************************
     *  ROUTER ONLY FUNCTIONS
     ***********************************************/

    /**
     * @notice Creates an option with the specified parameters
     * @dev Can only be called by router
     */
    function createFromRouter(
        OptionParams calldata optionParams,
        uint32 queuedTime
    ) external override onlyRole(ROUTER_ROLE) returns (uint256 optionID) {
        bytes32 marketId = keccak256(
            abi.encode(optionParams.strike, optionParams.expiration)
        );
        uint256 settlementFee = (optionParams.totalFee * optionParams.sf) / 1e4;
        Option memory option = Option(
            State.Active,
            optionParams.strike,
            optionParams.amount,
            optionParams.amount,
            optionParams.totalFee - settlementFee,
            optionParams.expiration,
            optionParams.totalFee,
            queuedTime,
            optionParams.isAbove
        );
        optionID = _generateTokenId();
        userOptionIds[optionParams.user].push(optionID);
        options[optionID] = option;
        _mint(optionParams.user, optionID);

        tokenX.safeTransfer(
            config.settlementFeeDisbursalContract(),
            settlementFee
        );

        pool.lock(optionID, option.lockedAmount, option.premium);

        IOptionStorage(config.optionStorageContract()).save(
            optionID,
            address(this),
            optionParams.user
        );
        totalMarketOI += optionParams.totalFee;

        if (optionParams.isAbove) {
            markets[marketId].contractsUp += optionParams.contracts;
            markets[marketId].premiumUp += int256(
                optionParams.totalFee - settlementFee
            );
        } else {
            markets[marketId].contractsDown += optionParams.contracts;
            markets[marketId].premiumDown += int256(
                optionParams.totalFee - settlementFee
            );
        }

        int256 skew = getSkew(marketId);
        require(skew <= config.maxSkew(), "Loss too high");

        emit Create(
            optionParams.user,
            optionID,
            settlementFee,
            optionParams.totalFee,
            skew,
            marketId
        );
    }

    /**
     * @notice Unlocks/Exercises the active options
     * @dev Can only be called router
     */
    function unlock(
        uint256 optionID,
        uint256 closingPrice
    ) external override onlyRole(ROUTER_ROLE) {
        require(_exists(optionID), "O10");
        Option storage option = options[optionID];
        require(option.expiration <= block.timestamp, "O4");

        require(option.state == State.Active, "O5");
        uint256 payout;
        if (
            (option.isAbove && closingPrice > option.strike) ||
            (!option.isAbove && closingPrice < option.strike)
        ) {
            payout = _exercise(optionID, closingPrice, option.isAbove);
        } else {
            option.state = State.Expired;
            pool.unlock(optionID);
            _burn(optionID);
            emit Expire(optionID, option.premium, closingPrice, option.isAbove);
        }
        totalMarketOI -= option.totalFee;

        ICircuitBreaker(config.circuitBreakerContract()).update(
            int256(payout) - int256(option.totalFee),
            int256(option.totalFee - option.premium),
            optionID
        );
    }

    function isExpirationValid(uint256 expiration) public view returns (bool) {
        if (expiration - block.timestamp < 12 hours) {
            return false;
        }
        bool dayend = (expiration - block.timestamp) < (1 days + 36 hours) &&
            (expiration + 16 hours) % 1 days == 0;
        bool weekend = ((expiration - 1 days - 8 hours) % 1 weeks == 0) &&
            (expiration - block.timestamp < 1 weeks + 36 hours); // Weekends at friday 8:00 AM UTC

        return dayend || weekend;
    }

    function getMarketId(
        uint256 strike,
        uint256 expiration
    ) public pure returns (bytes32) {
        return keccak256(abi.encode(strike, expiration));
    }

    function runInitialChecks(
        uint128 strike,
        uint32 expiration
    ) external override onlyRole(ROUTER_ROLE) {
        bytes32 marketId = getMarketId(strike, expiration);
        if (
            expiration < block.timestamp ||
            expiration - block.timestamp < 12 hours
        ) {
            revert("Wrong expiry");
        } else if (markets[marketId].isValid) {
            return;
        } else {
            if (
                isExpirationValid(expiration) &&
                strike % config.strikeStepSize() == 0
            ) {
                markets[marketId] = Market(
                    marketId,
                    markets[marketId].contractsUp,
                    markets[marketId].contractsDown,
                    markets[marketId].premiumUp,
                    markets[marketId].premiumDown,
                    strike,
                    expiration,
                    true
                );
                emit CreateMarket(strike, expiration, marketId, address(this));
            } else {
                revert("Invalid strike or expiration");
            }
        }
    }

    /************************************************
     *  READ ONLY FUNCTIONS
     ***********************************************/

    /**
     * @notice Returns decimals of the pool token
     */
    function decimals() public view returns (uint256) {
        return tokenX.decimals();
    }

    /**
     * @notice Calculates the fees for buying an option
     */
    function fees(
        bool isAbove,
        uint256 currentPrice,
        uint256 strike,
        uint256 period,
        uint256 iv,
        uint256 sf
    )
        public
        view
        returns (uint256 total, uint256 settlementFee, uint256 premium)
    {
        uint256 _baseFeePerContract = baseFeePerContract(
            isAbove,
            currentPrice,
            strike,
            period,
            iv
        );
        settlementFee = (_baseFeePerContract * sf) / 1e4;
        total = _baseFeePerContract + settlementFee;
        premium = _baseFeePerContract - settlementFee;
    }

    /**
     * @notice Calculates the fees for buying an option
     */
    function baseFeePerContract(
        bool isAbove,
        uint256 currentPrice,
        uint256 strike,
        uint256 period,
        uint256 iv
    ) public view returns (uint256) {
        return
            (OptionMath.blackScholesPriceBinary(
                iv,
                strike,
                currentPrice,
                period,
                true,
                isAbove
            ) * 10 ** decimals()) / 1e8;
    }

    function getSkew(bytes32 marketId) public view returns (int256) {
        int256 lossUp = getLoss(marketId, true);
        int256 lossDown = getLoss(marketId, false);
        return lossUp > lossDown ? lossUp : lossDown;
    }

    function getLoss(
        bytes32 marketId,
        bool isAbove
    ) public view returns (int256) {
        int256 payin = markets[marketId].premiumDown +
            markets[marketId].premiumUp;
        return
            isAbove
                ? int256(
                    (markets[marketId].contractsUp * config.payout()) /
                        10 ** decimals()
                ) - payin
                : int256(
                    (markets[marketId].contractsDown * config.payout()) /
                        10 ** decimals()
                ) - payin;
    }

    function getMaxPermissibleContracts(
        bytes32 marketId,
        uint256 _baseFeePerContract,
        bool isAbove
    ) public view returns (uint256) {
        return
            (uint256(config.maxSkew() - getLoss(marketId, isAbove)) *
                (10 ** decimals())) / (config.payout() - _baseFeePerContract);
    }

    /**
     * @notice Runs all the checks on the option parameters and
     * returns the revised amount and fee
     */
    function evaluateParams(
        OptionParams calldata optionParams
    )
        external
        view
        override
        returns (
            uint256 amount,
            uint256 fee,
            uint256 revisedContracts,
            uint256 revisedSf
        )
    {
        require(!isPaused, "O33");
        require(
            assetCategory == AssetCategory.Crypto ||
                ICreationWindowContract(config.creationWindowContract())
                    .isInCreationWindow(
                        optionParams.expiration - block.timestamp
                    ),
            "O30"
        );
        uint256 _baseFeePerContract = baseFeePerContract(
            optionParams.isAbove,
            optionParams.currentPrice,
            optionParams.strike,
            optionParams.expiration - block.timestamp,
            optionParams.iv
        );

        require(
            _baseFeePerContract > 5 * 10 ** (decimals() - 2),
            "Fee too less"
        );
        require(
            _baseFeePerContract < 95 * 10 ** (decimals() - 2),
            "Fee too high"
        );

        bytes32 marketId = keccak256(
            abi.encode(optionParams.strike, optionParams.expiration)
        );

        revisedSf = getSettlementFeePercentage(
            referral.codeOwner(optionParams.referralCode),
            optionParams.user,
            optionParams.sf
        );
        _baseFeePerContract += (_baseFeePerContract * revisedSf) / 1e4;
        require(
            _baseFeePerContract <= optionParams.maxFeePerContract,
            "Price difference too high"
        );

        uint256 maxContracts = getMaxPermissibleContracts(
            marketId,
            _baseFeePerContract,
            optionParams.isAbove
        );
        revisedContracts =
            (optionParams.totalFee * (10 ** decimals())) /
            _baseFeePerContract;
        if (revisedContracts > maxContracts) {
            require(optionParams.allowPartialFill, "O29");
            revisedContracts = maxContracts;
            fee = (_baseFeePerContract * revisedContracts) / (10 ** decimals());
        } else {
            fee = optionParams.totalFee;
        }

        amount = (config.payout() * revisedContracts) / (10 ** decimals());
    }

    /************************************************
     * ERC721 FUNCTIONS
     ***********************************************/

    function _generateTokenId() internal returns (uint256) {
        return nextTokenId++;
    }

    function abs(int x) private pure returns (int) {
        return x >= 0 ? x : -x;
    }

    function min(uint256 a, uint256 b) internal pure returns (uint256) {
        return a < b ? a : b;
    }

    function max(uint256 a, uint256 b) internal pure returns (uint256) {
        return a > b ? a : b;
    }

    function supportsInterface(
        bytes4 interfaceId
    ) public view override(ERC721, AccessControl) returns (bool) {
        return super.supportsInterface(interfaceId);
    }

    function ownerOf(
        uint256 tokenId
    )
        public
        view
        virtual
        override(ERC721, IBufferBinaryOptions)
        returns (address)
    {
        return super.ownerOf(tokenId);
    }

    /************************************************
     *  INTERNAL OPTION UTILITY FUNCTIONS
     ***********************************************/

    /**
     * @notice Exercises the ITM options
     */
    function _exercise(
        uint256 optionID,
        uint256 closingPrice,
        bool isAbove
    ) internal returns (uint256 profit) {
        Option storage option = options[optionID];
        address user = ownerOf(optionID);

        profit = option.lockedAmount;

        pool.send(optionID, address(this), option.lockedAmount);
        tokenX.safeTransfer(user, profit);
        if (profit < option.lockedAmount) {
            tokenX.safeTransfer(address(pool), option.lockedAmount - profit);
        }

        if (profit <= option.premium)
            emit LpProfit(optionID, option.premium - profit);
        else emit LpLoss(optionID, profit - option.premium);

        // Burn the option
        _burn(optionID);
        option.state = State.Exercised;
        emit Exercise(user, optionID, profit, closingPrice, isAbove);
    }

    /**
     * @notice Calculates the discount to be applied on settlement fee based on
     * referrer tiers
     */
    function _getReferralDiscount(
        address referrer,
        address user
    ) public view returns (uint256 referralDiscount) {
        uint256 maxStep;
        if (
            referrer != user &&
            referrer != address(0) &&
            referrer.code.length == 0
        ) {
            uint8 step = referral.referrerTierStep(
                referral.referrerTier(referrer)
            );
            maxStep += step;
        }
        referralDiscount = (stepSize * maxStep);
    }

    /**
     * @notice Returns the discounted settlement fee
     */
    function getSettlementFeePercentage(
        address referrer,
        address user,
        uint256 baseSettlementFeePercentage
    ) public view returns (uint256 settlementFeePercentage) {
        settlementFeePercentage = baseSettlementFeePercentage;
        uint256 referralDiscount = _getReferralDiscount(referrer, user);
        settlementFeePercentage = settlementFeePercentage - referralDiscount;
    }

    function approveAddress(
        address addressToApprove
    ) public onlyRole(DEFAULT_ADMIN_ROLE) {
        approvedAddresses[addressToApprove] = true;
    }

    function _beforeTokenTransfer(
        address from,
        address to,
        uint256 tokenId
    ) internal virtual override {
        if (
            from != address(0) &&
            to != address(0) &&
            approvedAddresses[to] == false &&
            approvedAddresses[from] == false
        ) {
            revert("Token transfer not allowed");
        }
    }
}

File 2 of 21 : ReentrancyGuard.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)

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 applied 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.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
abstract contract ReentrancyGuard {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant _NOT_ENTERED = 1;
    uint256 private constant _ENTERED = 2;

    uint256 private _status;

    constructor() {
        _status = _NOT_ENTERED;
    }

    /**
     * @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 making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        // On the first call to nonReentrant, _notEntered will be true
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

        // Any calls to nonReentrant after this point will fail
        _status = _ENTERED;

        _;

        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = _NOT_ENTERED;
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/ERC721.sol)

pragma solidity ^0.8.0;

import "IERC721.sol";
import "IERC721Receiver.sol";
import "IERC721Metadata.sol";
import "Address.sol";
import "Context.sol";
import "Strings.sol";
import "ERC165.sol";

/**
 * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
 * the Metadata extension, but not including the Enumerable extension, which is available separately as
 * {ERC721Enumerable}.
 */
contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
    using Address for address;
    using Strings for uint256;

    // Token name
    string private _name;

    // Token symbol
    string private _symbol;

    // Mapping from token ID to owner address
    mapping(uint256 => address) private _owners;

    // Mapping owner address to token count
    mapping(address => uint256) private _balances;

    // Mapping from token ID to approved address
    mapping(uint256 => address) private _tokenApprovals;

    // Mapping from owner to operator approvals
    mapping(address => mapping(address => bool)) private _operatorApprovals;

    /**
     * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
     */
    constructor(string memory name_, string memory symbol_) {
        _name = name_;
        _symbol = symbol_;
    }

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
        return
            interfaceId == type(IERC721).interfaceId ||
            interfaceId == type(IERC721Metadata).interfaceId ||
            super.supportsInterface(interfaceId);
    }

    /**
     * @dev See {IERC721-balanceOf}.
     */
    function balanceOf(address owner) public view virtual override returns (uint256) {
        require(owner != address(0), "ERC721: address zero is not a valid owner");
        return _balances[owner];
    }

    /**
     * @dev See {IERC721-ownerOf}.
     */
    function ownerOf(uint256 tokenId) public view virtual override returns (address) {
        address owner = _owners[tokenId];
        require(owner != address(0), "ERC721: invalid token ID");
        return owner;
    }

    /**
     * @dev See {IERC721Metadata-name}.
     */
    function name() public view virtual override returns (string memory) {
        return _name;
    }

    /**
     * @dev See {IERC721Metadata-symbol}.
     */
    function symbol() public view virtual override returns (string memory) {
        return _symbol;
    }

    /**
     * @dev See {IERC721Metadata-tokenURI}.
     */
    function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
        _requireMinted(tokenId);

        string memory baseURI = _baseURI();
        return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : "";
    }

    /**
     * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
     * token will be the concatenation of the `baseURI` and the `tokenId`. Empty
     * by default, can be overridden in child contracts.
     */
    function _baseURI() internal view virtual returns (string memory) {
        return "";
    }

    /**
     * @dev See {IERC721-approve}.
     */
    function approve(address to, uint256 tokenId) public virtual override {
        address owner = ERC721.ownerOf(tokenId);
        require(to != owner, "ERC721: approval to current owner");

        require(
            _msgSender() == owner || isApprovedForAll(owner, _msgSender()),
            "ERC721: approve caller is not token owner nor approved for all"
        );

        _approve(to, tokenId);
    }

    /**
     * @dev See {IERC721-getApproved}.
     */
    function getApproved(uint256 tokenId) public view virtual override returns (address) {
        _requireMinted(tokenId);

        return _tokenApprovals[tokenId];
    }

    /**
     * @dev See {IERC721-setApprovalForAll}.
     */
    function setApprovalForAll(address operator, bool approved) public virtual override {
        _setApprovalForAll(_msgSender(), operator, approved);
    }

    /**
     * @dev See {IERC721-isApprovedForAll}.
     */
    function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
        return _operatorApprovals[owner][operator];
    }

    /**
     * @dev See {IERC721-transferFrom}.
     */
    function transferFrom(
        address from,
        address to,
        uint256 tokenId
    ) public virtual override {
        //solhint-disable-next-line max-line-length
        require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner nor approved");

        _transfer(from, to, tokenId);
    }

    /**
     * @dev See {IERC721-safeTransferFrom}.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId
    ) public virtual override {
        safeTransferFrom(from, to, tokenId, "");
    }

    /**
     * @dev See {IERC721-safeTransferFrom}.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId,
        bytes memory data
    ) public virtual override {
        require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner nor approved");
        _safeTransfer(from, to, tokenId, data);
    }

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
     * are aware of the ERC721 protocol to prevent tokens from being forever locked.
     *
     * `data` is additional data, it has no specified format and it is sent in call to `to`.
     *
     * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.
     * implement alternative mechanisms to perform token transfer, such as signature-based.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function _safeTransfer(
        address from,
        address to,
        uint256 tokenId,
        bytes memory data
    ) internal virtual {
        _transfer(from, to, tokenId);
        require(_checkOnERC721Received(from, to, tokenId, data), "ERC721: transfer to non ERC721Receiver implementer");
    }

    /**
     * @dev Returns whether `tokenId` exists.
     *
     * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
     *
     * Tokens start existing when they are minted (`_mint`),
     * and stop existing when they are burned (`_burn`).
     */
    function _exists(uint256 tokenId) internal view virtual returns (bool) {
        return _owners[tokenId] != address(0);
    }

    /**
     * @dev Returns whether `spender` is allowed to manage `tokenId`.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {
        address owner = ERC721.ownerOf(tokenId);
        return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender);
    }

    /**
     * @dev Safely mints `tokenId` and transfers it to `to`.
     *
     * Requirements:
     *
     * - `tokenId` must not exist.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function _safeMint(address to, uint256 tokenId) internal virtual {
        _safeMint(to, tokenId, "");
    }

    /**
     * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
     * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
     */
    function _safeMint(
        address to,
        uint256 tokenId,
        bytes memory data
    ) internal virtual {
        _mint(to, tokenId);
        require(
            _checkOnERC721Received(address(0), to, tokenId, data),
            "ERC721: transfer to non ERC721Receiver implementer"
        );
    }

    /**
     * @dev Mints `tokenId` and transfers it to `to`.
     *
     * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
     *
     * Requirements:
     *
     * - `tokenId` must not exist.
     * - `to` cannot be the zero address.
     *
     * Emits a {Transfer} event.
     */
    function _mint(address to, uint256 tokenId) internal virtual {
        require(to != address(0), "ERC721: mint to the zero address");
        require(!_exists(tokenId), "ERC721: token already minted");

        _beforeTokenTransfer(address(0), to, tokenId);

        _balances[to] += 1;
        _owners[tokenId] = to;

        emit Transfer(address(0), to, tokenId);

        _afterTokenTransfer(address(0), to, tokenId);
    }

    /**
     * @dev Destroys `tokenId`.
     * The approval is cleared when the token is burned.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     *
     * Emits a {Transfer} event.
     */
    function _burn(uint256 tokenId) internal virtual {
        address owner = ERC721.ownerOf(tokenId);

        _beforeTokenTransfer(owner, address(0), tokenId);

        // Clear approvals
        _approve(address(0), tokenId);

        _balances[owner] -= 1;
        delete _owners[tokenId];

        emit Transfer(owner, address(0), tokenId);

        _afterTokenTransfer(owner, address(0), tokenId);
    }

    /**
     * @dev Transfers `tokenId` from `from` to `to`.
     *  As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     *
     * Emits a {Transfer} event.
     */
    function _transfer(
        address from,
        address to,
        uint256 tokenId
    ) internal virtual {
        require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner");
        require(to != address(0), "ERC721: transfer to the zero address");

        _beforeTokenTransfer(from, to, tokenId);

        // Clear approvals from the previous owner
        _approve(address(0), tokenId);

        _balances[from] -= 1;
        _balances[to] += 1;
        _owners[tokenId] = to;

        emit Transfer(from, to, tokenId);

        _afterTokenTransfer(from, to, tokenId);
    }

    /**
     * @dev Approve `to` to operate on `tokenId`
     *
     * Emits an {Approval} event.
     */
    function _approve(address to, uint256 tokenId) internal virtual {
        _tokenApprovals[tokenId] = to;
        emit Approval(ERC721.ownerOf(tokenId), to, tokenId);
    }

    /**
     * @dev Approve `operator` to operate on all of `owner` tokens
     *
     * Emits an {ApprovalForAll} event.
     */
    function _setApprovalForAll(
        address owner,
        address operator,
        bool approved
    ) internal virtual {
        require(owner != operator, "ERC721: approve to caller");
        _operatorApprovals[owner][operator] = approved;
        emit ApprovalForAll(owner, operator, approved);
    }

    /**
     * @dev Reverts if the `tokenId` has not been minted yet.
     */
    function _requireMinted(uint256 tokenId) internal view virtual {
        require(_exists(tokenId), "ERC721: invalid token ID");
    }

    /**
     * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
     * The call is not executed if the target address is not a contract.
     *
     * @param from address representing the previous owner of the given token ID
     * @param to target address that will receive the tokens
     * @param tokenId uint256 ID of the token to be transferred
     * @param data bytes optional data to send along with the call
     * @return bool whether the call correctly returned the expected magic value
     */
    function _checkOnERC721Received(
        address from,
        address to,
        uint256 tokenId,
        bytes memory data
    ) private returns (bool) {
        if (to.isContract()) {
            try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) {
                return retval == IERC721Receiver.onERC721Received.selector;
            } catch (bytes memory reason) {
                if (reason.length == 0) {
                    revert("ERC721: transfer to non ERC721Receiver implementer");
                } else {
                    /// @solidity memory-safe-assembly
                    assembly {
                        revert(add(32, reason), mload(reason))
                    }
                }
            }
        } else {
            return true;
        }
    }

    /**
     * @dev Hook that is called before any token transfer. This includes minting
     * and burning.
     *
     * Calling conditions:
     *
     * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
     * transferred to `to`.
     * - When `from` is zero, `tokenId` will be minted for `to`.
     * - When `to` is zero, ``from``'s `tokenId` will be burned.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(
        address from,
        address to,
        uint256 tokenId
    ) internal virtual {}

    /**
     * @dev Hook that is called after any transfer of tokens. This includes
     * minting and burning.
     *
     * Calling conditions:
     *
     * - when `from` and `to` are both non-zero.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _afterTokenTransfer(
        address from,
        address to,
        uint256 tokenId
    ) internal virtual {}
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/IERC721.sol)

pragma solidity ^0.8.0;

import "IERC165.sol";

/**
 * @dev Required interface of an ERC721 compliant contract.
 */
interface IERC721 is IERC165 {
    /**
     * @dev Emitted when `tokenId` token is transferred from `from` to `to`.
     */
    event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
     */
    event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
     */
    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);

    /**
     * @dev Returns the number of tokens in ``owner``'s account.
     */
    function balanceOf(address owner) external view returns (uint256 balance);

    /**
     * @dev Returns the owner of the `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function ownerOf(uint256 tokenId) external view returns (address owner);

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId,
        bytes calldata data
    ) external;

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
     * are aware of the ERC721 protocol to prevent tokens from being forever locked.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external;

    /**
     * @dev Transfers `tokenId` token from `from` to `to`.
     *
     * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external;

    /**
     * @dev Gives permission to `to` to transfer `tokenId` token to another account.
     * The approval is cleared when the token is transferred.
     *
     * Only a single account can be approved at a time, so approving the zero address clears previous approvals.
     *
     * Requirements:
     *
     * - The caller must own the token or be an approved operator.
     * - `tokenId` must exist.
     *
     * Emits an {Approval} event.
     */
    function approve(address to, uint256 tokenId) external;

    /**
     * @dev Approve or remove `operator` as an operator for the caller.
     * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
     *
     * Requirements:
     *
     * - The `operator` cannot be the caller.
     *
     * Emits an {ApprovalForAll} event.
     */
    function setApprovalForAll(address operator, bool _approved) external;

    /**
     * @dev Returns the account approved for `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function getApproved(uint256 tokenId) external view returns (address operator);

    /**
     * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
     *
     * See {setApprovalForAll}
     */
    function isApprovedForAll(address owner, address operator) external view returns (bool);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[EIP].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165 {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}

File 6 of 21 : IERC721Receiver.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)

pragma solidity ^0.8.0;

/**
 * @title ERC721 token receiver interface
 * @dev Interface for any contract that wants to support safeTransfers
 * from ERC721 asset contracts.
 */
interface IERC721Receiver {
    /**
     * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
     * by `operator` from `from`, this function is called.
     *
     * It must return its Solidity selector to confirm the token transfer.
     * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
     *
     * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.
     */
    function onERC721Received(
        address operator,
        address from,
        uint256 tokenId,
        bytes calldata data
    ) external returns (bytes4);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)

pragma solidity ^0.8.0;

import "IERC721.sol";

/**
 * @title ERC-721 Non-Fungible Token Standard, optional metadata extension
 * @dev See https://eips.ethereum.org/EIPS/eip-721
 */
interface IERC721Metadata is IERC721 {
    /**
     * @dev Returns the token collection name.
     */
    function name() external view returns (string memory);

    /**
     * @dev Returns the token collection symbol.
     */
    function symbol() external view returns (string memory);

    /**
     * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
     */
    function tokenURI(uint256 tokenId) external view returns (string memory);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @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
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 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
                /// @solidity memory-safe-assembly
                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

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

pragma solidity ^0.8.0;

/**
 * @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 Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)

pragma solidity ^0.8.0;

/**
 * @dev String operations.
 */
library Strings {
    bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
    uint8 private constant _ADDRESS_LENGTH = 20;

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        // Inspired by OraclizeAPI's implementation - MIT licence
        // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol

        if (value == 0) {
            return "0";
        }
        uint256 temp = value;
        uint256 digits;
        while (temp != 0) {
            digits++;
            temp /= 10;
        }
        bytes memory buffer = new bytes(digits);
        while (value != 0) {
            digits -= 1;
            buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
            value /= 10;
        }
        return string(buffer);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        if (value == 0) {
            return "0x00";
        }
        uint256 temp = value;
        uint256 length = 0;
        while (temp != 0) {
            length++;
            temp >>= 8;
        }
        return toHexString(value, length);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
     */
    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
        bytes memory buffer = new bytes(2 * length + 2);
        buffer[0] = "0";
        buffer[1] = "x";
        for (uint256 i = 2 * length + 1; i > 1; --i) {
            buffer[i] = _HEX_SYMBOLS[value & 0xf];
            value >>= 4;
        }
        require(value == 0, "Strings: hex length insufficient");
        return string(buffer);
    }

    /**
     * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
     */
    function toHexString(address addr) internal pure returns (string memory) {
        return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)

pragma solidity ^0.8.0;

import "IERC165.sol";

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
 * for the additional interface id that will be supported. For example:
 *
 * ```solidity
 * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
 *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
 * }
 * ```
 *
 * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
 */
abstract contract ERC165 is IERC165 {
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IERC165).interfaceId;
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/AccessControl.sol)

pragma solidity ^0.8.0;

import "IAccessControl.sol";
import "Context.sol";
import "Strings.sol";
import "ERC165.sol";

/**
 * @dev Contract module that allows children to implement role-based access
 * control mechanisms. This is a lightweight version that doesn't allow enumerating role
 * members except through off-chain means by accessing the contract event logs. Some
 * applications may benefit from on-chain enumerability, for those cases see
 * {AccessControlEnumerable}.
 *
 * Roles are referred to by their `bytes32` identifier. These should be exposed
 * in the external API and be unique. The best way to achieve this is by
 * using `public constant` hash digests:
 *
 * ```
 * bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
 * ```
 *
 * Roles can be used to represent a set of permissions. To restrict access to a
 * function call, use {hasRole}:
 *
 * ```
 * function foo() public {
 *     require(hasRole(MY_ROLE, msg.sender));
 *     ...
 * }
 * ```
 *
 * Roles can be granted and revoked dynamically via the {grantRole} and
 * {revokeRole} functions. Each role has an associated admin role, and only
 * accounts that have a role's admin role can call {grantRole} and {revokeRole}.
 *
 * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
 * that only accounts with this role will be able to grant or revoke other
 * roles. More complex role relationships can be created by using
 * {_setRoleAdmin}.
 *
 * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
 * grant and revoke this role. Extra precautions should be taken to secure
 * accounts that have been granted it.
 */
abstract contract AccessControl is Context, IAccessControl, ERC165 {
    struct RoleData {
        mapping(address => bool) members;
        bytes32 adminRole;
    }

    mapping(bytes32 => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

    /**
     * @dev Modifier that checks that an account has a specific role. Reverts
     * with a standardized message including the required role.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
     *
     * _Available since v4.1._
     */
    modifier onlyRole(bytes32 role) {
        _checkRole(role);
        _;
    }

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
    }

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) public view virtual override returns (bool) {
        return _roles[role].members[account];
    }

    /**
     * @dev Revert with a standard message if `_msgSender()` is missing `role`.
     * Overriding this function changes the behavior of the {onlyRole} modifier.
     *
     * Format of the revert message is described in {_checkRole}.
     *
     * _Available since v4.6._
     */
    function _checkRole(bytes32 role) internal view virtual {
        _checkRole(role, _msgSender());
    }

    /**
     * @dev Revert with a standard message if `account` is missing `role`.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
     */
    function _checkRole(bytes32 role, address account) internal view virtual {
        if (!hasRole(role, account)) {
            revert(
                string(
                    abi.encodePacked(
                        "AccessControl: account ",
                        Strings.toHexString(uint160(account), 20),
                        " is missing role ",
                        Strings.toHexString(uint256(role), 32)
                    )
                )
            );
        }
    }

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {
        return _roles[role].adminRole;
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     *
     * May emit a {RoleGranted} event.
     */
    function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
        _grantRole(role, account);
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     *
     * May emit a {RoleRevoked} event.
     */
    function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
        _revokeRole(role, account);
    }

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been revoked `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `account`.
     *
     * May emit a {RoleRevoked} event.
     */
    function renounceRole(bytes32 role, address account) public virtual override {
        require(account == _msgSender(), "AccessControl: can only renounce roles for self");

        _revokeRole(role, account);
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event. Note that unlike {grantRole}, this function doesn't perform any
     * checks on the calling account.
     *
     * May emit a {RoleGranted} event.
     *
     * [WARNING]
     * ====
     * This function should only be called from the constructor when setting
     * up the initial roles for the system.
     *
     * Using this function in any other way is effectively circumventing the admin
     * system imposed by {AccessControl}.
     * ====
     *
     * NOTE: This function is deprecated in favor of {_grantRole}.
     */
    function _setupRole(bytes32 role, address account) internal virtual {
        _grantRole(role, account);
    }

    /**
     * @dev Sets `adminRole` as ``role``'s admin role.
     *
     * Emits a {RoleAdminChanged} event.
     */
    function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
        bytes32 previousAdminRole = getRoleAdmin(role);
        _roles[role].adminRole = adminRole;
        emit RoleAdminChanged(role, previousAdminRole, adminRole);
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * Internal function without access restriction.
     *
     * May emit a {RoleGranted} event.
     */
    function _grantRole(bytes32 role, address account) internal virtual {
        if (!hasRole(role, account)) {
            _roles[role].members[account] = true;
            emit RoleGranted(role, account, _msgSender());
        }
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * Internal function without access restriction.
     *
     * May emit a {RoleRevoked} event.
     */
    function _revokeRole(bytes32 role, address account) internal virtual {
        if (hasRole(role, account)) {
            _roles[role].members[account] = false;
            emit RoleRevoked(role, account, _msgSender());
        }
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)

pragma solidity ^0.8.0;

/**
 * @dev External interface of AccessControl declared to support ERC165 detection.
 */
interface IAccessControl {
    /**
     * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
     *
     * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
     * {RoleAdminChanged} not being emitted signaling this.
     *
     * _Available since v3.1._
     */
    event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);

    /**
     * @dev Emitted when `account` is granted `role`.
     *
     * `sender` is the account that originated the contract call, an admin role
     * bearer except when using {AccessControl-_setupRole}.
     */
    event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Emitted when `account` is revoked `role`.
     *
     * `sender` is the account that originated the contract call:
     *   - if using `revokeRole`, it is the admin role bearer
     *   - if using `renounceRole`, it is the role bearer (i.e. `account`)
     */
    event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) external view returns (bool);

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {AccessControl-_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) external view returns (bytes32);

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function grantRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function revokeRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been granted `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `account`.
     */
    function renounceRole(bytes32 role, address account) external;
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

import "IERC20.sol";
import "draft-IERC20Permit.sol";
import "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));
        }
    }

    function safePermit(
        IERC20Permit token,
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal {
        uint256 nonceBefore = token.nonces(owner);
        token.permit(owner, spender, value, deadline, v, r, s);
        uint256 nonceAfter = token.nonces(owner);
        require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
    }

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

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

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

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

    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

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

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

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

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

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
 * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
 * need to send a transaction, and thus is not required to hold Ether at all.
 */
interface IERC20Permit {
    /**
     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
     * given ``owner``'s signed approval.
     *
     * IMPORTANT: The same issues {IERC20-approve} has related to transaction
     * ordering also apply here.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `deadline` must be a timestamp in the future.
     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
     * over the EIP712-formatted function arguments.
     * - the signature must use ``owner``'s current nonce (see {nonces}).
     *
     * For more information on the signature format, see the
     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
     * section].
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

    /**
     * @dev Returns the current nonce for `owner`. This value must be
     * included whenever a signature is generated for {permit}.
     *
     * Every successful call to {permit} increases ``owner``'s nonce by one. This
     * prevents a signature from being used multiple times.
     */
    function nonces(address owner) external view returns (uint256);

    /**
     * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
     */
    // solhint-disable-next-line func-name-mixedcase
    function DOMAIN_SEPARATOR() external view returns (bytes32);
}

File 17 of 21 : Interfaces.sol
// SPDX-License-Identifier: BUSL-1.1
import "ERC20.sol";

pragma solidity 0.8.4;

interface ICircuitBreaker {
    struct MarketPoolPair {
        address market;
        address pool;
    }
    struct Configs {
        int256 value;
        address contractAddress;
    }
    struct OverallStats {
        address contractAddress;
        int256 loss;
        int256 sf;
        int256 lp_sf;
        int256 net_loss;
    }
    struct MarketStats {
        address pool;
        int256 loss;
        int256 sf;
    }
    struct PoolStats {
        address[] markets;
        int256 loss;
        int256 sf;
    }

    function update(int256 loss, int256 sf, uint256 option_id) external;

    event Update(
        int256 loss,
        int256 sf,
        address market,
        address pool,
        uint256 option_id
    );

    event MarketPaused(address market, address pool);
    event PoolPaused(address pool);
}

interface IBooster {
    struct UserBoostTrades {
        uint256 totalBoostTrades;
        uint256 totalBoostTradesUsed;
    }

    function getUserBoostData(
        address user,
        address token
    ) external view returns (UserBoostTrades memory);

    function updateUserBoost(address user, address token) external;

    function getBoostPercentage(
        address user,
        address token
    ) external view returns (uint256);

    struct Permit {
        uint256 value;
        uint256 deadline;
        uint8 v;
        bytes32 r;
        bytes32 s;
        bool shouldApprove;
    }
    event ApproveTokenX(
        address user,
        uint256 nonce,
        uint256 value,
        uint256 deadline,
        address tokenX
    );
    event BuyCoupon(address indexed token, address indexed user, uint256 price);
    event SetPrice(uint256 couponPrice);
    event SetBoostPercentage(uint256 boost);
    event UpdateBoostTradesUser(address indexed user, address indexed token);
    event Configure(uint8[4] nftTierDiscounts);
}

interface IAccountRegistrar {
    struct AccountMapping {
        address oneCT;
        uint256 nonce;
    }
    event RegisterAccount(
        address indexed user,
        address indexed oneCT,
        uint256 nonce
    );
    event DeregisterAccount(address indexed account, uint256 nonce);

    function accountMapping(
        address
    ) external view returns (address oneCT, uint256 nonce);

    function registerAccount(
        address oneCT,
        address user,
        bytes memory signature
    ) external;
}

interface IBufferRouter {
    struct QueuedTrade {
        address user;
        address targetContract;
        uint128 strike;
        uint32 expiration;
        uint256 contracts;
        bool allowPartialFill;
        bool isQueued;
        uint256 optionId;
        bool isAbove;
        uint32 queuedTime;
        uint256 maxFeePerContract;
        string referralCode;
        uint256 totalFee;
    }

    struct OptionInfo {
        uint256 queueId;
        address signer;
        uint256 nonce;
    }

    struct SignInfo {
        bytes signature;
        uint32 timestamp;
    }
    struct TradeInitiationParamas {
        address targetContract;
        bool allowPartialFill;
        string referralCode;
        bool isAbove;
        uint256 totalFee;
        uint128 strike;
        uint32 expiration;
        uint256 maxFeePerContract;
    }

    struct ResolveTradeParams {
        uint256 queueId;
        uint256 iv;
        uint256 sf;
        SignInfo publisherSignInfo;
        SignInfo sfSignInfo;
        bytes[] priceUpdateData;
        bytes32[] priceIds;
    }

    struct Register {
        address oneCT;
        bytes signature;
        bool shouldRegister;
    }

    struct CloseTradeParams {
        uint256 optionId;
        address targetContract;
        bytes[] priceUpdateData;
        bytes32[] priceIds;
    }

    struct IdMapping {
        uint256 id;
        bool isSet;
    }

    event OpenTrade(
        address indexed user,
        uint256 indexed queueId,
        uint256 indexed optionId,
        address targetContract,
        uint256 contracts
    );
    event CancelTrade(address indexed account, uint256 queueId, string reason);
    event FailUnlock(
        uint256 indexed optionId,
        address targetContract,
        string reason
    );
    event FailResolve(uint256 indexed queueId, string reason);
    event FailRevoke(address indexed user, address tokenX, string reason);
    event ContractRegistryUpdated(address targetContract, bool register);

    event InitiateTrade(
        address indexed user,
        uint256 queueId,
        uint256 timestamp
    );
}

interface IBufferBinaryOptions {
    event Create(
        address indexed account,
        uint256 indexed id,
        uint256 settlementFee,
        uint256 totalFee,
        int256 skew,
        bytes32 marketId
    );
    event CreateMarket(
        uint128 strike,
        uint32 expiration,
        bytes32 marketId,
        address optionsContract
    );

    event Exercise(
        address indexed account,
        uint256 indexed id,
        uint256 profit,
        uint256 priceAtExpiration,
        bool isAbove
    );
    event Expire(
        uint256 indexed id,
        uint256 premium,
        uint256 priceAtExpiration,
        bool isAbove
    );
    event Pause(bool isPaused);
    event UpdateReferral(
        address user,
        address referrer,
        bool isReferralValid,
        uint256 totalFee,
        uint256 referrerFee,
        uint256 rebate,
        string referralCode
    );

    event LpProfit(uint256 indexed id, uint256 amount);
    event LpLoss(uint256 indexed id, uint256 amount);

    function createFromRouter(
        OptionParams calldata optionParams,
        uint32 queuedTime
    ) external returns (uint256 optionID);

    function evaluateParams(
        OptionParams calldata optionParams
    )
        external
        view
        returns (
            uint256 amount,
            uint256 fee,
            uint256 revisedContracts,
            uint256 revisedSf
        );

    function tokenX() external view returns (ERC20);

    function pool() external view returns (ILiquidityPool);

    function config() external view returns (IOptionsConfig);

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

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

    function ownerOf(uint256 id) external view returns (address);

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

    function totalMarketOI() external view returns (uint256);

    enum State {
        Inactive,
        Active,
        Exercised,
        Expired
    }

    enum AssetCategory {
        Forex,
        Crypto,
        Commodities
    }
    struct OptionExpiryData {
        uint256 optionId;
        uint256 priceAtExpiration;
    }

    event CreateOptionsContract(
        address config,
        address pool,
        address tokenX,
        string token0,
        string token1,
        AssetCategory category
    );
    struct Option {
        State state;
        uint128 strike;
        uint256 amount;
        uint256 lockedAmount;
        uint256 premium;
        uint32 expiration;
        uint256 totalFee;
        uint32 createdAt;
        bool isAbove;
    }
    struct OptionParams {
        address user;
        uint256 sf;
        uint256 iv;
        bool allowPartialFill;
        bool isAbove;
        uint256 contracts;
        uint128 strike;
        uint32 expiration;
        uint256 amount;
        uint256 totalFee;
        uint256 maxFeePerContract;
        uint256 currentPrice;
        string referralCode;
    }

    function options(
        uint256 optionId
    )
        external
        view
        returns (
            State state,
            uint128 strike,
            uint256 amount,
            uint256 lockedAmount,
            uint256 premium,
            uint32 expiration,
            uint256 totalFee,
            uint32 createdAt,
            bool isAbove
        );

    function unlock(uint256 optionID, uint256 closingPrice) external;

    function runInitialChecks(uint128 strike, uint32 expiration) external;
}

interface IBufferBinaryOptionPauserV2_5 {
    function isPaused() external view returns (bool);

    function setIsPaused() external;
}

interface IBufferBinaryOptionPauserV2 {
    function isPaused() external view returns (bool);

    function toggleCreation() external;
}

interface ILiquidityPool {
    struct LockedAmount {
        uint256 timestamp;
        uint256 amount;
    }
    struct ProvidedLiquidity {
        uint256 unlockedAmount;
        LockedAmount[] lockedAmounts;
        uint256 nextIndexForUnlock;
    }
    struct LockedLiquidity {
        uint256 amount;
        uint256 premium;
        bool locked;
    }
    event Profit(uint256 indexed id, uint256 amount);
    event Loss(uint256 indexed id, uint256 amount);
    event Provide(address indexed account, uint256 amount, uint256 writeAmount);
    event UpdateMaxLiquidity(uint256 indexed maxLiquidity);
    event Withdraw(
        address indexed account,
        uint256 amount,
        uint256 writeAmount
    );

    function unlock(uint256 id) external;

    function totalTokenXBalance() external view returns (uint256 amount);

    function availableBalance() external view returns (uint256 balance);

    function send(uint256 id, address account, uint256 amount) external;

    function lock(uint256 id, uint256 tokenXAmount, uint256 premium) external;
}

interface IOptionsConfig {
    event UpdateSettlementFeeDisbursalContract(address value);
    event UpdatetraderNFTContract(address value);
    event UpdateOptionStorageContract(address value);
    event UpdateCreationWindowContract(address value);
    event UpdatePlatformFee(uint256 _platformFee);
    event UpdateIV(uint32 _iv);
    event UpdateMaxSkew(int256 _maxSkew);

    event UpdateCircuitBreakerContract(address _circuitBreakerContract);
    event UpdateSf(uint256 sf);
    event UpdatePayout(uint256 payout);
    event UpdateStrikeStepSize(uint128 strikeStepSize);

    function maxSkew() external view returns (int256);

    function circuitBreakerContract() external view returns (address);

    function settlementFeeDisbursalContract() external view returns (address);

    function platformFee() external view returns (uint256);

    function payout() external view returns (uint256);

    function optionStorageContract() external view returns (address);

    function creationWindowContract() external view returns (address);

    function strikeStepSize() external view returns (uint128);
}

interface ITraderNFT {
    function tokenOwner(uint256 id) external view returns (address user);

    function tokenTierMappings(uint256 id) external view returns (uint8 tier);

    event UpdateTiers(uint256[] tokenIds, uint8[] tiers, uint256[] batchIds);
}

interface IFakeTraderNFT {
    function tokenOwner(uint256 id) external view returns (address user);

    function tokenTierMappings(uint256 id) external view returns (uint8 tier);

    event UpdateNftBasePrice(uint256 nftBasePrice);
    event UpdateMaxNFTMintLimits(uint256 maxNFTMintLimit);
    event UpdateBaseURI(string baseURI);
    event Claim(address indexed account, uint256 claimTokenId);
    event Mint(address indexed account, uint256 tokenId, uint8 tier);
}

interface IReferralStorage {
    function codeOwner(string memory _code) external view returns (address);

    function traderReferralCodes(address) external view returns (string memory);

    function getTraderReferralInfo(
        address user
    ) external view returns (string memory, address);

    function setTraderReferralCode(address user, string memory _code) external;

    function setReferrerTier(address, uint8) external;

    function referrerTierStep(
        uint8 referralTier
    ) external view returns (uint8 step);

    function referrerTierDiscount(
        uint8 referralTier
    ) external view returns (uint32 discount);

    function referrerTier(address referrer) external view returns (uint8 tier);

    struct ReferrerData {
        uint256 tradeVolume;
        uint256 rebate;
        uint256 trades;
    }

    struct ReferreeData {
        uint256 tradeVolume;
        uint256 rebate;
    }

    struct ReferralData {
        ReferrerData referrerData;
        ReferreeData referreeData;
    }

    struct Tier {
        uint256 totalRebate; // e.g. 2400 for 24%
        uint256 discountShare; // 5000 for 50%/50%, 7000 for 30% rebates/70% discount
    }

    event UpdateTraderReferralCode(address indexed account, string code);
    event UpdateReferrerTier(address referrer, uint8 tierId);
    event RegisterCode(address indexed account, string code);
    event SetCodeOwner(
        address indexed account,
        address newAccount,
        string code
    );
}

interface IOptionStorage {
    function save(
        uint256 optionId,
        address optionsContract,
        address user
    ) external;
}

interface ICreationWindowContract {
    function isInCreationWindow(uint256 period) external view returns (bool);
}

interface IPoolOIStorage {
    function updatePoolOI(bool isIncreased, uint256 interest) external;

    function totalPoolOI() external view returns (uint256);
}

interface IPoolOIConfig {
    function getMaxPoolOI() external view returns (uint256);

    function getPoolOICap() external view returns (uint256);
}

interface IMarketOIConfig {
    function getMaxMarketOI(
        uint256 currentMarketOI
    ) external view returns (uint256);

    function getMarketOICap() external view returns (uint256);
}

interface IMarket {
    struct Market {
        uint256 strike;
        uint32 expiration;
        uint256 maxSkew;
        uint256 skewUp;
        uint256 skewDown;
        bool isEnabled;
    }

    function market(bytes32 marketId) external view returns (Market memory);

    function updateMarketSkew(
        bytes32 marketId,
        bool isAbove,
        uint256 loss
    ) external;

    function maxContractsAllowed(
        bytes32 marketId,
        uint256 lossPerContract,
        bool isAbove
    ) external view returns (uint256);
}

/// @title Consume prices from the Pyth Network (https://pyth.network/).
/// @dev Please refer to the guidance at https://docs.pyth.network/consumers/best-practices for how to consume prices safely.
/// @author Pyth Data Association
interface IPyth {
    /// @notice Returns the period (in seconds) that a price feed is considered valid since its publish time
    function getValidTimePeriod() external view returns (uint validTimePeriod);

    /// @notice Returns the price and confidence interval.
    /// @dev Reverts if the price has not been updated within the last `getValidTimePeriod()` seconds.
    /// @param id The Pyth Price Feed ID of which to fetch the price and confidence interval.
    /// @return price - please read the documentation of Price to understand how to use this safely.
    function getPrice(bytes32 id) external view returns (Price memory price);

    /// @notice Returns the exponentially-weighted moving average price and confidence interval.
    /// @dev Reverts if the EMA price is not available.
    /// @param id The Pyth Price Feed ID of which to fetch the EMA price and confidence interval.
    /// @return price - please read the documentation of Price to understand how to use this safely.
    function getEmaPrice(bytes32 id) external view returns (Price memory price);

    /// @notice Returns the price of a price feed without any sanity checks.
    /// @dev This function returns the most recent price update in this contract without any recency checks.
    /// This function is unsafe as the returned price update may be arbitrarily far in the past.
    ///
    /// Users of this function should check the `publishTime` in the price to ensure that the returned price is
    /// sufficiently recent for their application. If you are considering using this function, it may be
    /// safer / easier to use either `getPrice` or `getPriceNoOlderThan`.
    /// @return price - please read the documentation of Price to understand how to use this safely.
    function getPriceUnsafe(
        bytes32 id
    ) external view returns (Price memory price);

    /// @notice Returns the price that is no older than `age` seconds of the current time.
    /// @dev This function is a sanity-checked version of `getPriceUnsafe` which is useful in
    /// applications that require a sufficiently-recent price. Reverts if the price wasn't updated sufficiently
    /// recently.
    /// @return price - please read the documentation of Price to understand how to use this safely.
    function getPriceNoOlderThan(
        bytes32 id,
        uint age
    ) external view returns (Price memory price);

    /// @notice Returns the exponentially-weighted moving average price of a price feed without any sanity checks.
    /// @dev This function returns the same price as `getEmaPrice` in the case where the price is available.
    /// However, if the price is not recent this function returns the latest available price.
    ///
    /// The returned price can be from arbitrarily far in the past; this function makes no guarantees that
    /// the returned price is recent or useful for any particular application.
    ///
    /// Users of this function should check the `publishTime` in the price to ensure that the returned price is
    /// sufficiently recent for their application. If you are considering using this function, it may be
    /// safer / easier to use either `getEmaPrice` or `getEmaPriceNoOlderThan`.
    /// @return price - please read the documentation of Price to understand how to use this safely.
    function getEmaPriceUnsafe(
        bytes32 id
    ) external view returns (Price memory price);

    /// @notice Returns the exponentially-weighted moving average price that is no older than `age` seconds
    /// of the current time.
    /// @dev This function is a sanity-checked version of `getEmaPriceUnsafe` which is useful in
    /// applications that require a sufficiently-recent price. Reverts if the price wasn't updated sufficiently
    /// recently.
    /// @return price - please read the documentation of Price to understand how to use this safely.
    function getEmaPriceNoOlderThan(
        bytes32 id,
        uint age
    ) external view returns (Price memory price);

    /// @notice Update price feeds with given update messages.
    /// This method requires the caller to pay a fee in wei; the required fee can be computed by calling
    /// `getUpdateFee` with the length of the `updateData` array.
    /// Prices will be updated if they are more recent than the current stored prices.
    /// The call will succeed even if the update is not the most recent.
    /// @dev Reverts if the transferred fee is not sufficient or the updateData is invalid.
    /// @param updateData Array of price update data.
    function updatePriceFeeds(bytes[] calldata updateData) external payable;

    /// @notice Wrapper around updatePriceFeeds that rejects fast if a price update is not necessary. A price update is
    /// necessary if the current on-chain publishTime is older than the given publishTime. It relies solely on the
    /// given `publishTimes` for the price feeds and does not read the actual price update publish time within `updateData`.
    ///
    /// This method requires the caller to pay a fee in wei; the required fee can be computed by calling
    /// `getUpdateFee` with the length of the `updateData` array.
    ///
    /// `priceIds` and `publishTimes` are two arrays with the same size that correspond to senders known publishTime
    /// of each priceId when calling this method. If all of price feeds within `priceIds` have updated and have
    /// a newer or equal publish time than the given publish time, it will reject the transaction to save gas.
    /// Otherwise, it calls updatePriceFeeds method to update the prices.
    ///
    /// @dev Reverts if update is not needed or the transferred fee is not sufficient or the updateData is invalid.
    /// @param updateData Array of price update data.
    /// @param priceIds Array of price ids.
    /// @param publishTimes Array of publishTimes. `publishTimes[i]` corresponds to known `publishTime` of `priceIds[i]`
    function updatePriceFeedsIfNecessary(
        bytes[] calldata updateData,
        bytes32[] calldata priceIds,
        uint64[] calldata publishTimes
    ) external payable;

    /// @notice Returns the required fee to update an array of price updates.
    /// @param updateData Array of price update data.
    /// @return feeAmount The required fee in Wei.
    function getUpdateFee(
        bytes[] calldata updateData
    ) external view returns (uint feeAmount);

    /// @notice Parse `updateData` and return price feeds of the given `priceIds` if they are all published
    /// within `minPublishTime` and `maxPublishTime`.
    ///
    /// You can use this method if you want to use a Pyth price at a fixed time and not the most recent price;
    /// otherwise, please consider using `updatePriceFeeds`. This method does not store the price updates on-chain.
    ///
    /// This method requires the caller to pay a fee in wei; the required fee can be computed by calling
    /// `getUpdateFee` with the length of the `updateData` array.
    ///
    ///
    /// @dev Reverts if the transferred fee is not sufficient or the updateData is invalid or there is
    /// no update for any of the given `priceIds` within the given time range.
    /// @param updateData Array of price update data.
    /// @param priceIds Array of price ids.
    /// @param minPublishTime minimum acceptable publishTime for the given `priceIds`.
    /// @param maxPublishTime maximum acceptable publishTime for the given `priceIds`.
    /// @return priceFeeds Array of the price feeds corresponding to the given `priceIds` (with the same order).
    function parsePriceFeedUpdates(
        bytes[] calldata updateData,
        bytes32[] calldata priceIds,
        uint64 minPublishTime,
        uint64 maxPublishTime
    ) external payable returns (PriceFeed[] memory priceFeeds);

    struct Price {
        // Price
        int64 price;
        // Confidence interval around the price
        uint64 conf;
        // Price exponent
        int32 expo;
        // Unix timestamp describing when the price was published
        uint publishTime;
    }
    struct PriceFeed {
        // The price ID.
        bytes32 id;
        // Latest available price
        Price price;
        // Latest available exponentially-weighted moving average price
        Price emaPrice;
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/ERC20.sol)

pragma solidity ^0.8.0;

import "IERC20.sol";
import "IERC20Metadata.sol";
import "Context.sol";

/**
 * @dev Implementation of the {IERC20} interface.
 *
 * This implementation is agnostic to the way tokens are created. This means
 * that a supply mechanism has to be added in a derived contract using {_mint}.
 * For a generic mechanism see {ERC20PresetMinterPauser}.
 *
 * TIP: For a detailed writeup see our guide
 * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
 * to implement supply mechanisms].
 *
 * We have followed general OpenZeppelin Contracts guidelines: functions revert
 * instead returning `false` on failure. This behavior is nonetheless
 * conventional and does not conflict with the expectations of ERC20
 * applications.
 *
 * Additionally, an {Approval} event is emitted on calls to {transferFrom}.
 * This allows applications to reconstruct the allowance for all accounts just
 * by listening to said events. Other implementations of the EIP may not emit
 * these events, as it isn't required by the specification.
 *
 * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
 * functions have been added to mitigate the well-known issues around setting
 * allowances. See {IERC20-approve}.
 */
contract ERC20 is Context, IERC20, IERC20Metadata {
    mapping(address => uint256) private _balances;

    mapping(address => mapping(address => uint256)) private _allowances;

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;

    /**
     * @dev Sets the values for {name} and {symbol}.
     *
     * The default value of {decimals} is 18. To select a different value for
     * {decimals} you should overload it.
     *
     * All two of these values are immutable: they can only be set once during
     * construction.
     */
    constructor(string memory name_, string memory symbol_) {
        _name = name_;
        _symbol = symbol_;
    }

    /**
     * @dev Returns the name of the token.
     */
    function name() public view virtual override returns (string memory) {
        return _name;
    }

    /**
     * @dev Returns the symbol of the token, usually a shorter version of the
     * name.
     */
    function symbol() public view virtual override returns (string memory) {
        return _symbol;
    }

    /**
     * @dev Returns the number of decimals used to get its user representation.
     * For example, if `decimals` equals `2`, a balance of `505` tokens should
     * be displayed to a user as `5.05` (`505 / 10 ** 2`).
     *
     * Tokens usually opt for a value of 18, imitating the relationship between
     * Ether and Wei. This is the value {ERC20} uses, unless this function is
     * overridden;
     *
     * NOTE: This information is only used for _display_ purposes: it in
     * no way affects any of the arithmetic of the contract, including
     * {IERC20-balanceOf} and {IERC20-transfer}.
     */
    function decimals() public view virtual override returns (uint8) {
        return 18;
    }

    /**
     * @dev See {IERC20-totalSupply}.
     */
    function totalSupply() public view virtual override returns (uint256) {
        return _totalSupply;
    }

    /**
     * @dev See {IERC20-balanceOf}.
     */
    function balanceOf(address account) public view virtual override returns (uint256) {
        return _balances[account];
    }

    /**
     * @dev See {IERC20-transfer}.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - the caller must have a balance of at least `amount`.
     */
    function transfer(address to, uint256 amount) public virtual override returns (bool) {
        address owner = _msgSender();
        _transfer(owner, to, amount);
        return true;
    }

    /**
     * @dev See {IERC20-allowance}.
     */
    function allowance(address owner, address spender) public view virtual override returns (uint256) {
        return _allowances[owner][spender];
    }

    /**
     * @dev See {IERC20-approve}.
     *
     * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on
     * `transferFrom`. This is semantically equivalent to an infinite approval.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function approve(address spender, uint256 amount) public virtual override returns (bool) {
        address owner = _msgSender();
        _approve(owner, spender, amount);
        return true;
    }

    /**
     * @dev See {IERC20-transferFrom}.
     *
     * Emits an {Approval} event indicating the updated allowance. This is not
     * required by the EIP. See the note at the beginning of {ERC20}.
     *
     * NOTE: Does not update the allowance if the current allowance
     * is the maximum `uint256`.
     *
     * Requirements:
     *
     * - `from` and `to` cannot be the zero address.
     * - `from` must have a balance of at least `amount`.
     * - the caller must have allowance for ``from``'s tokens of at least
     * `amount`.
     */
    function transferFrom(
        address from,
        address to,
        uint256 amount
    ) public virtual override returns (bool) {
        address spender = _msgSender();
        _spendAllowance(from, spender, amount);
        _transfer(from, to, amount);
        return true;
    }

    /**
     * @dev Atomically increases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
        address owner = _msgSender();
        _approve(owner, spender, allowance(owner, spender) + addedValue);
        return true;
    }

    /**
     * @dev Atomically decreases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `spender` must have allowance for the caller of at least
     * `subtractedValue`.
     */
    function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
        address owner = _msgSender();
        uint256 currentAllowance = allowance(owner, spender);
        require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
        unchecked {
            _approve(owner, spender, currentAllowance - subtractedValue);
        }

        return true;
    }

    /**
     * @dev Moves `amount` of tokens from `from` to `to`.
     *
     * This internal function is equivalent to {transfer}, and can be used to
     * e.g. implement automatic token fees, slashing mechanisms, etc.
     *
     * Emits a {Transfer} event.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `from` must have a balance of at least `amount`.
     */
    function _transfer(
        address from,
        address to,
        uint256 amount
    ) internal virtual {
        require(from != address(0), "ERC20: transfer from the zero address");
        require(to != address(0), "ERC20: transfer to the zero address");

        _beforeTokenTransfer(from, to, amount);

        uint256 fromBalance = _balances[from];
        require(fromBalance >= amount, "ERC20: transfer amount exceeds balance");
        unchecked {
            _balances[from] = fromBalance - amount;
        }
        _balances[to] += amount;

        emit Transfer(from, to, amount);

        _afterTokenTransfer(from, to, amount);
    }

    /** @dev Creates `amount` tokens and assigns them to `account`, increasing
     * the total supply.
     *
     * Emits a {Transfer} event with `from` set to the zero address.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     */
    function _mint(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: mint to the zero address");

        _beforeTokenTransfer(address(0), account, amount);

        _totalSupply += amount;
        _balances[account] += amount;
        emit Transfer(address(0), account, amount);

        _afterTokenTransfer(address(0), account, amount);
    }

    /**
     * @dev Destroys `amount` tokens from `account`, reducing the
     * total supply.
     *
     * Emits a {Transfer} event with `to` set to the zero address.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     * - `account` must have at least `amount` tokens.
     */
    function _burn(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: burn from the zero address");

        _beforeTokenTransfer(account, address(0), amount);

        uint256 accountBalance = _balances[account];
        require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
        unchecked {
            _balances[account] = accountBalance - amount;
        }
        _totalSupply -= amount;

        emit Transfer(account, address(0), amount);

        _afterTokenTransfer(account, address(0), amount);
    }

    /**
     * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
     *
     * This internal function is equivalent to `approve`, and can be used to
     * e.g. set automatic allowances for certain subsystems, etc.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `owner` cannot be the zero address.
     * - `spender` cannot be the zero address.
     */
    function _approve(
        address owner,
        address spender,
        uint256 amount
    ) internal virtual {
        require(owner != address(0), "ERC20: approve from the zero address");
        require(spender != address(0), "ERC20: approve to the zero address");

        _allowances[owner][spender] = amount;
        emit Approval(owner, spender, amount);
    }

    /**
     * @dev Updates `owner` s allowance for `spender` based on spent `amount`.
     *
     * Does not update the allowance amount in case of infinite allowance.
     * Revert if not enough allowance is available.
     *
     * Might emit an {Approval} event.
     */
    function _spendAllowance(
        address owner,
        address spender,
        uint256 amount
    ) internal virtual {
        uint256 currentAllowance = allowance(owner, spender);
        if (currentAllowance != type(uint256).max) {
            require(currentAllowance >= amount, "ERC20: insufficient allowance");
            unchecked {
                _approve(owner, spender, currentAllowance - amount);
            }
        }
    }

    /**
     * @dev Hook that is called before any transfer of tokens. This includes
     * minting and burning.
     *
     * Calling conditions:
     *
     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * will be transferred to `to`.
     * - when `from` is zero, `amount` tokens will be minted for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens will be burned.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(
        address from,
        address to,
        uint256 amount
    ) internal virtual {}

    /**
     * @dev Hook that is called after any transfer of tokens. This includes
     * minting and burning.
     *
     * Calling conditions:
     *
     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * has been transferred to `to`.
     * - when `from` is zero, `amount` tokens have been minted for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens have been burned.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _afterTokenTransfer(
        address from,
        address to,
        uint256 amount
    ) internal virtual {}
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)

pragma solidity ^0.8.0;

import "IERC20.sol";

/**
 * @dev Interface for the optional metadata functions from the ERC20 standard.
 *
 * _Available since v4.1._
 */
interface IERC20Metadata is IERC20 {
    /**
     * @dev Returns the name of the token.
     */
    function name() external view returns (string memory);

    /**
     * @dev Returns the symbol of the token.
     */
    function symbol() external view returns (string memory);

    /**
     * @dev Returns the decimals places of the token.
     */
    function decimals() external view returns (uint8);
}

// SPDX-License-Identifier: BUSL-1.1

pragma solidity 0.8.4;
import "ABDKMath64x64.sol";

library OptionMath {
    using ABDKMath64x64 for int128;

    // 64x64 fixed point integer constants
    int128 internal constant ONE_64x64 = 0x10000000000000000;
    int128 internal constant THREE_64x64 = 0x30000000000000000;

    // 64x64 fixed point constants used in Choudhury’s approximation of the Black-Scholes CDF
    int128 private constant CDF_CONST_0 = 0x09109f285df452394; // 2260 / 3989
    int128 private constant CDF_CONST_1 = 0x19abac0ea1da65036; // 6400 / 3989
    int128 private constant CDF_CONST_2 = 0x0d3c84b78b749bd6b; // 3300 / 3989

    /**
     * @notice calculate Choudhury’s approximation of the Black-Scholes CDF
     * @param input64x64 64x64 fixed point representation of random variable
     * @return 64x64 fixed point representation of the approximated CDF of x
     */
    function _N(int128 input64x64) internal pure returns (int128) {
        // squaring via mul is cheaper than via pow
        int128 inputSquared64x64 = input64x64.mul(input64x64);

        int128 value64x64 = (-inputSquared64x64 >> 1).exp().div(
            CDF_CONST_0.add(CDF_CONST_1.mul(input64x64.abs())).add(
                CDF_CONST_2.mul(inputSquared64x64.add(THREE_64x64).sqrt())
            )
        );

        return input64x64 > 0 ? ONE_64x64.sub(value64x64) : value64x64;
    }

    /**
     * @notice calculate the price of an option using the Black-Scholes model
     * @param impliedVol uint256 representation of annualized impliedVol with a factor of 1e4
     * @param strike uint256 representation of strike price with a factor of 1e8
     * @param spot uint256 representation of spot price with a factor of 1e8
     * @param period uint256 representation of duration of option contract (in seconds)
     * @param isYes whether to price "call" or "put" option
     * @param isAbove whether to the user bets the price will stay above this strike or not
     * @return uint256 representation of Black-Scholes option price with a factor of 1e8
     */
    function blackScholesPriceBinary(
        uint256 impliedVol,
        uint256 strike,
        uint256 spot,
        uint256 period,
        bool isYes,
        bool isAbove
    ) internal pure returns (uint256) {
        int128 D8 = ABDKMath64x64.fromUInt(10 ** 8);
        int128 D4 = ABDKMath64x64.fromUInt(10 ** 4);
        int128 impliedVol64x64 = ABDKMath64x64.fromUInt(impliedVol).div(D4);
        int128 variance64x64 = impliedVol64x64.mul(impliedVol64x64);
        int128 strike64x64 = ABDKMath64x64.fromUInt(strike).div(D8);
        int128 spot64x64 = ABDKMath64x64.fromUInt(spot).div(D8);
        int128 maturity64x64 = ABDKMath64x64.fromUInt(period).div(
            ABDKMath64x64.fromUInt(365 days)
        );

        int128 premium64x64 = _blackScholesPriceBinary(
            variance64x64,
            strike64x64,
            spot64x64,
            maturity64x64,
            isYes,
            isAbove
        );
        return ABDKMath64x64.toUInt(premium64x64.mul(D8));
    }

    /**
     * @notice calculate the price of an option using the Black-Scholes model
     * @param varianceAnnualized64x64 64x64 fixed point representation of annualized variance
     * @param strike64x64 64x64 fixed point representation of strike price
     * @param spot64x64 64x64 fixed point representation of spot price
     * @param timeToMaturity64x64 64x64 fixed point representation of duration of option contract (in years)
     * @param isYes whether to price "call" or "put" option
     * @param isAbove whether to the user bets the price will stay above this strike or not
     * @return 64x64 fixed point representation of Black-Scholes option price
     */
    function _blackScholesPriceBinary(
        int128 varianceAnnualized64x64,
        int128 strike64x64,
        int128 spot64x64,
        int128 timeToMaturity64x64,
        bool isYes,
        bool isAbove
    ) internal pure returns (int128) {
        int128 cumulativeVariance64x64 = timeToMaturity64x64.mul(
            varianceAnnualized64x64
        );
        int128 cumulativeVarianceSqrt64x64 = cumulativeVariance64x64.sqrt();

        int128 d1_64x64 = spot64x64
            .div(strike64x64)
            .ln()
            .add(cumulativeVariance64x64 >> 1)
            .div(cumulativeVarianceSqrt64x64);
        int128 d2_64x64 = d1_64x64.sub(cumulativeVarianceSqrt64x64);

        if (isYes) {
            if (isAbove) {
                return _N(d2_64x64);
            } else {
                return _N(-d2_64x64);
            }
        } else {
            if (isAbove) {
                return ABDKMath64x64.fromUInt(1).sub(_N(d2_64x64));
            } else {
                return ABDKMath64x64.fromUInt(1).sub(_N(-d2_64x64));
            }
        }
    }
}

// SPDX-License-Identifier: BUSL-1.1

pragma solidity 0.8.4;

/**
 * Smart contract library of mathematical functions operating with signed
 * 64.64-bit fixed point numbers.  Signed 64.64-bit fixed point number is
 * basically a simple fraction whose numerator is signed 128-bit integer and
 * denominator is 2^64.  As long as denominator is always the same, there is no
 * need to store it, thus in Solidity signed 64.64-bit fixed point numbers are
 * represented by int128 type holding only the numerator.
 */
library ABDKMath64x64 {
    /*
     * Minimum value signed 64.64-bit fixed point number may have.
     */
    int128 private constant MIN_64x64 = -0x80000000000000000000000000000000;

    /*
     * Maximum value signed 64.64-bit fixed point number may have.
     */
    int128 private constant MAX_64x64 = 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;

    /**
     * Convert signed 256-bit integer number into signed 64.64-bit fixed point
     * number.  Revert on overflow.
     *
     * @param x signed 256-bit integer number
     * @return signed 64.64-bit fixed point number
     */
    function fromInt(int256 x) internal pure returns (int128) {
        unchecked {
            require(x >= -0x8000000000000000 && x <= 0x7FFFFFFFFFFFFFFF);
            return int128(x << 64);
        }
    }

    /**
     * Convert signed 64.64 fixed point number into signed 64-bit integer number
     * rounding down.
     *
     * @param x signed 64.64-bit fixed point number
     * @return signed 64-bit integer number
     */
    function toInt(int128 x) internal pure returns (int64) {
        unchecked {
            return int64(x >> 64);
        }
    }

    /**
     * Convert unsigned 256-bit integer number into signed 64.64-bit fixed point
     * number.  Revert on overflow.
     *
     * @param x unsigned 256-bit integer number
     * @return signed 64.64-bit fixed point number
     */
    function fromUInt(uint256 x) internal pure returns (int128) {
        unchecked {
            require(x <= 0x7FFFFFFFFFFFFFFF);
            return int128(int256(x << 64));
        }
    }

    /**
     * Convert signed 64.64 fixed point number into unsigned 64-bit integer
     * number rounding down.  Revert on underflow.
     *
     * @param x signed 64.64-bit fixed point number
     * @return unsigned 64-bit integer number
     */
    function toUInt(int128 x) internal pure returns (uint64) {
        unchecked {
            require(x >= 0);
            return uint64(uint128(x >> 64));
        }
    }

    /**
     * Convert signed 128.128 fixed point number into signed 64.64-bit fixed point
     * number rounding down.  Revert on overflow.
     *
     * @param x signed 128.128-bin fixed point number
     * @return signed 64.64-bit fixed point number
     */
    function from128x128(int256 x) internal pure returns (int128) {
        unchecked {
            int256 result = x >> 64;
            require(result >= MIN_64x64 && result <= MAX_64x64);
            return int128(result);
        }
    }

    /**
     * Convert signed 64.64 fixed point number into signed 128.128 fixed point
     * number.
     *
     * @param x signed 64.64-bit fixed point number
     * @return signed 128.128 fixed point number
     */
    function to128x128(int128 x) internal pure returns (int256) {
        unchecked {
            return int256(x) << 64;
        }
    }

    /**
     * Calculate x + y.  Revert on overflow.
     *
     * @param x signed 64.64-bit fixed point number
     * @param y signed 64.64-bit fixed point number
     * @return signed 64.64-bit fixed point number
     */
    function add(int128 x, int128 y) internal pure returns (int128) {
        unchecked {
            int256 result = int256(x) + y;
            require(result >= MIN_64x64 && result <= MAX_64x64);
            return int128(result);
        }
    }

    /**
     * Calculate x - y.  Revert on overflow.
     *
     * @param x signed 64.64-bit fixed point number
     * @param y signed 64.64-bit fixed point number
     * @return signed 64.64-bit fixed point number
     */
    function sub(int128 x, int128 y) internal pure returns (int128) {
        unchecked {
            int256 result = int256(x) - y;
            require(result >= MIN_64x64 && result <= MAX_64x64);
            return int128(result);
        }
    }

    /**
     * Calculate x * y rounding down.  Revert on overflow.
     *
     * @param x signed 64.64-bit fixed point number
     * @param y signed 64.64-bit fixed point number
     * @return signed 64.64-bit fixed point number
     */
    function mul(int128 x, int128 y) internal pure returns (int128) {
        unchecked {
            int256 result = (int256(x) * y) >> 64;
            require(result >= MIN_64x64 && result <= MAX_64x64);
            return int128(result);
        }
    }

    /**
     * Calculate x * y rounding towards zero, where x is signed 64.64 fixed point
     * number and y is signed 256-bit integer number.  Revert on overflow.
     *
     * @param x signed 64.64 fixed point number
     * @param y signed 256-bit integer number
     * @return signed 256-bit integer number
     */
    function muli(int128 x, int256 y) internal pure returns (int256) {
        unchecked {
            if (x == MIN_64x64) {
                require(
                    y >= -0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF &&
                        y <= 0x1000000000000000000000000000000000000000000000000
                );
                return -y << 63;
            } else {
                bool negativeResult = false;
                if (x < 0) {
                    x = -x;
                    negativeResult = true;
                }
                if (y < 0) {
                    y = -y; // We rely on overflow behavior here
                    negativeResult = !negativeResult;
                }
                uint256 absoluteResult = mulu(x, uint256(y));
                if (negativeResult) {
                    require(
                        absoluteResult <=
                            0x8000000000000000000000000000000000000000000000000000000000000000
                    );
                    return -int256(absoluteResult); // We rely on overflow behavior here
                } else {
                    require(
                        absoluteResult <=
                            0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
                    );
                    return int256(absoluteResult);
                }
            }
        }
    }

    /**
     * Calculate x * y rounding down, where x is signed 64.64 fixed point number
     * and y is unsigned 256-bit integer number.  Revert on overflow.
     *
     * @param x signed 64.64 fixed point number
     * @param y unsigned 256-bit integer number
     * @return unsigned 256-bit integer number
     */
    function mulu(int128 x, uint256 y) internal pure returns (uint256) {
        unchecked {
            if (y == 0) return 0;

            require(x >= 0);

            uint256 lo = (uint256(int256(x)) *
                (y & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)) >> 64;
            uint256 hi = uint256(int256(x)) * (y >> 128);

            require(hi <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
            hi <<= 64;

            require(
                hi <=
                    0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF -
                        lo
            );
            return hi + lo;
        }
    }

    /**
     * Calculate x / y rounding towards zero.  Revert on overflow or when y is
     * zero.
     *
     * @param x signed 64.64-bit fixed point number
     * @param y signed 64.64-bit fixed point number
     * @return signed 64.64-bit fixed point number
     */
    function div(int128 x, int128 y) internal pure returns (int128) {
        unchecked {
            require(y != 0);
            int256 result = (int256(x) << 64) / y;
            require(result >= MIN_64x64 && result <= MAX_64x64);
            return int128(result);
        }
    }

    /**
     * Calculate x / y rounding towards zero, where x and y are signed 256-bit
     * integer numbers.  Revert on overflow or when y is zero.
     *
     * @param x signed 256-bit integer number
     * @param y signed 256-bit integer number
     * @return signed 64.64-bit fixed point number
     */
    function divi(int256 x, int256 y) internal pure returns (int128) {
        unchecked {
            require(y != 0);

            bool negativeResult = false;
            if (x < 0) {
                x = -x; // We rely on overflow behavior here
                negativeResult = true;
            }
            if (y < 0) {
                y = -y; // We rely on overflow behavior here
                negativeResult = !negativeResult;
            }
            uint128 absoluteResult = divuu(uint256(x), uint256(y));
            if (negativeResult) {
                require(absoluteResult <= 0x80000000000000000000000000000000);
                return -int128(absoluteResult); // We rely on overflow behavior here
            } else {
                require(absoluteResult <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
                return int128(absoluteResult); // We rely on overflow behavior here
            }
        }
    }

    /**
     * Calculate x / y rounding towards zero, where x and y are unsigned 256-bit
     * integer numbers.  Revert on overflow or when y is zero.
     *
     * @param x unsigned 256-bit integer number
     * @param y unsigned 256-bit integer number
     * @return signed 64.64-bit fixed point number
     */
    function divu(uint256 x, uint256 y) internal pure returns (int128) {
        unchecked {
            require(y != 0);
            uint128 result = divuu(x, y);
            require(result <= uint128(MAX_64x64));
            return int128(result);
        }
    }

    /**
     * Calculate -x.  Revert on overflow.
     *
     * @param x signed 64.64-bit fixed point number
     * @return signed 64.64-bit fixed point number
     */
    function neg(int128 x) internal pure returns (int128) {
        unchecked {
            require(x != MIN_64x64);
            return -x;
        }
    }

    /**
     * Calculate |x|.  Revert on overflow.
     *
     * @param x signed 64.64-bit fixed point number
     * @return signed 64.64-bit fixed point number
     */
    function abs(int128 x) internal pure returns (int128) {
        unchecked {
            require(x != MIN_64x64);
            return x < 0 ? -x : x;
        }
    }

    /**
     * Calculate 1 / x rounding towards zero.  Revert on overflow or when x is
     * zero.
     *
     * @param x signed 64.64-bit fixed point number
     * @return signed 64.64-bit fixed point number
     */
    function inv(int128 x) internal pure returns (int128) {
        unchecked {
            require(x != 0);
            int256 result = int256(0x100000000000000000000000000000000) / x;
            require(result >= MIN_64x64 && result <= MAX_64x64);
            return int128(result);
        }
    }

    /**
     * Calculate arithmetics average of x and y, i.e. (x + y) / 2 rounding down.
     *
     * @param x signed 64.64-bit fixed point number
     * @param y signed 64.64-bit fixed point number
     * @return signed 64.64-bit fixed point number
     */
    function avg(int128 x, int128 y) internal pure returns (int128) {
        unchecked {
            return int128((int256(x) + int256(y)) >> 1);
        }
    }

    /**
     * Calculate geometric average of x and y, i.e. sqrt (x * y) rounding down.
     * Revert on overflow or in case x * y is negative.
     *
     * @param x signed 64.64-bit fixed point number
     * @param y signed 64.64-bit fixed point number
     * @return signed 64.64-bit fixed point number
     */
    function gavg(int128 x, int128 y) internal pure returns (int128) {
        unchecked {
            int256 m = int256(x) * int256(y);
            require(m >= 0);
            require(
                m <
                    0x4000000000000000000000000000000000000000000000000000000000000000
            );
            return int128(sqrtu(uint256(m)));
        }
    }

    /**
     * Calculate x^y assuming 0^0 is 1, where x is signed 64.64 fixed point number
     * and y is unsigned 256-bit integer number.  Revert on overflow.
     *
     * @param x signed 64.64-bit fixed point number
     * @param y uint256 value
     * @return signed 64.64-bit fixed point number
     */
    function pow(int128 x, uint256 y) internal pure returns (int128) {
        unchecked {
            bool negative = x < 0 && y & 1 == 1;

            uint256 absX = uint128(x < 0 ? -x : x);
            uint256 absResult;
            absResult = 0x100000000000000000000000000000000;

            if (absX <= 0x10000000000000000) {
                absX <<= 63;
                while (y != 0) {
                    if (y & 0x1 != 0) {
                        absResult = (absResult * absX) >> 127;
                    }
                    absX = (absX * absX) >> 127;

                    if (y & 0x2 != 0) {
                        absResult = (absResult * absX) >> 127;
                    }
                    absX = (absX * absX) >> 127;

                    if (y & 0x4 != 0) {
                        absResult = (absResult * absX) >> 127;
                    }
                    absX = (absX * absX) >> 127;

                    if (y & 0x8 != 0) {
                        absResult = (absResult * absX) >> 127;
                    }
                    absX = (absX * absX) >> 127;

                    y >>= 4;
                }

                absResult >>= 64;
            } else {
                uint256 absXShift = 63;
                if (absX < 0x1000000000000000000000000) {
                    absX <<= 32;
                    absXShift -= 32;
                }
                if (absX < 0x10000000000000000000000000000) {
                    absX <<= 16;
                    absXShift -= 16;
                }
                if (absX < 0x1000000000000000000000000000000) {
                    absX <<= 8;
                    absXShift -= 8;
                }
                if (absX < 0x10000000000000000000000000000000) {
                    absX <<= 4;
                    absXShift -= 4;
                }
                if (absX < 0x40000000000000000000000000000000) {
                    absX <<= 2;
                    absXShift -= 2;
                }
                if (absX < 0x80000000000000000000000000000000) {
                    absX <<= 1;
                    absXShift -= 1;
                }

                uint256 resultShift = 0;
                while (y != 0) {
                    require(absXShift < 64);

                    if (y & 0x1 != 0) {
                        absResult = (absResult * absX) >> 127;
                        resultShift += absXShift;
                        if (absResult > 0x100000000000000000000000000000000) {
                            absResult >>= 1;
                            resultShift += 1;
                        }
                    }
                    absX = (absX * absX) >> 127;
                    absXShift <<= 1;
                    if (absX >= 0x100000000000000000000000000000000) {
                        absX >>= 1;
                        absXShift += 1;
                    }

                    y >>= 1;
                }

                require(resultShift < 64);
                absResult >>= 64 - resultShift;
            }
            int256 result = negative ? -int256(absResult) : int256(absResult);
            require(result >= MIN_64x64 && result <= MAX_64x64);
            return int128(result);
        }
    }

    /**
     * Calculate sqrt (x) rounding down.  Revert if x < 0.
     *
     * @param x signed 64.64-bit fixed point number
     * @return signed 64.64-bit fixed point number
     */
    function sqrt(int128 x) internal pure returns (int128) {
        unchecked {
            require(x >= 0);
            return int128(sqrtu(uint256(int256(x)) << 64));
        }
    }

    /**
     * Calculate binary logarithm of x.  Revert if x <= 0.
     *
     * @param x signed 64.64-bit fixed point number
     * @return signed 64.64-bit fixed point number
     */
    function log_2(int128 x) internal pure returns (int128) {
        unchecked {
            require(x > 0);

            int256 msb = 0;
            int256 xc = x;
            if (xc >= 0x10000000000000000) {
                xc >>= 64;
                msb += 64;
            }
            if (xc >= 0x100000000) {
                xc >>= 32;
                msb += 32;
            }
            if (xc >= 0x10000) {
                xc >>= 16;
                msb += 16;
            }
            if (xc >= 0x100) {
                xc >>= 8;
                msb += 8;
            }
            if (xc >= 0x10) {
                xc >>= 4;
                msb += 4;
            }
            if (xc >= 0x4) {
                xc >>= 2;
                msb += 2;
            }
            if (xc >= 0x2) msb += 1; // No need to shift xc anymore

            int256 result = (msb - 64) << 64;
            uint256 ux = uint256(int256(x)) << uint256(127 - msb);
            for (int256 bit = 0x8000000000000000; bit > 0; bit >>= 1) {
                ux *= ux;
                uint256 b = ux >> 255;
                ux >>= 127 + b;
                result += bit * int256(b);
            }

            return int128(result);
        }
    }

    /**
     * Calculate natural logarithm of x.  Revert if x <= 0.
     *
     * @param x signed 64.64-bit fixed point number
     * @return signed 64.64-bit fixed point number
     */
    function ln(int128 x) internal pure returns (int128) {
        unchecked {
            require(x > 0);

            return
                int128(
                    int256(
                        (uint256(int256(log_2(x))) *
                            0xB17217F7D1CF79ABC9E3B39803F2F6AF) >> 128
                    )
                );
        }
    }

    /**
     * Calculate binary exponent of x.  Revert on overflow.
     *
     * @param x signed 64.64-bit fixed point number
     * @return signed 64.64-bit fixed point number
     */
    function exp_2(int128 x) internal pure returns (int128) {
        unchecked {
            require(x < 0x400000000000000000); // Overflow

            if (x < -0x400000000000000000) return 0; // Underflow

            uint256 result = 0x80000000000000000000000000000000;

            if (x & 0x8000000000000000 > 0)
                result = (result * 0x16A09E667F3BCC908B2FB1366EA957D3E) >> 128;
            if (x & 0x4000000000000000 > 0)
                result = (result * 0x1306FE0A31B7152DE8D5A46305C85EDEC) >> 128;
            if (x & 0x2000000000000000 > 0)
                result = (result * 0x1172B83C7D517ADCDF7C8C50EB14A791F) >> 128;
            if (x & 0x1000000000000000 > 0)
                result = (result * 0x10B5586CF9890F6298B92B71842A98363) >> 128;
            if (x & 0x800000000000000 > 0)
                result = (result * 0x1059B0D31585743AE7C548EB68CA417FD) >> 128;
            if (x & 0x400000000000000 > 0)
                result = (result * 0x102C9A3E778060EE6F7CACA4F7A29BDE8) >> 128;
            if (x & 0x200000000000000 > 0)
                result = (result * 0x10163DA9FB33356D84A66AE336DCDFA3F) >> 128;
            if (x & 0x100000000000000 > 0)
                result = (result * 0x100B1AFA5ABCBED6129AB13EC11DC9543) >> 128;
            if (x & 0x80000000000000 > 0)
                result = (result * 0x10058C86DA1C09EA1FF19D294CF2F679B) >> 128;
            if (x & 0x40000000000000 > 0)
                result = (result * 0x1002C605E2E8CEC506D21BFC89A23A00F) >> 128;
            if (x & 0x20000000000000 > 0)
                result = (result * 0x100162F3904051FA128BCA9C55C31E5DF) >> 128;
            if (x & 0x10000000000000 > 0)
                result = (result * 0x1000B175EFFDC76BA38E31671CA939725) >> 128;
            if (x & 0x8000000000000 > 0)
                result = (result * 0x100058BA01FB9F96D6CACD4B180917C3D) >> 128;
            if (x & 0x4000000000000 > 0)
                result = (result * 0x10002C5CC37DA9491D0985C348C68E7B3) >> 128;
            if (x & 0x2000000000000 > 0)
                result = (result * 0x1000162E525EE054754457D5995292026) >> 128;
            if (x & 0x1000000000000 > 0)
                result = (result * 0x10000B17255775C040618BF4A4ADE83FC) >> 128;
            if (x & 0x800000000000 > 0)
                result = (result * 0x1000058B91B5BC9AE2EED81E9B7D4CFAB) >> 128;
            if (x & 0x400000000000 > 0)
                result = (result * 0x100002C5C89D5EC6CA4D7C8ACC017B7C9) >> 128;
            if (x & 0x200000000000 > 0)
                result = (result * 0x10000162E43F4F831060E02D839A9D16D) >> 128;
            if (x & 0x100000000000 > 0)
                result = (result * 0x100000B1721BCFC99D9F890EA06911763) >> 128;
            if (x & 0x80000000000 > 0)
                result = (result * 0x10000058B90CF1E6D97F9CA14DBCC1628) >> 128;
            if (x & 0x40000000000 > 0)
                result = (result * 0x1000002C5C863B73F016468F6BAC5CA2B) >> 128;
            if (x & 0x20000000000 > 0)
                result = (result * 0x100000162E430E5A18F6119E3C02282A5) >> 128;
            if (x & 0x10000000000 > 0)
                result = (result * 0x1000000B1721835514B86E6D96EFD1BFE) >> 128;
            if (x & 0x8000000000 > 0)
                result = (result * 0x100000058B90C0B48C6BE5DF846C5B2EF) >> 128;
            if (x & 0x4000000000 > 0)
                result = (result * 0x10000002C5C8601CC6B9E94213C72737A) >> 128;
            if (x & 0x2000000000 > 0)
                result = (result * 0x1000000162E42FFF037DF38AA2B219F06) >> 128;
            if (x & 0x1000000000 > 0)
                result = (result * 0x10000000B17217FBA9C739AA5819F44F9) >> 128;
            if (x & 0x800000000 > 0)
                result = (result * 0x1000000058B90BFCDEE5ACD3C1CEDC823) >> 128;
            if (x & 0x400000000 > 0)
                result = (result * 0x100000002C5C85FE31F35A6A30DA1BE50) >> 128;
            if (x & 0x200000000 > 0)
                result = (result * 0x10000000162E42FF0999CE3541B9FFFCF) >> 128;
            if (x & 0x100000000 > 0)
                result = (result * 0x100000000B17217F80F4EF5AADDA45554) >> 128;
            if (x & 0x80000000 > 0)
                result = (result * 0x10000000058B90BFBF8479BD5A81B51AD) >> 128;
            if (x & 0x40000000 > 0)
                result = (result * 0x1000000002C5C85FDF84BD62AE30A74CC) >> 128;
            if (x & 0x20000000 > 0)
                result = (result * 0x100000000162E42FEFB2FED257559BDAA) >> 128;
            if (x & 0x10000000 > 0)
                result = (result * 0x1000000000B17217F7D5A7716BBA4A9AE) >> 128;
            if (x & 0x8000000 > 0)
                result = (result * 0x100000000058B90BFBE9DDBAC5E109CCE) >> 128;
            if (x & 0x4000000 > 0)
                result = (result * 0x10000000002C5C85FDF4B15DE6F17EB0D) >> 128;
            if (x & 0x2000000 > 0)
                result = (result * 0x1000000000162E42FEFA494F1478FDE05) >> 128;
            if (x & 0x1000000 > 0)
                result = (result * 0x10000000000B17217F7D20CF927C8E94C) >> 128;
            if (x & 0x800000 > 0)
                result = (result * 0x1000000000058B90BFBE8F71CB4E4B33D) >> 128;
            if (x & 0x400000 > 0)
                result = (result * 0x100000000002C5C85FDF477B662B26945) >> 128;
            if (x & 0x200000 > 0)
                result = (result * 0x10000000000162E42FEFA3AE53369388C) >> 128;
            if (x & 0x100000 > 0)
                result = (result * 0x100000000000B17217F7D1D351A389D40) >> 128;
            if (x & 0x80000 > 0)
                result = (result * 0x10000000000058B90BFBE8E8B2D3D4EDE) >> 128;
            if (x & 0x40000 > 0)
                result = (result * 0x1000000000002C5C85FDF4741BEA6E77E) >> 128;
            if (x & 0x20000 > 0)
                result = (result * 0x100000000000162E42FEFA39FE95583C2) >> 128;
            if (x & 0x10000 > 0)
                result = (result * 0x1000000000000B17217F7D1CFB72B45E1) >> 128;
            if (x & 0x8000 > 0)
                result = (result * 0x100000000000058B90BFBE8E7CC35C3F0) >> 128;
            if (x & 0x4000 > 0)
                result = (result * 0x10000000000002C5C85FDF473E242EA38) >> 128;
            if (x & 0x2000 > 0)
                result = (result * 0x1000000000000162E42FEFA39F02B772C) >> 128;
            if (x & 0x1000 > 0)
                result = (result * 0x10000000000000B17217F7D1CF7D83C1A) >> 128;
            if (x & 0x800 > 0)
                result = (result * 0x1000000000000058B90BFBE8E7BDCBE2E) >> 128;
            if (x & 0x400 > 0)
                result = (result * 0x100000000000002C5C85FDF473DEA871F) >> 128;
            if (x & 0x200 > 0)
                result = (result * 0x10000000000000162E42FEFA39EF44D91) >> 128;
            if (x & 0x100 > 0)
                result = (result * 0x100000000000000B17217F7D1CF79E949) >> 128;
            if (x & 0x80 > 0)
                result = (result * 0x10000000000000058B90BFBE8E7BCE544) >> 128;
            if (x & 0x40 > 0)
                result = (result * 0x1000000000000002C5C85FDF473DE6ECA) >> 128;
            if (x & 0x20 > 0)
                result = (result * 0x100000000000000162E42FEFA39EF366F) >> 128;
            if (x & 0x10 > 0)
                result = (result * 0x1000000000000000B17217F7D1CF79AFA) >> 128;
            if (x & 0x8 > 0)
                result = (result * 0x100000000000000058B90BFBE8E7BCD6D) >> 128;
            if (x & 0x4 > 0)
                result = (result * 0x10000000000000002C5C85FDF473DE6B2) >> 128;
            if (x & 0x2 > 0)
                result = (result * 0x1000000000000000162E42FEFA39EF358) >> 128;
            if (x & 0x1 > 0)
                result = (result * 0x10000000000000000B17217F7D1CF79AB) >> 128;

            result >>= uint256(int256(63 - (x >> 64)));
            require(result <= uint256(int256(MAX_64x64)));

            return int128(int256(result));
        }
    }

    /**
     * Calculate natural exponent of x.  Revert on overflow.
     *
     * @param x signed 64.64-bit fixed point number
     * @return signed 64.64-bit fixed point number
     */
    function exp(int128 x) internal pure returns (int128) {
        unchecked {
            require(x < 0x400000000000000000); // Overflow

            if (x < -0x400000000000000000) return 0; // Underflow

            return
                exp_2(
                    int128(
                        (int256(x) * 0x171547652B82FE1777D0FFDA0D23A7D12) >> 128
                    )
                );
        }
    }

    /**
     * Calculate x / y rounding towards zero, where x and y are unsigned 256-bit
     * integer numbers.  Revert on overflow or when y is zero.
     *
     * @param x unsigned 256-bit integer number
     * @param y unsigned 256-bit integer number
     * @return unsigned 64.64-bit fixed point number
     */
    function divuu(uint256 x, uint256 y) private pure returns (uint128) {
        unchecked {
            require(y != 0);

            uint256 result;

            if (x <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)
                result = (x << 64) / y;
            else {
                uint256 msb = 192;
                uint256 xc = x >> 192;
                if (xc >= 0x100000000) {
                    xc >>= 32;
                    msb += 32;
                }
                if (xc >= 0x10000) {
                    xc >>= 16;
                    msb += 16;
                }
                if (xc >= 0x100) {
                    xc >>= 8;
                    msb += 8;
                }
                if (xc >= 0x10) {
                    xc >>= 4;
                    msb += 4;
                }
                if (xc >= 0x4) {
                    xc >>= 2;
                    msb += 2;
                }
                if (xc >= 0x2) msb += 1; // No need to shift xc anymore

                result = (x << (255 - msb)) / (((y - 1) >> (msb - 191)) + 1);
                require(result <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);

                uint256 hi = result * (y >> 128);
                uint256 lo = result * (y & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);

                uint256 xh = x >> 192;
                uint256 xl = x << 64;

                if (xl < lo) xh -= 1;
                xl -= lo; // We rely on overflow behavior here
                lo = hi << 128;
                if (xl < lo) xh -= 1;
                xl -= lo; // We rely on overflow behavior here

                assert(xh == hi >> 128);

                result += xl / y;
            }

            require(result <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
            return uint128(result);
        }
    }

    /**
     * Calculate sqrt (x) rounding down, where x is unsigned 256-bit integer
     * number.
     *
     * @param x unsigned 256-bit integer number
     * @return unsigned 128-bit integer number
     */
    function sqrtu(uint256 x) private pure returns (uint128) {
        unchecked {
            if (x == 0) return 0;
            else {
                uint256 xx = x;
                uint256 r = 1;
                if (xx >= 0x100000000000000000000000000000000) {
                    xx >>= 128;
                    r <<= 64;
                }
                if (xx >= 0x10000000000000000) {
                    xx >>= 64;
                    r <<= 32;
                }
                if (xx >= 0x100000000) {
                    xx >>= 32;
                    r <<= 16;
                }
                if (xx >= 0x10000) {
                    xx >>= 16;
                    r <<= 8;
                }
                if (xx >= 0x100) {
                    xx >>= 8;
                    r <<= 4;
                }
                if (xx >= 0x10) {
                    xx >>= 4;
                    r <<= 2;
                }
                if (xx >= 0x8) {
                    r <<= 1;
                }
                r = (r + x / r) >> 1;
                r = (r + x / r) >> 1;
                r = (r + x / r) >> 1;
                r = (r + x / r) >> 1;
                r = (r + x / r) >> 1;
                r = (r + x / r) >> 1;
                r = (r + x / r) >> 1; // Seven iterations should be enough
                uint256 r1 = x / r;
                return uint128(r < r1 ? r : r1);
            }
        }
    }
}

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

Contract ABI

API
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"settlementFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"totalFee","type":"uint256"},{"indexed":false,"internalType":"int256","name":"skew","type":"int256"},{"indexed":false,"internalType":"bytes32","name":"marketId","type":"bytes32"}],"name":"Create","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint128","name":"strike","type":"uint128"},{"indexed":false,"internalType":"uint32","name":"expiration","type":"uint32"},{"indexed":false,"internalType":"bytes32","name":"marketId","type":"bytes32"},{"indexed":false,"internalType":"address","name":"optionsContract","type":"address"}],"name":"CreateMarket","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"config","type":"address"},{"indexed":false,"internalType":"address","name":"pool","type":"address"},{"indexed":false,"internalType":"address","name":"tokenX","type":"address"},{"indexed":false,"internalType":"string","name":"token0","type":"string"},{"indexed":false,"internalType":"string","name":"token1","type":"string"},{"indexed":false,"internalType":"enum IBufferBinaryOptions.AssetCategory","name":"category","type":"uint8"}],"name":"CreateOptionsContract","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"profit","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"priceAtExpiration","type":"uint256"},{"indexed":false,"internalType":"bool","name":"isAbove","type":"bool"}],"name":"Exercise","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"premium","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"priceAtExpiration","type":"uint256"},{"indexed":false,"internalType":"bool","name":"isAbove","type":"bool"}],"name":"Expire","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"LpLoss","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"LpProfit","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"isPaused","type":"bool"}],"name":"Pause","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"address","name":"referrer","type":"address"},{"indexed":false,"internalType":"bool","name":"isReferralValid","type":"bool"},{"indexed":false,"internalType":"uint256","name":"totalFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"referrerFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"rebate","type":"uint256"},{"indexed":false,"internalType":"string","name":"referralCode","type":"string"}],"name":"UpdateReferral","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PAUSER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ROUTER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"referrer","type":"address"},{"internalType":"address","name":"user","type":"address"}],"name":"_getReferralDiscount","outputs":[{"internalType":"uint256","name":"referralDiscount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"addressToApprove","type":"address"}],"name":"approveAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"approvePoolToTransferTokenX","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"approvedAddresses","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"assetCategory","outputs":[{"internalType":"enum IBufferBinaryOptions.AssetCategory","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"assetPair","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"isAbove","type":"bool"},{"internalType":"uint256","name":"currentPrice","type":"uint256"},{"internalType":"uint256","name":"strike","type":"uint256"},{"internalType":"uint256","name":"period","type":"uint256"},{"internalType":"uint256","name":"iv","type":"uint256"}],"name":"baseFeePerContract","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"config","outputs":[{"internalType":"contract IOptionsConfig","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"sf","type":"uint256"},{"internalType":"uint256","name":"iv","type":"uint256"},{"internalType":"bool","name":"allowPartialFill","type":"bool"},{"internalType":"bool","name":"isAbove","type":"bool"},{"internalType":"uint256","name":"contracts","type":"uint256"},{"internalType":"uint128","name":"strike","type":"uint128"},{"internalType":"uint32","name":"expiration","type":"uint32"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"totalFee","type":"uint256"},{"internalType":"uint256","name":"maxFeePerContract","type":"uint256"},{"internalType":"uint256","name":"currentPrice","type":"uint256"},{"internalType":"string","name":"referralCode","type":"string"}],"internalType":"struct IBufferBinaryOptions.OptionParams","name":"optionParams","type":"tuple"},{"internalType":"uint32","name":"queuedTime","type":"uint32"}],"name":"createFromRouter","outputs":[{"internalType":"uint256","name":"optionID","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"sf","type":"uint256"},{"internalType":"uint256","name":"iv","type":"uint256"},{"internalType":"bool","name":"allowPartialFill","type":"bool"},{"internalType":"bool","name":"isAbove","type":"bool"},{"internalType":"uint256","name":"contracts","type":"uint256"},{"internalType":"uint128","name":"strike","type":"uint128"},{"internalType":"uint32","name":"expiration","type":"uint32"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"totalFee","type":"uint256"},{"internalType":"uint256","name":"maxFeePerContract","type":"uint256"},{"internalType":"uint256","name":"currentPrice","type":"uint256"},{"internalType":"string","name":"referralCode","type":"string"}],"internalType":"struct IBufferBinaryOptions.OptionParams","name":"optionParams","type":"tuple"}],"name":"evaluateParams","outputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"fee","type":"uint256"},{"internalType":"uint256","name":"revisedContracts","type":"uint256"},{"internalType":"uint256","name":"revisedSf","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"isAbove","type":"bool"},{"internalType":"uint256","name":"currentPrice","type":"uint256"},{"internalType":"uint256","name":"strike","type":"uint256"},{"internalType":"uint256","name":"period","type":"uint256"},{"internalType":"uint256","name":"iv","type":"uint256"},{"internalType":"uint256","name":"sf","type":"uint256"}],"name":"fees","outputs":[{"internalType":"uint256","name":"total","type":"uint256"},{"internalType":"uint256","name":"settlementFee","type":"uint256"},{"internalType":"uint256","name":"premium","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"marketId","type":"bytes32"},{"internalType":"bool","name":"isAbove","type":"bool"}],"name":"getLoss","outputs":[{"internalType":"int256","name":"","type":"int256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"strike","type":"uint256"},{"internalType":"uint256","name":"expiration","type":"uint256"}],"name":"getMarketId","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes32","name":"marketId","type":"bytes32"},{"internalType":"uint256","name":"_baseFeePerContract","type":"uint256"},{"internalType":"bool","name":"isAbove","type":"bool"}],"name":"getMaxPermissibleContracts","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"referrer","type":"address"},{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"baseSettlementFeePercentage","type":"uint256"}],"name":"getSettlementFeePercentage","outputs":[{"internalType":"uint256","name":"settlementFeePercentage","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"marketId","type":"bytes32"}],"name":"getSkew","outputs":[{"internalType":"int256","name":"","type":"int256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract ERC20","name":"_tokenX","type":"address"},{"internalType":"contract ILiquidityPool","name":"_pool","type":"address"},{"internalType":"contract IOptionsConfig","name":"_config","type":"address"},{"internalType":"contract IReferralStorage","name":"_referral","type":"address"},{"internalType":"enum IBufferBinaryOptions.AssetCategory","name":"_category","type":"uint8"},{"internalType":"string","name":"_token0","type":"string"},{"internalType":"string","name":"_token1","type":"string"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"expiration","type":"uint256"}],"name":"isExpirationValid","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isPaused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"markets","outputs":[{"internalType":"bytes32","name":"marketId","type":"bytes32"},{"internalType":"uint256","name":"contractsUp","type":"uint256"},{"internalType":"uint256","name":"contractsDown","type":"uint256"},{"internalType":"int256","name":"premiumUp","type":"int256"},{"internalType":"int256","name":"premiumDown","type":"int256"},{"internalType":"uint256","name":"strike","type":"uint256"},{"internalType":"uint256","name":"expiration","type":"uint256"},{"internalType":"bool","name":"isValid","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nextTokenId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"options","outputs":[{"internalType":"enum IBufferBinaryOptions.State","name":"state","type":"uint8"},{"internalType":"uint128","name":"strike","type":"uint128"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"lockedAmount","type":"uint256"},{"internalType":"uint256","name":"premium","type":"uint256"},{"internalType":"uint32","name":"expiration","type":"uint32"},{"internalType":"uint256","name":"totalFee","type":"uint256"},{"internalType":"uint32","name":"createdAt","type":"uint32"},{"internalType":"bool","name":"isAbove","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pool","outputs":[{"internalType":"contract ILiquidityPool","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"referral","outputs":[{"internalType":"contract IReferralStorage","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint128","name":"strike","type":"uint128"},{"internalType":"uint32","name":"expiration","type":"uint32"}],"name":"runInitialChecks","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"setIsPaused","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"stepSize","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"token0","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"token1","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tokenX","outputs":[{"internalType":"contract ERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalMarketOI","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"optionID","type":"uint256"},{"internalType":"uint256","name":"closingPrice","type":"uint256"}],"name":"unlock","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"userOptionIds","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]

608060405260006008553480156200001657600080fd5b506040805180820182526006815265213ab33332b960d11b60208083019182528351808501909452600384526221232960e91b9084015260016000819055825192939262000065929062000147565b5080516200007b90600290602084019062000147565b506200008d9150600090503362000093565b6200022a565b6200009f8282620000a3565b5050565b60008281526007602090815260408083206001600160a01b038516845290915290205460ff166200009f5760008281526007602090815260408083206001600160a01b03851684529091529020805460ff19166001179055620001033390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b8280546200015590620001ed565b90600052602060002090601f016020900481019282620001795760008555620001c4565b82601f106200019457805160ff1916838001178555620001c4565b82800160010185558215620001c4579182015b82811115620001c4578251825591602001919060010190620001a7565b50620001d2929150620001d6565b5090565b5b80821115620001d25760008155600101620001d7565b600181811c908216806200020257607f821691505b602082108114156200022457634e487b7160e01b600052602260045260246000fd5b50919050565b615e01806200023a6000396000f3fe608060405234801561001057600080fd5b506004361061035d5760003560e01c8063617c6719116101d3578063a6512c3f11610104578063d21220a7116100a2578063e63ab1e91161007c578063e63ab1e914610870578063e985e9c514610897578063f136a874146108d3578063fabf657a146108f657600080fd5b8063d21220a714610842578063d45497f81461084a578063d547741f1461085d57600080fd5b8063b88d4fde116100de578063b88d4fde146107f6578063c742a80a14610809578063c87b56dd1461081c578063c962ca121461082f57600080fd5b8063a6512c3f1461079c578063a90d7f09146107d6578063b187bd26146107e957600080fd5b806379502c551161017157806391d148541161014b57806391d148541461076657806395d89b4114610779578063a217fddf14610781578063a22cb4651461078957600080fd5b806379502c551461072d57806385a9ab06146107405780638f29a3d41461075357600080fd5b80636c6a22a6116101ad5780636c6a22a61461066d57806370a08231146106805780637564912b1461069357806375794a3c1461072457600080fd5b8063617c67191461063f5780636352211e14610652578063645734e61461066557600080fd5b8063248a9ca3116102ad57806336568abe1161024b57806342842e0e1161022557806342842e0e146105de57806345fdd3f2146105f157806356799e5f146106245780635bfadb241461062c57600080fd5b806336568abe1461052d57806336ebafe914610540578063409e22051461055b57600080fd5b80632f2ff15d116102875780632f2ff15d146104ea57806330d643b5146104fd578063313ce5671461051257806332475ce41461051a57600080fd5b8063248a9ca3146104785780632c26d8ee1461049b5780632d293b63146104bc57600080fd5b80631441a5a91161031a5780631b3979c0116102f45780631b3979c01461042857806320a6c8ba1461043b5780632313dd021461045c57806323b872dd1461046557600080fd5b80631441a5a9146103ef57806316dc165b1461040257806316f0115b1461041557600080fd5b806301ffc9a71461036257806306fdde031461038a578063081812fc1461039f578063095ea7b3146103ca5780630dfe1681146103df57806310082c75146103e7575b600080fd5b6103756103703660046153cf565b610909565b60405190151581526020015b60405180910390f35b61039261091a565b6040516103819190615947565b6103b26103ad366004615337565b6109ac565b6040516001600160a01b039091168152602001610381565b6103dd6103d8366004615246565b6109d3565b005b610392610aee565b610392610b7c565b6010546103b2906001600160a01b031681565b6011546103b2906001600160a01b031681565b600e546103b2906001600160a01b031681565b6103dd610436366004615407565b610b89565b61044e61044936600461515c565b610d47565b604051908152602001610381565b61044e60095481565b6103dd61047336600461515c565b610d69565b61044e610486366004615337565b60009081526007602052604090206001015490565b6010546104af90600160a01b900460ff1681565b60405161038191906158a2565b6104cf6104ca3660046152ec565b610d9a565b60408051938452602084019290925290820152606001610381565b6103dd6104f836600461534f565b610ded565b61044e600080516020615dac83398151915281565b61044e610e12565b61044e610528366004615373565b610e97565b6103dd61053b36600461534f565b611063565b610548601981565b60405161ffff9091168152602001610381565b6105c9610569366004615337565b601260205260009081526040902080546001820154600283015460038401546004850154600586015460069096015460ff808716976101009097046001600160801b03169663ffffffff93841693909290811691600160201b9091041689565b604051610381999897969594939291906158b0565b6103dd6105ec36600461515c565b6110e1565b6106046105ff3660046154e0565b6110fc565b604080519485526020850193909352918301526060820152608001610381565b6103dd6116f6565b6103dd61063a3660046155c2565b6117d1565b61044e61064d366004615124565b611b57565b6103b2610660366004615337565b611cb2565b6103dd611cbd565b61044e61067b366004615337565b611d49565b61044e61068e3660046150ec565b611d7c565b6106e76106a1366004615337565b6015602052600090815260409020805460018201546002830154600384015460048501546005860154600687015460079097015495969495939492939192909160ff1688565b604080519889526020890197909752958701949094526060860192909252608085015260a084015260c0830152151560e082015261010001610381565b61044e60085481565b600f546103b2906001600160a01b031681565b61044e61074e366004615513565b611e02565b610375610761366004615337565b6124ed565b61037561077436600461534f565b612592565b6103926125bd565b61044e600081565b6103dd610797366004615219565b6125cc565b61044e6107aa3660046155c2565b604080516020808201949094528082019290925280518083038201815260609092019052805191012090565b61044e6107e4366004615397565b6125d7565b600a546103759060ff1681565b6103dd61080436600461519c565b612735565b6103dd610817366004615597565b61276d565b61039261082a366004615337565b612acd565b61044e61083d366004615246565b612b40565b610392612b71565b61044e6108583660046152a9565b612b7e565b6103dd61086b36600461534f565b612bc5565b61044e7f65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a81565b6103756108a5366004615124565b6001600160a01b03918216600090815260066020908152604080832093909416825291909152205460ff1690565b6103756108e13660046150ec565b60146020526000908152604090205460ff1681565b6103dd6109043660046150ec565b612bea565b600061091482612c1a565b92915050565b60606001805461092990615c56565b80601f016020809104026020016040519081016040528092919081815260200182805461095590615c56565b80156109a25780601f10610977576101008083540402835291602001916109a2565b820191906000526020600020905b81548152906001019060200180831161098557829003601f168201915b5050505050905090565b60006109b782612c3f565b506000908152600560205260409020546001600160a01b031690565b60006109de82612c9e565b9050806001600160a01b0316836001600160a01b03161415610a515760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084015b60405180910390fd5b336001600160a01b0382161480610a6d5750610a6d81336108a5565b610adf5760405162461bcd60e51b815260206004820152603e60248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f7420746f60448201527f6b656e206f776e6572206e6f7220617070726f76656420666f7220616c6c00006064820152608401610a48565b610ae98383612cfe565b505050565b600b8054610afb90615c56565b80601f0160208091040260200160405190810160405280929190818152602001828054610b2790615c56565b8015610b745780601f10610b4957610100808354040283529160200191610b74565b820191906000526020600020905b815481529060010190602001808311610b5757829003601f168201915b505050505081565b600d8054610afb90615c56565b6000610b9481612d6c565b6011546001600160a01b0316610cff57601180546001600160a01b03808b166001600160a01b031992831617909255600e80548a8416908316179055600f80548984169083161790556010805492881691831682178155869290916001600160a81b031990911617600160a01b836002811115610c2157634e487b7160e01b600052602160045260246000fd5b02179055508251610c3990600b906020860190614f92565b508151610c4d90600c906020850190614f92565b50610c59600033612d76565b600b600c604051602001610c6e92919061578f565b604051602081830303815290604052600d9080519060200190610c92929190614f92565b50600f54600e546011546010546040517f13d3a1031aba66188cca5785e8045078864e8f69c24715761bf0449ef10304d694610cf2946001600160a01b039182169490821693911691600b91600c91600160a01b90910460ff1690615819565b60405180910390a1610d3d565b60405162461bcd60e51b8152602060048201526013602482015272105b1c9958591e481a5b9a5d1a585b1a5e9959606a1b6044820152606401610a48565b5050505050505050565b806000610d548585611b57565b9050610d608183615bfc565b95945050505050565b610d733382612d80565b610d8f5760405162461bcd60e51b8152600401610a48906159ac565b610ae9838383612dfe565b600080600080610dad8a8a8a8a8a612b7e565b9050612710610dbc8683615b9e565b610dc69190615a9f565b9250610dd28382615a87565b9350610dde8382615bfc565b91505096509650969350505050565b600082815260076020526040902060010154610e0881612d6c565b610ae98383612fa5565b6011546040805163313ce56760e01b815290516000926001600160a01b03169163313ce567916004808301926020929190829003018186803b158015610e5757600080fd5b505afa158015610e6b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e8f91906155fd565b60ff16905090565b600082815260156020526040812060038101546004909101548291610ebb91615a46565b905082610f915780610ecb610e12565b610ed690600a615af6565b600f60009054906101000a90046001600160a01b03166001600160a01b03166363bd1d4a6040518163ffffffff1660e01b815260040160206040518083038186803b158015610f2457600080fd5b505afa158015610f38573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f5c91906154c8565b600087815260156020526040902060020154610f789190615b9e565b610f829190615a9f565b610f8c9190615bbd565b61105b565b80610f9a610e12565b610fa590600a615af6565b600f60009054906101000a90046001600160a01b03166001600160a01b03166363bd1d4a6040518163ffffffff1660e01b815260040160206040518083038186803b158015610ff357600080fd5b505afa158015611007573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061102b91906154c8565b6000878152601560205260409020600101546110479190615b9e565b6110519190615a9f565b61105b9190615bbd565b949350505050565b6001600160a01b03811633146110d35760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608401610a48565b6110dd828261302b565b5050565b610ae983838360405180602001604052806000815250612735565b600a5460009081908190819060ff161561113e5760405162461bcd60e51b81526020600482015260036024820152624f333360e81b6044820152606401610a48565b6001601054600160a01b900460ff16600281111561116c57634e487b7160e01b600052602160045260246000fd5b14806112975750600f60009054906101000a90046001600160a01b03166001600160a01b0316632677327a6040518163ffffffff1660e01b815260040160206040518083038186803b1580156111c157600080fd5b505afa1580156111d5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111f99190615108565b6001600160a01b031663f7d52fa142611219610100890160e08a016155e3565b63ffffffff166112299190615bfc565b6040518263ffffffff1660e01b815260040161124791815260200190565b60206040518083038186803b15801561125f57600080fd5b505afa158015611273573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611297919061528d565b6112c95760405162461bcd60e51b815260206004820152600360248201526204f33360ec1b6044820152606401610a48565b60006113296112de60a0880160808901615271565b6101608801356112f460e08a0160c08b0161555f565b6001600160801b03164261130f6101008c0160e08d016155e3565b63ffffffff1661131f9190615bfc565b8a60400135612b7e565b90506002611335610e12565b61133f9190615bfc565b61134a90600a615af6565b611355906005615b9e565b81116113925760405162461bcd60e51b815260206004820152600c60248201526b46656520746f6f206c65737360a01b6044820152606401610a48565b600261139c610e12565b6113a69190615bfc565b6113b190600a615af6565b6113bc90605f615b9e565b81106113f95760405162461bcd60e51b815260206004820152600c60248201526b08ccaca40e8dede40d0d2ced60a31b6044820152606401610a48565b600061140b60e0880160c0890161555f565b61141c610100890160e08a016155e3565b604080516001600160801b03909316602084015263ffffffff9091169082015260600160408051601f198184030181529190528051602090910120601054909150611501906001600160a01b0316637d191bdb61147d6101808b018b6159fa565b6040518363ffffffff1660e01b815260040161149a929190615918565b60206040518083038186803b1580156114b257600080fd5b505afa1580156114c6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114ea9190615108565b6114f760208a018a6150ec565b8960200135610d47565b92506127106115108484615b9e565b61151a9190615a9f565b6115249083615a87565b915086610140013582111561157b5760405162461bcd60e51b815260206004820152601960248201527f507269636520646966666572656e636520746f6f2068696768000000000000006044820152606401610a48565b600061159282846107e460a08c0160808d01615271565b90508261159d610e12565b6115a890600a615af6565b6115b7906101208b0135615b9e565b6115c19190615a9f565b94508085111561163e576115db6080890160608a01615271565b61160d5760405162461bcd60e51b81526020600482015260036024820152624f323960e81b6044820152606401610a48565b809450611618610e12565b61162390600a615af6565b61162d8685615b9e565b6116379190615a9f565b9550611647565b87610120013595505b61164f610e12565b61165a90600a615af6565b600f54604080516331de8ea560e11b8152905188926001600160a01b0316916363bd1d4a916004808301926020929190829003018186803b15801561169e57600080fd5b505afa1580156116b2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116d691906154c8565b6116e09190615b9e565b6116ea9190615a9f565b96505050509193509193565b6117207f65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a33612592565b1561173757600a805460ff19166001179055611793565b611742600033612592565b1561175e57600a805460ff19811660ff90911615179055611793565b60405162461bcd60e51b815260206004820152600a60248201526957726f6e6720726f6c6560b01b6044820152606401610a48565b600a5460405160ff909116151581527f9422424b175dda897495a07b091ef74a3ef715cf6d866fc972954c1c7f4593049060200160405180910390a1565b600080516020615dac8339815191526117e981612d6c565b6000838152600360205260409020546001600160a01b03166118335760405162461bcd60e51b815260206004820152600360248201526204f31360ec1b6044820152606401610a48565b600083815260126020526040902060048101544263ffffffff90911611156118825760405162461bcd60e51b815260206004820152600260248201526113cd60f21b6044820152606401610a48565b6001815460ff1660038111156118a857634e487b7160e01b600052602160045260246000fd5b146118da5760405162461bcd60e51b81526020600482015260026024820152614f3560f01b6044820152606401610a48565b6006810154600090600160201b900460ff1680156119065750815461010090046001600160801b031684115b8061193657506006820154600160201b900460ff161580156119365750815461010090046001600160801b031684105b1561195e5761195785858460060160049054906101000a900460ff16613092565b9050611a29565b815460ff19166003178255600e54604051636198e33960e01b8152600481018790526001600160a01b0390911690636198e33990602401600060405180830381600087803b1580156119af57600080fd5b505af11580156119c3573d6000803e3d6000fd5b505050506119d08561327b565b600382015460068301546040805192835260208301879052600160201b90910460ff1615159082015285907f06b9a7d5e559ec958118dcc25fab116916793fa9782acbf47186bf70bc4cf88e9060600160405180910390a25b816005015460096000828254611a3f9190615bfc565b9091555050600f546040805163488d8b8f60e11b815290516001600160a01b039092169163911b171e91600480820192602092909190829003018186803b158015611a8957600080fd5b505afa158015611a9d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ac19190615108565b6001600160a01b0316633a5d92a8836005015483611adf9190615bbd565b84600301548560050154611af39190615bfc565b6040516001600160e01b031960e085901b1681526004810192909252602482015260448101889052606401600060405180830381600087803b158015611b3857600080fd5b505af1158015611b4c573d6000803e3d6000fd5b505050505050505050565b600080826001600160a01b0316846001600160a01b031614158015611b8457506001600160a01b03841615155b8015611b9857506001600160a01b0384163b155b15611ca75760105460405163010de89960e21b81526001600160a01b038681166004830152600092169063ad1b1493908290630437a2649060240160206040518083038186803b158015611beb57600080fd5b505afa158015611bff573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c2391906155fd565b6040516001600160e01b031960e084901b16815260ff909116600482015260240160206040518083038186803b158015611c5c57600080fd5b505afa158015611c70573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c9491906155fd565b9050611ca360ff821683615a87565b9150505b61105b816019615b9e565b600061091482612c9e565b601154600e5460405163095ea7b360e01b81526001600160a01b039182166004820152600019602482015291169063095ea7b390604401602060405180830381600087803b158015611d0e57600080fd5b505af1158015611d22573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d46919061528d565b50565b600080611d57836001610e97565b90506000611d66846000610e97565b9050808213611d75578061105b565b5092915050565b60006001600160a01b038216611de65760405162461bcd60e51b815260206004820152602960248201527f4552433732313a2061646472657373207a65726f206973206e6f7420612076616044820152683634b21037bbb732b960b91b6064820152608401610a48565b506001600160a01b031660009081526004602052604090205490565b6000600080516020615dac833981519152611e1c81612d6c565b6000611e2e60e0860160c0870161555f565b611e3f610100870160e088016155e3565b604080516001600160801b03909316602084015263ffffffff9091169082015260600160405160208183030381529060405280519060200120905060006127108660200135876101200135611e949190615b9e565b611e9e9190615a9f565b9050600060405180610120016040528060016003811115611ecf57634e487b7160e01b600052602160045260246000fd5b8152602001611ee460e08a0160c08b0161555f565b6001600160801b03168152610100890135602082018190526040820152606001611f13846101208b0135615bfc565b8152602001611f296101008a0160e08b016155e3565b63ffffffff90811682526101208a0135602083015288166040820152606001611f5860a08a0160808b01615271565b151590529050611f66613322565b945060136000611f7960208a018a6150ec565b6001600160a01b031681526020808201929092526040908101600090812080546001818101835591835284832001899055888252601290935220825181548493839160ff191690836003811115611fe057634e487b7160e01b600052602160045260246000fd5b0217905550602082810151825470ffffffffffffffffffffffffffffffff0019166101006001600160801b03909216820217835560408401516001840155606084015160028401556080840151600384015560a084015160048401805463ffffffff191663ffffffff92831617905560c0850151600585015560e0850151600690940180549290950151931664ffffffffff1990911617600160201b92151592909202919091179091556120a09061209a908901896150ec565b8661333c565b600f54604080516309b41a1b60e11b81529051612131926001600160a01b0316916313683436916004808301926020929190829003018186803b1580156120e657600080fd5b505afa1580156120fa573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061211e9190615108565b6011546001600160a01b0316908461348a565b600e546060820151608083015160405163edd0d42160e01b815260048101899052602481019290925260448201526001600160a01b039091169063edd0d42190606401600060405180830381600087803b15801561218e57600080fd5b505af11580156121a2573d6000803e3d6000fd5b50505050600f60009054906101000a90046001600160a01b03166001600160a01b03166395b12ea36040518163ffffffff1660e01b815260040160206040518083038186803b1580156121f457600080fd5b505afa158015612208573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061222c9190615108565b6001600160a01b031663710b2815863061224960208c018c6150ec565b6040516001600160e01b031960e086901b16815260048101939093526001600160a01b039182166024840152166044820152606401600060405180830381600087803b15801561229857600080fd5b505af11580156122ac573d6000803e3d6000fd5b50505050866101200135600960008282546122c79190615a87565b909155506122dd905060a0880160808901615271565b15612348576000838152601560205260408120600101805460a08a01359290612307908490615a87565b9091555061231c905082610120890135615bfc565b6000848152601560205260408120600301805490919061233d908490615a46565b909155506123a99050565b6000838152601560205260408120600201805460a08a0135929061236d908490615a87565b90915550612382905082610120890135615bfc565b600084815260156020526040812060040180549091906123a3908490615a46565b90915550505b60006123b484611d49565b9050600f60009054906101000a90046001600160a01b03166001600160a01b03166350ec40e06040518163ffffffff1660e01b815260040160206040518083038186803b15801561240457600080fd5b505afa158015612418573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061243c91906154c8565b81131561247b5760405162461bcd60e51b815260206004820152600d60248201526c098dee6e640e8dede40d0d2ced609b1b6044820152606401610a48565b8561248960208a018a6150ec565b604080518681526101208c01356020820152908101849052606081018790526001600160a01b0391909116907ffa6101f13be10247a3f27ba031321ca444c4bf1eb56aade9f1c96f5e621164aa9060800160405180910390a3505050505092915050565b600061a8c06124fc4284615bfc565b101561250a57506000919050565b600062034bc061251a4285615bfc565b10801561253e5750620151806125328461e100615a87565b61253c9190615ccc565b155b9050600062093a806170806125566201518087615bfc565b6125609190615bfc565b61256a9190615ccc565b1580156125825750620b34c06125804286615bfc565b105b9050818061105b57509392505050565b60009182526007602090815260408084206001600160a01b0393909316845291905290205460ff1690565b60606002805461092990615c56565b6110dd3383836134dc565b600082600f60009054906101000a90046001600160a01b03166001600160a01b03166363bd1d4a6040518163ffffffff1660e01b815260040160206040518083038186803b15801561262857600080fd5b505afa15801561263c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061266091906154c8565b61266a9190615bfc565b612672610e12565b61267d90600a615af6565b6126878685610e97565b600f60009054906101000a90046001600160a01b03166001600160a01b03166350ec40e06040518163ffffffff1660e01b815260040160206040518083038186803b1580156126d557600080fd5b505afa1580156126e9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061270d91906154c8565b6127179190615bbd565b6127219190615b9e565b61272b9190615a9f565b90505b9392505050565b61273f3383612d80565b61275b5760405162461bcd60e51b8152600401610a48906159ac565b612767848484846135ab565b50505050565b600080516020615dac83398151915261278581612d6c565b604080516001600160801b03851660208083019190915263ffffffff85168284015282518083038401815260609092019092528051910120428363ffffffff1610806127e1575061a8c06127df4263ffffffff8616615bfc565b105b1561281d5760405162461bcd60e51b815260206004820152600c60248201526b57726f6e672065787069727960a01b6044820152606401610a48565b60008181526015602052604090206007015460ff161561283d5750505050565b61284c8363ffffffff166124ed565b80156128ee5750600f60009054906101000a90046001600160a01b03166001600160a01b031663d63a95cf6040518163ffffffff1660e01b815260040160206040518083038186803b1580156128a157600080fd5b505afa1580156128b5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128d9919061557b565b6128e39085615ca6565b6001600160801b0316155b15612a855760405180610100016040528082815260200160156000848152602001908152602001600020600101548152602001601560008481526020019081526020016000206002015481526020016015600084815260200190815260200160002060030154815260200160156000848152602001908152602001600020600401548152602001856001600160801b031681526020018463ffffffff1681526020016001151581525060156000838152602001908152602001600020600082015181600001556020820151816001015560408201518160020155606082015181600301556080820151816004015560a0820151816005015560c0820151816006015560e08201518160070160006101000a81548160ff0219169083151502179055509050507fb373e533c35db97af93fa6fd93a43d7bb03943fa27553f266d118ab174b8c27784848330604051612a7894939291906001600160801b0394909416845263ffffffff92909216602084015260408301526001600160a01b0316606082015260800190565b60405180910390a1612767565b60405162461bcd60e51b815260206004820152601c60248201527f496e76616c696420737472696b65206f722065787069726174696f6e000000006044820152606401610a48565b6060612ad882612c3f565b6000612aef60408051602081019091526000815290565b90506000815111612b0f576040518060200160405280600081525061272e565b80612b19846135de565b604051602001612b2a929190615760565b6040516020818303038152906040529392505050565b60136020528160005260406000208181548110612b5c57600080fd5b90600052602060002001600091509150505481565b600c8054610afb90615c56565b60006305f5e100612b8d610e12565b612b9890600a615af6565b612ba78487898860018d6136f8565b612bb19190615b9e565b612bbb9190615a9f565b9695505050505050565b600082815260076020526040902060010154612be081612d6c565b610ae9838361302b565b6000612bf581612d6c565b506001600160a01b03166000908152601460205260409020805460ff19166001179055565b60006001600160e01b03198216637965db0b60e01b14806109145750610914826137c9565b6000818152600360205260409020546001600160a01b0316611d465760405162461bcd60e51b8152602060048201526018602482015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b6044820152606401610a48565b6000818152600360205260408120546001600160a01b0316806109145760405162461bcd60e51b8152602060048201526018602482015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b6044820152606401610a48565b600081815260056020526040902080546001600160a01b0319166001600160a01b0384169081179091558190612d3382612c9e565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b611d468133613819565b6110dd8282612fa5565b600080612d8c83612c9e565b9050806001600160a01b0316846001600160a01b03161480612dd357506001600160a01b0380821660009081526006602090815260408083209388168352929052205460ff165b8061105b5750836001600160a01b0316612dec846109ac565b6001600160a01b031614949350505050565b826001600160a01b0316612e1182612c9e565b6001600160a01b031614612e755760405162461bcd60e51b815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201526437bbb732b960d91b6064820152608401610a48565b6001600160a01b038216612ed75760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610a48565b612ee283838361387d565b612eed600082612cfe565b6001600160a01b0383166000908152600460205260408120805460019290612f16908490615bfc565b90915550506001600160a01b0382166000908152600460205260408120805460019290612f44908490615a87565b909155505060008181526003602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b612faf8282612592565b6110dd5760008281526007602090815260408083206001600160a01b03851684529091529020805460ff19166001179055612fe73390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6130358282612592565b156110dd5760008281526007602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6000838152601260205260408120816130aa86611cb2565b6002830154600e546040516381b34f1560e01b8152600481018a9052306024820152604481018390529195509192506001600160a01b03909116906381b34f1590606401600060405180830381600087803b15801561310857600080fd5b505af115801561311c573d6000803e3d6000fd5b505060115461313892506001600160a01b03169050828561348a565b816002015483101561317857600e546002830154613178916001600160a01b031690613165908690615bfc565b6011546001600160a01b0316919061348a565b816003015483116131cb57857fc88c04f82f76cf4112dc206d1a563be25c04a4a762a699eccd4d4abc6df0dff08484600301546131b59190615bfc565b60405190815260200160405180910390a261320f565b857fa569991d55d525eae5729bac6890aeb7c0bdcd198f36ca0d0a7da8c2c0a734fb8360030154856131fd9190615bfc565b60405190815260200160405180910390a25b6132188661327b565b815460ff19166002178255604080518481526020810187905285151581830152905187916001600160a01b038416917ff394088c7503260c927488ca4397d6b43146f13c239078415e6f14029e5cb7f8916060908290030190a350509392505050565b600061328682612c9e565b90506132948160008461387d565b61329f600083612cfe565b6001600160a01b03811660009081526004602052604081208054600192906132c8908490615bfc565b909155505060008281526003602052604080822080546001600160a01b0319169055518391906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a45050565b600880546000918261333383615c8b565b91905055905090565b6001600160a01b0382166133925760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610a48565b6000818152600360205260409020546001600160a01b0316156133f75760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610a48565b6134036000838361387d565b6001600160a01b038216600090815260046020526040812080546001929061342c908490615a87565b909155505060008181526003602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052610ae9908490613934565b816001600160a01b0316836001600160a01b0316141561353e5760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610a48565b6001600160a01b03838116600081815260066020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b6135b6848484612dfe565b6135c284848484613a06565b6127675760405162461bcd60e51b8152600401610a489061595a565b6060816136025750506040805180820190915260018152600360fc1b602082015290565b8160005b811561362c578061361681615c8b565b91506136259050600a83615a9f565b9150613606565b60008167ffffffffffffffff81111561365557634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f19166020018201604052801561367f576020820181803683370190505b5090505b841561105b57613694600183615bfc565b91506136a1600a86615ccc565b6136ac906030615a87565b60f81b8183815181106136cf57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a9053506136f1600a86615a9f565b9450613683565b6000806137086305f5e100613b13565b90506000613717612710613b13565b90506000613731826137288c613b13565b600f0b90613b31565b90506000613743600f83900b83613b98565b90506000613754856137288d613b13565b90506000613765866137288d613b13565b905060006137826137796301e13380613b13565b6137288d613b13565b90506000613794858585858f8f613bce565b90506137ac6137a7600f83900b8a613b98565b613ca5565b67ffffffffffffffff169f9e505050505050505050505050505050565b60006001600160e01b031982166380ac58cd60e01b14806137fa57506001600160e01b03198216635b5e139f60e01b145b8061091457506301ffc9a760e01b6001600160e01b0319831614610914565b6138238282612592565b6110dd5761383b816001600160a01b03166014613cc1565b613846836020613cc1565b6040516020016138579291906157a4565b60408051601f198184030181529082905262461bcd60e51b8252610a4891600401615947565b6001600160a01b0383161580159061389d57506001600160a01b03821615155b80156138c257506001600160a01b03821660009081526014602052604090205460ff16155b80156138e757506001600160a01b03831660009081526014602052604090205460ff16155b15610ae95760405162461bcd60e51b815260206004820152601a60248201527f546f6b656e207472616e73666572206e6f7420616c6c6f7765640000000000006044820152606401610a48565b6000613989826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316613ea39092919063ffffffff16565b805190915015610ae957808060200190518101906139a7919061528d565b610ae95760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610a48565b60006001600160a01b0384163b15613b0857604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290613a4a90339089908890889060040161586f565b602060405180830381600087803b158015613a6457600080fd5b505af1925050508015613a94575060408051601f3d908101601f19168201909252613a91918101906153eb565b60015b613aee573d808015613ac2576040519150601f19603f3d011682016040523d82523d6000602084013e613ac7565b606091505b508051613ae65760405162461bcd60e51b8152600401610a489061595a565b805181602001fd5b6001600160e01b031916630a85bd0160e11b14905061105b565b506001949350505050565b6000677fffffffffffffff821115613b2a57600080fd5b5060401b90565b600081600f0b60001415613b4457600080fd5b600082600f0b604085600f0b901b81613b6d57634e487b7160e01b600052601260045260246000fd5b05905060016001607f1b03198112801590613b8f575060016001607f1b038113155b61272e57600080fd5b6000600f83810b9083900b0260401d60016001607f1b03198112801590613b8f575060016001607f1b0381131561272e57600080fd5b600080613bdf600f86900b89613b98565b90506000613bef82600f0b613eb2565b90506000613c2c82613728600186600f0b901d613c23613c1b8e8e600f0b613b3190919063ffffffff16565b600f0b613ed4565b600f0b90613f0e565b90506000613c3e600f83900b84613f41565b90508615613c71578515613c6057613c5581613f74565b945050505050612bbb565b613c55613c6c82615ce0565b613f74565b8515613c9657613c55613c8382613f74565b613c8d6001613b13565b600f0b90613f41565b613c55613c83613c6c83615ce0565b60008082600f0b1215613cb757600080fd5b50600f0b60401d90565b60606000613cd0836002615b9e565b613cdb906002615a87565b67ffffffffffffffff811115613d0157634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015613d2b576020820181803683370190505b509050600360fc1b81600081518110613d5457634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110613d9157634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a9053506000613db5846002615b9e565b613dc0906001615a87565b90505b6001811115613e54576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110613e0257634e487b7160e01b600052603260045260246000fd5b1a60f81b828281518110613e2657634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535060049490941c93613e4d81615c3f565b9050613dc3565b50831561272e5760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610a48565b606061272b8484600085614030565b60008082600f0b1215613ec457600080fd5b610914604083600f0b901b614161565b60008082600f0b13613ee557600080fd5b6080613ef083614343565b600f0b6fb17217f7d1cf79abc9e3b39803f2f6af02901c9050919050565b6000600f83810b9083900b0160016001607f1b03198112801590613b8f575060016001607f1b0381131561272e57600080fd5b6000600f82810b9084900b0360016001607f1b03198112801590613b8f575060016001607f1b0381131561272e57600080fd5b600080613f85600f84900b84613b98565b9050600061400f613ff4613fc3613fb4613fac600f87900b68030000000000000000613f0e565b600f0b613eb2565b67d3c84b78b749bd6b90613b98565b613c23613fe5613fd589600f0b61441d565b68019abac0ea1da6503690613b98565b679109f285df45239490613f0e565b613728600161400286615ce0565b600f0b901d600f0b614450565b9050600084600f0b13614022578061105b565b61105b600160401b82613f41565b6060824710156140915760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610a48565b6001600160a01b0385163b6140e85760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610a48565b600080866001600160a01b031685876040516141049190615744565b60006040518083038185875af1925050503d8060008114614141576040519150601f19603f3d011682016040523d82523d6000602084013e614146565b606091505b50915091506141568282866144a5565b979650505050505050565b60008161417057506000919050565b816001600160801b82106141895760809190911c9060401b5b600160401b821061419f5760409190911c9060201b5b600160201b82106141b55760209190911c9060101b5b6201000082106141ca5760109190911c9060081b5b61010082106141de5760089190911c9060041b5b601082106141f15760049190911c9060021b5b600882106141fd5760011b5b600181858161421c57634e487b7160e01b600052601260045260246000fd5b048201901c9050600181858161424257634e487b7160e01b600052601260045260246000fd5b048201901c9050600181858161426857634e487b7160e01b600052601260045260246000fd5b048201901c9050600181858161428e57634e487b7160e01b600052601260045260246000fd5b048201901c905060018185816142b457634e487b7160e01b600052601260045260246000fd5b048201901c905060018185816142da57634e487b7160e01b600052601260045260246000fd5b048201901c9050600181858161430057634e487b7160e01b600052601260045260246000fd5b048201901c9050600081858161432657634e487b7160e01b600052601260045260246000fd5b0490508082106143365780610d60565b509392505050565b919050565b60008082600f0b1361435457600080fd5b6000600f83900b600160401b811261436e576040918201911d5b600160201b8112614381576020918201911d5b620100008112614393576010918201911d5b61010081126143a4576008918201911d5b601081126143b4576004918201911d5b600481126143c4576002918201911d5b600281126143d3576001820191505b603f19820160401b600f85900b607f8490031b6001603f1b5b60008113156144125790800260ff81901c8281029390930192607f011c9060011d6143ec565b509095945050505050565b6000600f82900b60016001607f1b0319141561443857600080fd5b600082600f0b126144495781610914565b5060000390565b6000600160461b82600f0b1261446557600080fd5b683fffffffffffffffff1982600f0b121561448257506000919050565b610914608083600f0b700171547652b82fe1777d0ffda0d23a7d1202901d6144de565b606083156144b457508161272e565b8251156144c45782518084602001fd5b8160405162461bcd60e51b8152600401610a489190615947565b6000600160461b82600f0b126144f357600080fd5b683fffffffffffffffff1982600f0b121561451057506000919050565b6001607f1b60006001603f1b8416600f0b131561453e5770016a09e667f3bcc908b2fb1366ea957d3e0260801c5b60008367400000000000000016600f0b131561456b577001306fe0a31b7152de8d5a46305c85edec0260801c5b60008367200000000000000016600f0b1315614598577001172b83c7d517adcdf7c8c50eb14a791f0260801c5b60008367100000000000000016600f0b13156145c55770010b5586cf9890f6298b92b71842a983630260801c5b60008367080000000000000016600f0b13156145f2577001059b0d31585743ae7c548eb68ca417fd0260801c5b60008367040000000000000016600f0b131561461f57700102c9a3e778060ee6f7caca4f7a29bde80260801c5b60008367020000000000000016600f0b131561464c5770010163da9fb33356d84a66ae336dcdfa3f0260801c5b60008367010000000000000016600f0b131561467957700100b1afa5abcbed6129ab13ec11dc95430260801c5b600083668000000000000016600f0b13156146a55770010058c86da1c09ea1ff19d294cf2f679b0260801c5b600083664000000000000016600f0b13156146d1577001002c605e2e8cec506d21bfc89a23a00f0260801c5b600083662000000000000016600f0b13156146fd57700100162f3904051fa128bca9c55c31e5df0260801c5b600083661000000000000016600f0b1315614729577001000b175effdc76ba38e31671ca9397250260801c5b600083660800000000000016600f0b131561475557700100058ba01fb9f96d6cacd4b180917c3d0260801c5b600083660400000000000016600f0b13156147815770010002c5cc37da9491d0985c348c68e7b30260801c5b600083660200000000000016600f0b13156147ad577001000162e525ee054754457d59952920260260801c5b600083660100000000000016600f0b13156147d95770010000b17255775c040618bf4a4ade83fc0260801c5b6000836580000000000016600f0b1315614804577001000058b91b5bc9ae2eed81e9b7d4cfab0260801c5b6000836540000000000016600f0b131561482f57700100002c5c89d5ec6ca4d7c8acc017b7c90260801c5b6000836520000000000016600f0b131561485a5770010000162e43f4f831060e02d839a9d16d0260801c5b6000836510000000000016600f0b131561488557700100000b1721bcfc99d9f890ea069117630260801c5b6000836508000000000016600f0b13156148b05770010000058b90cf1e6d97f9ca14dbcc16280260801c5b6000836504000000000016600f0b13156148db577001000002c5c863b73f016468f6bac5ca2b0260801c5b6000836502000000000016600f0b131561490657700100000162e430e5a18f6119e3c02282a50260801c5b6000836501000000000016600f0b1315614931577001000000b1721835514b86e6d96efd1bfe0260801c5b60008364800000000016600f0b131561495b57700100000058b90c0b48c6be5df846c5b2ef0260801c5b60008364400000000016600f0b13156149855770010000002c5c8601cc6b9e94213c72737a0260801c5b60008364200000000016600f0b13156149af577001000000162e42fff037df38aa2b219f060260801c5b60008364100000000016600f0b13156149d95770010000000b17217fba9c739aa5819f44f90260801c5b60008364080000000016600f0b1315614a03577001000000058b90bfcdee5acd3c1cedc8230260801c5b60008364040000000016600f0b1315614a2d57700100000002c5c85fe31f35a6a30da1be500260801c5b60008364020000000016600f0b1315614a575770010000000162e42ff0999ce3541b9fffcf0260801c5b600083600160201b16600f0b1315614a8057700100000000b17217f80f4ef5aadda455540260801c5b600083638000000016600f0b1315614aa95770010000000058b90bfbf8479bd5a81b51ad0260801c5b600083634000000016600f0b1315614ad2577001000000002c5c85fdf84bd62ae30a74cc0260801c5b600083632000000016600f0b1315614afb57700100000000162e42fefb2fed257559bdaa0260801c5b600083631000000016600f0b1315614b24577001000000000b17217f7d5a7716bba4a9ae0260801c5b600083630800000016600f0b1315614b4d57700100000000058b90bfbe9ddbac5e109cce0260801c5b600083630400000016600f0b1315614b765770010000000002c5c85fdf4b15de6f17eb0d0260801c5b600083630200000016600f0b1315614b9f577001000000000162e42fefa494f1478fde050260801c5b600083630100000016600f0b1315614bc85770010000000000b17217f7d20cf927c8e94c0260801c5b6000836280000016600f0b1315614bf0577001000000000058b90bfbe8f71cb4e4b33d0260801c5b6000836240000016600f0b1315614c1857700100000000002c5c85fdf477b662b269450260801c5b6000836220000016600f0b1315614c405770010000000000162e42fefa3ae53369388c0260801c5b6000836210000016600f0b1315614c6857700100000000000b17217f7d1d351a389d400260801c5b6000836208000016600f0b1315614c905770010000000000058b90bfbe8e8b2d3d4ede0260801c5b6000836204000016600f0b1315614cb8577001000000000002c5c85fdf4741bea6e77e0260801c5b6000836202000016600f0b1315614ce057700100000000000162e42fefa39fe95583c20260801c5b6000836201000016600f0b1315614d08577001000000000000b17217f7d1cfb72b45e10260801c5b60008361800016600f0b1315614d2f57700100000000000058b90bfbe8e7cc35c3f00260801c5b60008361400016600f0b1315614d565770010000000000002c5c85fdf473e242ea380260801c5b60008361200016600f0b1315614d7d577001000000000000162e42fefa39f02b772c0260801c5b60008361100016600f0b1315614da45770010000000000000b17217f7d1cf7d83c1a0260801c5b60008361080016600f0b1315614dcb577001000000000000058b90bfbe8e7bdcbe2e0260801c5b60008361040016600f0b1315614df257700100000000000002c5c85fdf473dea871f0260801c5b60008361020016600f0b1315614e195770010000000000000162e42fefa39ef44d910260801c5b60008361010016600f0b1315614e4057700100000000000000b17217f7d1cf79e9490260801c5b600083608016600f0b1315614e665770010000000000000058b90bfbe8e7bce5440260801c5b600083604016600f0b1315614e8c577001000000000000002c5c85fdf473de6eca0260801c5b600083602016600f0b1315614eb257700100000000000000162e42fefa39ef366f0260801c5b600083601016600f0b1315614ed8577001000000000000000b17217f7d1cf79afa0260801c5b600083600816600f0b1315614efe57700100000000000000058b90bfbe8e7bcd6d0260801c5b600083600416600f0b1315614f245770010000000000000002c5c85fdf473de6b20260801c5b600083600216600f0b1315614f4a577001000000000000000162e42fefa39ef3580260801c5b600083600116600f0b1315614f705770010000000000000000b17217f7d1cf79ab0260801c5b600f83810b60401d603f03900b1c60016001607f1b0381111561091457600080fd5b828054614f9e90615c56565b90600052602060002090601f016020900481019282614fc05760008555615006565b82601f10614fd957805160ff1916838001178555615006565b82800160010185558215615006579182015b82811115615006578251825591602001919060010190614feb565b50615012929150615016565b5090565b5b808211156150125760008155600101615017565b600067ffffffffffffffff8084111561504657615046615d47565b604051601f8501601f19908116603f0116810190828211818310171561506e5761506e615d47565b8160405280935085815286868601111561508757600080fd5b858560208301376000602087830101525050509392505050565b600082601f8301126150b1578081fd5b61272e8383356020850161502b565b60006101a082840312156150d2578081fd5b50919050565b803563ffffffff8116811461433e57600080fd5b6000602082840312156150fd578081fd5b813561272e81615d5d565b600060208284031215615119578081fd5b815161272e81615d5d565b60008060408385031215615136578081fd5b823561514181615d5d565b9150602083013561515181615d5d565b809150509250929050565b600080600060608486031215615170578081fd5b833561517b81615d5d565b9250602084013561518b81615d5d565b929592945050506040919091013590565b600080600080608085870312156151b1578081fd5b84356151bc81615d5d565b935060208501356151cc81615d5d565b925060408501359150606085013567ffffffffffffffff8111156151ee578182fd5b8501601f810187136151fe578182fd5b61520d8782356020840161502b565b91505092959194509250565b6000806040838503121561522b578182fd5b823561523681615d5d565b9150602083013561515181615d72565b60008060408385031215615258578182fd5b823561526381615d5d565b946020939093013593505050565b600060208284031215615282578081fd5b813561272e81615d72565b60006020828403121561529e578081fd5b815161272e81615d72565b600080600080600060a086880312156152c0578283fd5b85356152cb81615d72565b97602087013597506040870135966060810135965060800135945092505050565b60008060008060008060c08789031215615304578384fd5b863561530f81615d72565b9860208801359850604088013597606081013597506080810135965060a00135945092505050565b600060208284031215615348578081fd5b5035919050565b60008060408385031215615361578182fd5b82359150602083013561515181615d5d565b60008060408385031215615385578182fd5b82359150602083013561515181615d72565b6000806000606084860312156153ab578081fd5b833592506020840135915060408401356153c481615d72565b809150509250925092565b6000602082840312156153e0578081fd5b813561272e81615d80565b6000602082840312156153fc578081fd5b815161272e81615d80565b600080600080600080600060e0888a031215615421578485fd5b873561542c81615d5d565b9650602088013561543c81615d5d565b9550604088013561544c81615d5d565b9450606088013561545c81615d5d565b935060808801356003811061546f578182fd5b925060a088013567ffffffffffffffff8082111561548b578283fd5b6154978b838c016150a1565b935060c08a01359150808211156154ac578283fd5b506154b98a828b016150a1565b91505092959891949750929550565b6000602082840312156154d9578081fd5b5051919050565b6000602082840312156154f1578081fd5b813567ffffffffffffffff811115615507578182fd5b61105b848285016150c0565b60008060408385031215615525578182fd5b823567ffffffffffffffff81111561553b578283fd5b615547858286016150c0565b925050615556602084016150d8565b90509250929050565b600060208284031215615570578081fd5b813561272e81615d96565b60006020828403121561558c578081fd5b815161272e81615d96565b600080604083850312156155a9578182fd5b82356155b481615d96565b9150615556602084016150d8565b600080604083850312156155d4578182fd5b50508035926020909101359150565b6000602082840312156155f4578081fd5b61272e826150d8565b60006020828403121561560e578081fd5b815160ff8116811461272e578182fd5b60008151808452615636816020860160208601615c13565b601f01601f19169290920160200192915050565b6003811061565a5761565a615d31565b9052565b6000815461566b81615c56565b808552602060018381168015615688576001811461569c576156ca565b60ff198516888401526040880195506156ca565b866000528260002060005b858110156156c25781548a82018601529083019084016156a7565b890184019650505b505050505092915050565b600081546156e281615c56565b600182811680156156fa576001811461570b5761573a565b60ff1984168752828701945061573a565b8560005260208060002060005b858110156157315781548a820152908401908201615718565b50505082870194505b5050505092915050565b60008251615756818460208701615c13565b9190910192915050565b60008351615772818460208801615c13565b835190830190615786818360208801615c13565b01949350505050565b600061272b61579e83866156d5565b846156d5565b7f416363657373436f6e74726f6c3a206163636f756e74200000000000000000008152600083516157dc816017850160208801615c13565b7001034b99036b4b9b9b4b733903937b6329607d1b601791840191820152835161580d816028840160208801615c13565b01602801949350505050565b6001600160a01b03878116825286811660208301528516604082015260c06060820181905260009061584d9083018661565e565b828103608084015261585f818661565e565b91505061415660a083018461564a565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090612bbb9083018461561e565b60208101610914828461564a565b610120810160048b106158c5576158c5615d31565b9981526001600160801b0398909816602089015260408801969096526060870194909452608086019290925263ffffffff90811660a086015260c08501919091521660e083015215156101009091015290565b60208152816020820152818360408301376000818301604090810191909152601f909201601f19160101919050565b60208152600061272e602083018461561e565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6020808252602e908201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560408201526d1c881b9bdc88185c1c1c9bdd995960921b606082015260800190565b6000808335601e19843603018112615a10578283fd5b83018035915067ffffffffffffffff821115615a2a578283fd5b602001915036819003821315615a3f57600080fd5b9250929050565b600080821280156001600160ff1b0384900385131615615a6857615a68615d05565b600160ff1b8390038412811615615a8157615a81615d05565b50500190565b60008219821115615a9a57615a9a615d05565b500190565b600082615aae57615aae615d1b565b500490565b600181815b80851115615aee578160001904821115615ad457615ad4615d05565b80851615615ae157918102915b93841c9390800290615ab8565b509250929050565b600061272e8383600082615b0c57506001610914565b81615b1957506000610914565b8160018114615b2f5760028114615b3957615b55565b6001915050610914565b60ff841115615b4a57615b4a615d05565b50506001821b610914565b5060208310610133831016604e8410600b8410161715615b78575081810a610914565b615b828383615ab3565b8060001904821115615b9657615b96615d05565b029392505050565b6000816000190483118215151615615bb857615bb8615d05565b500290565b60008083128015600160ff1b850184121615615bdb57615bdb615d05565b6001600160ff1b0384018313811615615bf657615bf6615d05565b50500390565b600082821015615c0e57615c0e615d05565b500390565b60005b83811015615c2e578181015183820152602001615c16565b838111156127675750506000910152565b600081615c4e57615c4e615d05565b506000190190565b600181811c90821680615c6a57607f821691505b602082108114156150d257634e487b7160e01b600052602260045260246000fd5b6000600019821415615c9f57615c9f615d05565b5060010190565b60006001600160801b0380841680615cc057615cc0615d1b565b92169190910692915050565b600082615cdb57615cdb615d1b565b500690565b600081600f0b60016001607f1b0319811415615cfe57615cfe615d05565b9003919050565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114611d4657600080fd5b8015158114611d4657600080fd5b6001600160e01b031981168114611d4657600080fd5b6001600160801b0381168114611d4657600080fdfe7a05a596cb0ce7fdea8a1e1ec73be300bdb35097c944ce1897202f7a13122eb2a26469706673582212205f7bd74cf944844069e0d24c2960179523225b4e17d34230165721d84e4acfed64736f6c63430008040033

Deployed Bytecode

0x608060405234801561001057600080fd5b506004361061035d5760003560e01c8063617c6719116101d3578063a6512c3f11610104578063d21220a7116100a2578063e63ab1e91161007c578063e63ab1e914610870578063e985e9c514610897578063f136a874146108d3578063fabf657a146108f657600080fd5b8063d21220a714610842578063d45497f81461084a578063d547741f1461085d57600080fd5b8063b88d4fde116100de578063b88d4fde146107f6578063c742a80a14610809578063c87b56dd1461081c578063c962ca121461082f57600080fd5b8063a6512c3f1461079c578063a90d7f09146107d6578063b187bd26146107e957600080fd5b806379502c551161017157806391d148541161014b57806391d148541461076657806395d89b4114610779578063a217fddf14610781578063a22cb4651461078957600080fd5b806379502c551461072d57806385a9ab06146107405780638f29a3d41461075357600080fd5b80636c6a22a6116101ad5780636c6a22a61461066d57806370a08231146106805780637564912b1461069357806375794a3c1461072457600080fd5b8063617c67191461063f5780636352211e14610652578063645734e61461066557600080fd5b8063248a9ca3116102ad57806336568abe1161024b57806342842e0e1161022557806342842e0e146105de57806345fdd3f2146105f157806356799e5f146106245780635bfadb241461062c57600080fd5b806336568abe1461052d57806336ebafe914610540578063409e22051461055b57600080fd5b80632f2ff15d116102875780632f2ff15d146104ea57806330d643b5146104fd578063313ce5671461051257806332475ce41461051a57600080fd5b8063248a9ca3146104785780632c26d8ee1461049b5780632d293b63146104bc57600080fd5b80631441a5a91161031a5780631b3979c0116102f45780631b3979c01461042857806320a6c8ba1461043b5780632313dd021461045c57806323b872dd1461046557600080fd5b80631441a5a9146103ef57806316dc165b1461040257806316f0115b1461041557600080fd5b806301ffc9a71461036257806306fdde031461038a578063081812fc1461039f578063095ea7b3146103ca5780630dfe1681146103df57806310082c75146103e7575b600080fd5b6103756103703660046153cf565b610909565b60405190151581526020015b60405180910390f35b61039261091a565b6040516103819190615947565b6103b26103ad366004615337565b6109ac565b6040516001600160a01b039091168152602001610381565b6103dd6103d8366004615246565b6109d3565b005b610392610aee565b610392610b7c565b6010546103b2906001600160a01b031681565b6011546103b2906001600160a01b031681565b600e546103b2906001600160a01b031681565b6103dd610436366004615407565b610b89565b61044e61044936600461515c565b610d47565b604051908152602001610381565b61044e60095481565b6103dd61047336600461515c565b610d69565b61044e610486366004615337565b60009081526007602052604090206001015490565b6010546104af90600160a01b900460ff1681565b60405161038191906158a2565b6104cf6104ca3660046152ec565b610d9a565b60408051938452602084019290925290820152606001610381565b6103dd6104f836600461534f565b610ded565b61044e600080516020615dac83398151915281565b61044e610e12565b61044e610528366004615373565b610e97565b6103dd61053b36600461534f565b611063565b610548601981565b60405161ffff9091168152602001610381565b6105c9610569366004615337565b601260205260009081526040902080546001820154600283015460038401546004850154600586015460069096015460ff808716976101009097046001600160801b03169663ffffffff93841693909290811691600160201b9091041689565b604051610381999897969594939291906158b0565b6103dd6105ec36600461515c565b6110e1565b6106046105ff3660046154e0565b6110fc565b604080519485526020850193909352918301526060820152608001610381565b6103dd6116f6565b6103dd61063a3660046155c2565b6117d1565b61044e61064d366004615124565b611b57565b6103b2610660366004615337565b611cb2565b6103dd611cbd565b61044e61067b366004615337565b611d49565b61044e61068e3660046150ec565b611d7c565b6106e76106a1366004615337565b6015602052600090815260409020805460018201546002830154600384015460048501546005860154600687015460079097015495969495939492939192909160ff1688565b604080519889526020890197909752958701949094526060860192909252608085015260a084015260c0830152151560e082015261010001610381565b61044e60085481565b600f546103b2906001600160a01b031681565b61044e61074e366004615513565b611e02565b610375610761366004615337565b6124ed565b61037561077436600461534f565b612592565b6103926125bd565b61044e600081565b6103dd610797366004615219565b6125cc565b61044e6107aa3660046155c2565b604080516020808201949094528082019290925280518083038201815260609092019052805191012090565b61044e6107e4366004615397565b6125d7565b600a546103759060ff1681565b6103dd61080436600461519c565b612735565b6103dd610817366004615597565b61276d565b61039261082a366004615337565b612acd565b61044e61083d366004615246565b612b40565b610392612b71565b61044e6108583660046152a9565b612b7e565b6103dd61086b36600461534f565b612bc5565b61044e7f65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a81565b6103756108a5366004615124565b6001600160a01b03918216600090815260066020908152604080832093909416825291909152205460ff1690565b6103756108e13660046150ec565b60146020526000908152604090205460ff1681565b6103dd6109043660046150ec565b612bea565b600061091482612c1a565b92915050565b60606001805461092990615c56565b80601f016020809104026020016040519081016040528092919081815260200182805461095590615c56565b80156109a25780601f10610977576101008083540402835291602001916109a2565b820191906000526020600020905b81548152906001019060200180831161098557829003601f168201915b5050505050905090565b60006109b782612c3f565b506000908152600560205260409020546001600160a01b031690565b60006109de82612c9e565b9050806001600160a01b0316836001600160a01b03161415610a515760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084015b60405180910390fd5b336001600160a01b0382161480610a6d5750610a6d81336108a5565b610adf5760405162461bcd60e51b815260206004820152603e60248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f7420746f60448201527f6b656e206f776e6572206e6f7220617070726f76656420666f7220616c6c00006064820152608401610a48565b610ae98383612cfe565b505050565b600b8054610afb90615c56565b80601f0160208091040260200160405190810160405280929190818152602001828054610b2790615c56565b8015610b745780601f10610b4957610100808354040283529160200191610b74565b820191906000526020600020905b815481529060010190602001808311610b5757829003601f168201915b505050505081565b600d8054610afb90615c56565b6000610b9481612d6c565b6011546001600160a01b0316610cff57601180546001600160a01b03808b166001600160a01b031992831617909255600e80548a8416908316179055600f80548984169083161790556010805492881691831682178155869290916001600160a81b031990911617600160a01b836002811115610c2157634e487b7160e01b600052602160045260246000fd5b02179055508251610c3990600b906020860190614f92565b508151610c4d90600c906020850190614f92565b50610c59600033612d76565b600b600c604051602001610c6e92919061578f565b604051602081830303815290604052600d9080519060200190610c92929190614f92565b50600f54600e546011546010546040517f13d3a1031aba66188cca5785e8045078864e8f69c24715761bf0449ef10304d694610cf2946001600160a01b039182169490821693911691600b91600c91600160a01b90910460ff1690615819565b60405180910390a1610d3d565b60405162461bcd60e51b8152602060048201526013602482015272105b1c9958591e481a5b9a5d1a585b1a5e9959606a1b6044820152606401610a48565b5050505050505050565b806000610d548585611b57565b9050610d608183615bfc565b95945050505050565b610d733382612d80565b610d8f5760405162461bcd60e51b8152600401610a48906159ac565b610ae9838383612dfe565b600080600080610dad8a8a8a8a8a612b7e565b9050612710610dbc8683615b9e565b610dc69190615a9f565b9250610dd28382615a87565b9350610dde8382615bfc565b91505096509650969350505050565b600082815260076020526040902060010154610e0881612d6c565b610ae98383612fa5565b6011546040805163313ce56760e01b815290516000926001600160a01b03169163313ce567916004808301926020929190829003018186803b158015610e5757600080fd5b505afa158015610e6b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e8f91906155fd565b60ff16905090565b600082815260156020526040812060038101546004909101548291610ebb91615a46565b905082610f915780610ecb610e12565b610ed690600a615af6565b600f60009054906101000a90046001600160a01b03166001600160a01b03166363bd1d4a6040518163ffffffff1660e01b815260040160206040518083038186803b158015610f2457600080fd5b505afa158015610f38573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f5c91906154c8565b600087815260156020526040902060020154610f789190615b9e565b610f829190615a9f565b610f8c9190615bbd565b61105b565b80610f9a610e12565b610fa590600a615af6565b600f60009054906101000a90046001600160a01b03166001600160a01b03166363bd1d4a6040518163ffffffff1660e01b815260040160206040518083038186803b158015610ff357600080fd5b505afa158015611007573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061102b91906154c8565b6000878152601560205260409020600101546110479190615b9e565b6110519190615a9f565b61105b9190615bbd565b949350505050565b6001600160a01b03811633146110d35760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608401610a48565b6110dd828261302b565b5050565b610ae983838360405180602001604052806000815250612735565b600a5460009081908190819060ff161561113e5760405162461bcd60e51b81526020600482015260036024820152624f333360e81b6044820152606401610a48565b6001601054600160a01b900460ff16600281111561116c57634e487b7160e01b600052602160045260246000fd5b14806112975750600f60009054906101000a90046001600160a01b03166001600160a01b0316632677327a6040518163ffffffff1660e01b815260040160206040518083038186803b1580156111c157600080fd5b505afa1580156111d5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111f99190615108565b6001600160a01b031663f7d52fa142611219610100890160e08a016155e3565b63ffffffff166112299190615bfc565b6040518263ffffffff1660e01b815260040161124791815260200190565b60206040518083038186803b15801561125f57600080fd5b505afa158015611273573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611297919061528d565b6112c95760405162461bcd60e51b815260206004820152600360248201526204f33360ec1b6044820152606401610a48565b60006113296112de60a0880160808901615271565b6101608801356112f460e08a0160c08b0161555f565b6001600160801b03164261130f6101008c0160e08d016155e3565b63ffffffff1661131f9190615bfc565b8a60400135612b7e565b90506002611335610e12565b61133f9190615bfc565b61134a90600a615af6565b611355906005615b9e565b81116113925760405162461bcd60e51b815260206004820152600c60248201526b46656520746f6f206c65737360a01b6044820152606401610a48565b600261139c610e12565b6113a69190615bfc565b6113b190600a615af6565b6113bc90605f615b9e565b81106113f95760405162461bcd60e51b815260206004820152600c60248201526b08ccaca40e8dede40d0d2ced60a31b6044820152606401610a48565b600061140b60e0880160c0890161555f565b61141c610100890160e08a016155e3565b604080516001600160801b03909316602084015263ffffffff9091169082015260600160408051601f198184030181529190528051602090910120601054909150611501906001600160a01b0316637d191bdb61147d6101808b018b6159fa565b6040518363ffffffff1660e01b815260040161149a929190615918565b60206040518083038186803b1580156114b257600080fd5b505afa1580156114c6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114ea9190615108565b6114f760208a018a6150ec565b8960200135610d47565b92506127106115108484615b9e565b61151a9190615a9f565b6115249083615a87565b915086610140013582111561157b5760405162461bcd60e51b815260206004820152601960248201527f507269636520646966666572656e636520746f6f2068696768000000000000006044820152606401610a48565b600061159282846107e460a08c0160808d01615271565b90508261159d610e12565b6115a890600a615af6565b6115b7906101208b0135615b9e565b6115c19190615a9f565b94508085111561163e576115db6080890160608a01615271565b61160d5760405162461bcd60e51b81526020600482015260036024820152624f323960e81b6044820152606401610a48565b809450611618610e12565b61162390600a615af6565b61162d8685615b9e565b6116379190615a9f565b9550611647565b87610120013595505b61164f610e12565b61165a90600a615af6565b600f54604080516331de8ea560e11b8152905188926001600160a01b0316916363bd1d4a916004808301926020929190829003018186803b15801561169e57600080fd5b505afa1580156116b2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116d691906154c8565b6116e09190615b9e565b6116ea9190615a9f565b96505050509193509193565b6117207f65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a33612592565b1561173757600a805460ff19166001179055611793565b611742600033612592565b1561175e57600a805460ff19811660ff90911615179055611793565b60405162461bcd60e51b815260206004820152600a60248201526957726f6e6720726f6c6560b01b6044820152606401610a48565b600a5460405160ff909116151581527f9422424b175dda897495a07b091ef74a3ef715cf6d866fc972954c1c7f4593049060200160405180910390a1565b600080516020615dac8339815191526117e981612d6c565b6000838152600360205260409020546001600160a01b03166118335760405162461bcd60e51b815260206004820152600360248201526204f31360ec1b6044820152606401610a48565b600083815260126020526040902060048101544263ffffffff90911611156118825760405162461bcd60e51b815260206004820152600260248201526113cd60f21b6044820152606401610a48565b6001815460ff1660038111156118a857634e487b7160e01b600052602160045260246000fd5b146118da5760405162461bcd60e51b81526020600482015260026024820152614f3560f01b6044820152606401610a48565b6006810154600090600160201b900460ff1680156119065750815461010090046001600160801b031684115b8061193657506006820154600160201b900460ff161580156119365750815461010090046001600160801b031684105b1561195e5761195785858460060160049054906101000a900460ff16613092565b9050611a29565b815460ff19166003178255600e54604051636198e33960e01b8152600481018790526001600160a01b0390911690636198e33990602401600060405180830381600087803b1580156119af57600080fd5b505af11580156119c3573d6000803e3d6000fd5b505050506119d08561327b565b600382015460068301546040805192835260208301879052600160201b90910460ff1615159082015285907f06b9a7d5e559ec958118dcc25fab116916793fa9782acbf47186bf70bc4cf88e9060600160405180910390a25b816005015460096000828254611a3f9190615bfc565b9091555050600f546040805163488d8b8f60e11b815290516001600160a01b039092169163911b171e91600480820192602092909190829003018186803b158015611a8957600080fd5b505afa158015611a9d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ac19190615108565b6001600160a01b0316633a5d92a8836005015483611adf9190615bbd565b84600301548560050154611af39190615bfc565b6040516001600160e01b031960e085901b1681526004810192909252602482015260448101889052606401600060405180830381600087803b158015611b3857600080fd5b505af1158015611b4c573d6000803e3d6000fd5b505050505050505050565b600080826001600160a01b0316846001600160a01b031614158015611b8457506001600160a01b03841615155b8015611b9857506001600160a01b0384163b155b15611ca75760105460405163010de89960e21b81526001600160a01b038681166004830152600092169063ad1b1493908290630437a2649060240160206040518083038186803b158015611beb57600080fd5b505afa158015611bff573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c2391906155fd565b6040516001600160e01b031960e084901b16815260ff909116600482015260240160206040518083038186803b158015611c5c57600080fd5b505afa158015611c70573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c9491906155fd565b9050611ca360ff821683615a87565b9150505b61105b816019615b9e565b600061091482612c9e565b601154600e5460405163095ea7b360e01b81526001600160a01b039182166004820152600019602482015291169063095ea7b390604401602060405180830381600087803b158015611d0e57600080fd5b505af1158015611d22573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d46919061528d565b50565b600080611d57836001610e97565b90506000611d66846000610e97565b9050808213611d75578061105b565b5092915050565b60006001600160a01b038216611de65760405162461bcd60e51b815260206004820152602960248201527f4552433732313a2061646472657373207a65726f206973206e6f7420612076616044820152683634b21037bbb732b960b91b6064820152608401610a48565b506001600160a01b031660009081526004602052604090205490565b6000600080516020615dac833981519152611e1c81612d6c565b6000611e2e60e0860160c0870161555f565b611e3f610100870160e088016155e3565b604080516001600160801b03909316602084015263ffffffff9091169082015260600160405160208183030381529060405280519060200120905060006127108660200135876101200135611e949190615b9e565b611e9e9190615a9f565b9050600060405180610120016040528060016003811115611ecf57634e487b7160e01b600052602160045260246000fd5b8152602001611ee460e08a0160c08b0161555f565b6001600160801b03168152610100890135602082018190526040820152606001611f13846101208b0135615bfc565b8152602001611f296101008a0160e08b016155e3565b63ffffffff90811682526101208a0135602083015288166040820152606001611f5860a08a0160808b01615271565b151590529050611f66613322565b945060136000611f7960208a018a6150ec565b6001600160a01b031681526020808201929092526040908101600090812080546001818101835591835284832001899055888252601290935220825181548493839160ff191690836003811115611fe057634e487b7160e01b600052602160045260246000fd5b0217905550602082810151825470ffffffffffffffffffffffffffffffff0019166101006001600160801b03909216820217835560408401516001840155606084015160028401556080840151600384015560a084015160048401805463ffffffff191663ffffffff92831617905560c0850151600585015560e0850151600690940180549290950151931664ffffffffff1990911617600160201b92151592909202919091179091556120a09061209a908901896150ec565b8661333c565b600f54604080516309b41a1b60e11b81529051612131926001600160a01b0316916313683436916004808301926020929190829003018186803b1580156120e657600080fd5b505afa1580156120fa573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061211e9190615108565b6011546001600160a01b0316908461348a565b600e546060820151608083015160405163edd0d42160e01b815260048101899052602481019290925260448201526001600160a01b039091169063edd0d42190606401600060405180830381600087803b15801561218e57600080fd5b505af11580156121a2573d6000803e3d6000fd5b50505050600f60009054906101000a90046001600160a01b03166001600160a01b03166395b12ea36040518163ffffffff1660e01b815260040160206040518083038186803b1580156121f457600080fd5b505afa158015612208573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061222c9190615108565b6001600160a01b031663710b2815863061224960208c018c6150ec565b6040516001600160e01b031960e086901b16815260048101939093526001600160a01b039182166024840152166044820152606401600060405180830381600087803b15801561229857600080fd5b505af11580156122ac573d6000803e3d6000fd5b50505050866101200135600960008282546122c79190615a87565b909155506122dd905060a0880160808901615271565b15612348576000838152601560205260408120600101805460a08a01359290612307908490615a87565b9091555061231c905082610120890135615bfc565b6000848152601560205260408120600301805490919061233d908490615a46565b909155506123a99050565b6000838152601560205260408120600201805460a08a0135929061236d908490615a87565b90915550612382905082610120890135615bfc565b600084815260156020526040812060040180549091906123a3908490615a46565b90915550505b60006123b484611d49565b9050600f60009054906101000a90046001600160a01b03166001600160a01b03166350ec40e06040518163ffffffff1660e01b815260040160206040518083038186803b15801561240457600080fd5b505afa158015612418573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061243c91906154c8565b81131561247b5760405162461bcd60e51b815260206004820152600d60248201526c098dee6e640e8dede40d0d2ced609b1b6044820152606401610a48565b8561248960208a018a6150ec565b604080518681526101208c01356020820152908101849052606081018790526001600160a01b0391909116907ffa6101f13be10247a3f27ba031321ca444c4bf1eb56aade9f1c96f5e621164aa9060800160405180910390a3505050505092915050565b600061a8c06124fc4284615bfc565b101561250a57506000919050565b600062034bc061251a4285615bfc565b10801561253e5750620151806125328461e100615a87565b61253c9190615ccc565b155b9050600062093a806170806125566201518087615bfc565b6125609190615bfc565b61256a9190615ccc565b1580156125825750620b34c06125804286615bfc565b105b9050818061105b57509392505050565b60009182526007602090815260408084206001600160a01b0393909316845291905290205460ff1690565b60606002805461092990615c56565b6110dd3383836134dc565b600082600f60009054906101000a90046001600160a01b03166001600160a01b03166363bd1d4a6040518163ffffffff1660e01b815260040160206040518083038186803b15801561262857600080fd5b505afa15801561263c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061266091906154c8565b61266a9190615bfc565b612672610e12565b61267d90600a615af6565b6126878685610e97565b600f60009054906101000a90046001600160a01b03166001600160a01b03166350ec40e06040518163ffffffff1660e01b815260040160206040518083038186803b1580156126d557600080fd5b505afa1580156126e9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061270d91906154c8565b6127179190615bbd565b6127219190615b9e565b61272b9190615a9f565b90505b9392505050565b61273f3383612d80565b61275b5760405162461bcd60e51b8152600401610a48906159ac565b612767848484846135ab565b50505050565b600080516020615dac83398151915261278581612d6c565b604080516001600160801b03851660208083019190915263ffffffff85168284015282518083038401815260609092019092528051910120428363ffffffff1610806127e1575061a8c06127df4263ffffffff8616615bfc565b105b1561281d5760405162461bcd60e51b815260206004820152600c60248201526b57726f6e672065787069727960a01b6044820152606401610a48565b60008181526015602052604090206007015460ff161561283d5750505050565b61284c8363ffffffff166124ed565b80156128ee5750600f60009054906101000a90046001600160a01b03166001600160a01b031663d63a95cf6040518163ffffffff1660e01b815260040160206040518083038186803b1580156128a157600080fd5b505afa1580156128b5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128d9919061557b565b6128e39085615ca6565b6001600160801b0316155b15612a855760405180610100016040528082815260200160156000848152602001908152602001600020600101548152602001601560008481526020019081526020016000206002015481526020016015600084815260200190815260200160002060030154815260200160156000848152602001908152602001600020600401548152602001856001600160801b031681526020018463ffffffff1681526020016001151581525060156000838152602001908152602001600020600082015181600001556020820151816001015560408201518160020155606082015181600301556080820151816004015560a0820151816005015560c0820151816006015560e08201518160070160006101000a81548160ff0219169083151502179055509050507fb373e533c35db97af93fa6fd93a43d7bb03943fa27553f266d118ab174b8c27784848330604051612a7894939291906001600160801b0394909416845263ffffffff92909216602084015260408301526001600160a01b0316606082015260800190565b60405180910390a1612767565b60405162461bcd60e51b815260206004820152601c60248201527f496e76616c696420737472696b65206f722065787069726174696f6e000000006044820152606401610a48565b6060612ad882612c3f565b6000612aef60408051602081019091526000815290565b90506000815111612b0f576040518060200160405280600081525061272e565b80612b19846135de565b604051602001612b2a929190615760565b6040516020818303038152906040529392505050565b60136020528160005260406000208181548110612b5c57600080fd5b90600052602060002001600091509150505481565b600c8054610afb90615c56565b60006305f5e100612b8d610e12565b612b9890600a615af6565b612ba78487898860018d6136f8565b612bb19190615b9e565b612bbb9190615a9f565b9695505050505050565b600082815260076020526040902060010154612be081612d6c565b610ae9838361302b565b6000612bf581612d6c565b506001600160a01b03166000908152601460205260409020805460ff19166001179055565b60006001600160e01b03198216637965db0b60e01b14806109145750610914826137c9565b6000818152600360205260409020546001600160a01b0316611d465760405162461bcd60e51b8152602060048201526018602482015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b6044820152606401610a48565b6000818152600360205260408120546001600160a01b0316806109145760405162461bcd60e51b8152602060048201526018602482015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b6044820152606401610a48565b600081815260056020526040902080546001600160a01b0319166001600160a01b0384169081179091558190612d3382612c9e565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b611d468133613819565b6110dd8282612fa5565b600080612d8c83612c9e565b9050806001600160a01b0316846001600160a01b03161480612dd357506001600160a01b0380821660009081526006602090815260408083209388168352929052205460ff165b8061105b5750836001600160a01b0316612dec846109ac565b6001600160a01b031614949350505050565b826001600160a01b0316612e1182612c9e565b6001600160a01b031614612e755760405162461bcd60e51b815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201526437bbb732b960d91b6064820152608401610a48565b6001600160a01b038216612ed75760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610a48565b612ee283838361387d565b612eed600082612cfe565b6001600160a01b0383166000908152600460205260408120805460019290612f16908490615bfc565b90915550506001600160a01b0382166000908152600460205260408120805460019290612f44908490615a87565b909155505060008181526003602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b612faf8282612592565b6110dd5760008281526007602090815260408083206001600160a01b03851684529091529020805460ff19166001179055612fe73390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6130358282612592565b156110dd5760008281526007602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6000838152601260205260408120816130aa86611cb2565b6002830154600e546040516381b34f1560e01b8152600481018a9052306024820152604481018390529195509192506001600160a01b03909116906381b34f1590606401600060405180830381600087803b15801561310857600080fd5b505af115801561311c573d6000803e3d6000fd5b505060115461313892506001600160a01b03169050828561348a565b816002015483101561317857600e546002830154613178916001600160a01b031690613165908690615bfc565b6011546001600160a01b0316919061348a565b816003015483116131cb57857fc88c04f82f76cf4112dc206d1a563be25c04a4a762a699eccd4d4abc6df0dff08484600301546131b59190615bfc565b60405190815260200160405180910390a261320f565b857fa569991d55d525eae5729bac6890aeb7c0bdcd198f36ca0d0a7da8c2c0a734fb8360030154856131fd9190615bfc565b60405190815260200160405180910390a25b6132188661327b565b815460ff19166002178255604080518481526020810187905285151581830152905187916001600160a01b038416917ff394088c7503260c927488ca4397d6b43146f13c239078415e6f14029e5cb7f8916060908290030190a350509392505050565b600061328682612c9e565b90506132948160008461387d565b61329f600083612cfe565b6001600160a01b03811660009081526004602052604081208054600192906132c8908490615bfc565b909155505060008281526003602052604080822080546001600160a01b0319169055518391906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a45050565b600880546000918261333383615c8b565b91905055905090565b6001600160a01b0382166133925760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610a48565b6000818152600360205260409020546001600160a01b0316156133f75760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610a48565b6134036000838361387d565b6001600160a01b038216600090815260046020526040812080546001929061342c908490615a87565b909155505060008181526003602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052610ae9908490613934565b816001600160a01b0316836001600160a01b0316141561353e5760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610a48565b6001600160a01b03838116600081815260066020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b6135b6848484612dfe565b6135c284848484613a06565b6127675760405162461bcd60e51b8152600401610a489061595a565b6060816136025750506040805180820190915260018152600360fc1b602082015290565b8160005b811561362c578061361681615c8b565b91506136259050600a83615a9f565b9150613606565b60008167ffffffffffffffff81111561365557634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f19166020018201604052801561367f576020820181803683370190505b5090505b841561105b57613694600183615bfc565b91506136a1600a86615ccc565b6136ac906030615a87565b60f81b8183815181106136cf57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a9053506136f1600a86615a9f565b9450613683565b6000806137086305f5e100613b13565b90506000613717612710613b13565b90506000613731826137288c613b13565b600f0b90613b31565b90506000613743600f83900b83613b98565b90506000613754856137288d613b13565b90506000613765866137288d613b13565b905060006137826137796301e13380613b13565b6137288d613b13565b90506000613794858585858f8f613bce565b90506137ac6137a7600f83900b8a613b98565b613ca5565b67ffffffffffffffff169f9e505050505050505050505050505050565b60006001600160e01b031982166380ac58cd60e01b14806137fa57506001600160e01b03198216635b5e139f60e01b145b8061091457506301ffc9a760e01b6001600160e01b0319831614610914565b6138238282612592565b6110dd5761383b816001600160a01b03166014613cc1565b613846836020613cc1565b6040516020016138579291906157a4565b60408051601f198184030181529082905262461bcd60e51b8252610a4891600401615947565b6001600160a01b0383161580159061389d57506001600160a01b03821615155b80156138c257506001600160a01b03821660009081526014602052604090205460ff16155b80156138e757506001600160a01b03831660009081526014602052604090205460ff16155b15610ae95760405162461bcd60e51b815260206004820152601a60248201527f546f6b656e207472616e73666572206e6f7420616c6c6f7765640000000000006044820152606401610a48565b6000613989826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316613ea39092919063ffffffff16565b805190915015610ae957808060200190518101906139a7919061528d565b610ae95760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610a48565b60006001600160a01b0384163b15613b0857604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290613a4a90339089908890889060040161586f565b602060405180830381600087803b158015613a6457600080fd5b505af1925050508015613a94575060408051601f3d908101601f19168201909252613a91918101906153eb565b60015b613aee573d808015613ac2576040519150601f19603f3d011682016040523d82523d6000602084013e613ac7565b606091505b508051613ae65760405162461bcd60e51b8152600401610a489061595a565b805181602001fd5b6001600160e01b031916630a85bd0160e11b14905061105b565b506001949350505050565b6000677fffffffffffffff821115613b2a57600080fd5b5060401b90565b600081600f0b60001415613b4457600080fd5b600082600f0b604085600f0b901b81613b6d57634e487b7160e01b600052601260045260246000fd5b05905060016001607f1b03198112801590613b8f575060016001607f1b038113155b61272e57600080fd5b6000600f83810b9083900b0260401d60016001607f1b03198112801590613b8f575060016001607f1b0381131561272e57600080fd5b600080613bdf600f86900b89613b98565b90506000613bef82600f0b613eb2565b90506000613c2c82613728600186600f0b901d613c23613c1b8e8e600f0b613b3190919063ffffffff16565b600f0b613ed4565b600f0b90613f0e565b90506000613c3e600f83900b84613f41565b90508615613c71578515613c6057613c5581613f74565b945050505050612bbb565b613c55613c6c82615ce0565b613f74565b8515613c9657613c55613c8382613f74565b613c8d6001613b13565b600f0b90613f41565b613c55613c83613c6c83615ce0565b60008082600f0b1215613cb757600080fd5b50600f0b60401d90565b60606000613cd0836002615b9e565b613cdb906002615a87565b67ffffffffffffffff811115613d0157634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015613d2b576020820181803683370190505b509050600360fc1b81600081518110613d5457634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110613d9157634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a9053506000613db5846002615b9e565b613dc0906001615a87565b90505b6001811115613e54576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110613e0257634e487b7160e01b600052603260045260246000fd5b1a60f81b828281518110613e2657634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535060049490941c93613e4d81615c3f565b9050613dc3565b50831561272e5760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610a48565b606061272b8484600085614030565b60008082600f0b1215613ec457600080fd5b610914604083600f0b901b614161565b60008082600f0b13613ee557600080fd5b6080613ef083614343565b600f0b6fb17217f7d1cf79abc9e3b39803f2f6af02901c9050919050565b6000600f83810b9083900b0160016001607f1b03198112801590613b8f575060016001607f1b0381131561272e57600080fd5b6000600f82810b9084900b0360016001607f1b03198112801590613b8f575060016001607f1b0381131561272e57600080fd5b600080613f85600f84900b84613b98565b9050600061400f613ff4613fc3613fb4613fac600f87900b68030000000000000000613f0e565b600f0b613eb2565b67d3c84b78b749bd6b90613b98565b613c23613fe5613fd589600f0b61441d565b68019abac0ea1da6503690613b98565b679109f285df45239490613f0e565b613728600161400286615ce0565b600f0b901d600f0b614450565b9050600084600f0b13614022578061105b565b61105b600160401b82613f41565b6060824710156140915760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610a48565b6001600160a01b0385163b6140e85760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610a48565b600080866001600160a01b031685876040516141049190615744565b60006040518083038185875af1925050503d8060008114614141576040519150601f19603f3d011682016040523d82523d6000602084013e614146565b606091505b50915091506141568282866144a5565b979650505050505050565b60008161417057506000919050565b816001600160801b82106141895760809190911c9060401b5b600160401b821061419f5760409190911c9060201b5b600160201b82106141b55760209190911c9060101b5b6201000082106141ca5760109190911c9060081b5b61010082106141de5760089190911c9060041b5b601082106141f15760049190911c9060021b5b600882106141fd5760011b5b600181858161421c57634e487b7160e01b600052601260045260246000fd5b048201901c9050600181858161424257634e487b7160e01b600052601260045260246000fd5b048201901c9050600181858161426857634e487b7160e01b600052601260045260246000fd5b048201901c9050600181858161428e57634e487b7160e01b600052601260045260246000fd5b048201901c905060018185816142b457634e487b7160e01b600052601260045260246000fd5b048201901c905060018185816142da57634e487b7160e01b600052601260045260246000fd5b048201901c9050600181858161430057634e487b7160e01b600052601260045260246000fd5b048201901c9050600081858161432657634e487b7160e01b600052601260045260246000fd5b0490508082106143365780610d60565b509392505050565b919050565b60008082600f0b1361435457600080fd5b6000600f83900b600160401b811261436e576040918201911d5b600160201b8112614381576020918201911d5b620100008112614393576010918201911d5b61010081126143a4576008918201911d5b601081126143b4576004918201911d5b600481126143c4576002918201911d5b600281126143d3576001820191505b603f19820160401b600f85900b607f8490031b6001603f1b5b60008113156144125790800260ff81901c8281029390930192607f011c9060011d6143ec565b509095945050505050565b6000600f82900b60016001607f1b0319141561443857600080fd5b600082600f0b126144495781610914565b5060000390565b6000600160461b82600f0b1261446557600080fd5b683fffffffffffffffff1982600f0b121561448257506000919050565b610914608083600f0b700171547652b82fe1777d0ffda0d23a7d1202901d6144de565b606083156144b457508161272e565b8251156144c45782518084602001fd5b8160405162461bcd60e51b8152600401610a489190615947565b6000600160461b82600f0b126144f357600080fd5b683fffffffffffffffff1982600f0b121561451057506000919050565b6001607f1b60006001603f1b8416600f0b131561453e5770016a09e667f3bcc908b2fb1366ea957d3e0260801c5b60008367400000000000000016600f0b131561456b577001306fe0a31b7152de8d5a46305c85edec0260801c5b60008367200000000000000016600f0b1315614598577001172b83c7d517adcdf7c8c50eb14a791f0260801c5b60008367100000000000000016600f0b13156145c55770010b5586cf9890f6298b92b71842a983630260801c5b60008367080000000000000016600f0b13156145f2577001059b0d31585743ae7c548eb68ca417fd0260801c5b60008367040000000000000016600f0b131561461f57700102c9a3e778060ee6f7caca4f7a29bde80260801c5b60008367020000000000000016600f0b131561464c5770010163da9fb33356d84a66ae336dcdfa3f0260801c5b60008367010000000000000016600f0b131561467957700100b1afa5abcbed6129ab13ec11dc95430260801c5b600083668000000000000016600f0b13156146a55770010058c86da1c09ea1ff19d294cf2f679b0260801c5b600083664000000000000016600f0b13156146d1577001002c605e2e8cec506d21bfc89a23a00f0260801c5b600083662000000000000016600f0b13156146fd57700100162f3904051fa128bca9c55c31e5df0260801c5b600083661000000000000016600f0b1315614729577001000b175effdc76ba38e31671ca9397250260801c5b600083660800000000000016600f0b131561475557700100058ba01fb9f96d6cacd4b180917c3d0260801c5b600083660400000000000016600f0b13156147815770010002c5cc37da9491d0985c348c68e7b30260801c5b600083660200000000000016600f0b13156147ad577001000162e525ee054754457d59952920260260801c5b600083660100000000000016600f0b13156147d95770010000b17255775c040618bf4a4ade83fc0260801c5b6000836580000000000016600f0b1315614804577001000058b91b5bc9ae2eed81e9b7d4cfab0260801c5b6000836540000000000016600f0b131561482f57700100002c5c89d5ec6ca4d7c8acc017b7c90260801c5b6000836520000000000016600f0b131561485a5770010000162e43f4f831060e02d839a9d16d0260801c5b6000836510000000000016600f0b131561488557700100000b1721bcfc99d9f890ea069117630260801c5b6000836508000000000016600f0b13156148b05770010000058b90cf1e6d97f9ca14dbcc16280260801c5b6000836504000000000016600f0b13156148db577001000002c5c863b73f016468f6bac5ca2b0260801c5b6000836502000000000016600f0b131561490657700100000162e430e5a18f6119e3c02282a50260801c5b6000836501000000000016600f0b1315614931577001000000b1721835514b86e6d96efd1bfe0260801c5b60008364800000000016600f0b131561495b57700100000058b90c0b48c6be5df846c5b2ef0260801c5b60008364400000000016600f0b13156149855770010000002c5c8601cc6b9e94213c72737a0260801c5b60008364200000000016600f0b13156149af577001000000162e42fff037df38aa2b219f060260801c5b60008364100000000016600f0b13156149d95770010000000b17217fba9c739aa5819f44f90260801c5b60008364080000000016600f0b1315614a03577001000000058b90bfcdee5acd3c1cedc8230260801c5b60008364040000000016600f0b1315614a2d57700100000002c5c85fe31f35a6a30da1be500260801c5b60008364020000000016600f0b1315614a575770010000000162e42ff0999ce3541b9fffcf0260801c5b600083600160201b16600f0b1315614a8057700100000000b17217f80f4ef5aadda455540260801c5b600083638000000016600f0b1315614aa95770010000000058b90bfbf8479bd5a81b51ad0260801c5b600083634000000016600f0b1315614ad2577001000000002c5c85fdf84bd62ae30a74cc0260801c5b600083632000000016600f0b1315614afb57700100000000162e42fefb2fed257559bdaa0260801c5b600083631000000016600f0b1315614b24577001000000000b17217f7d5a7716bba4a9ae0260801c5b600083630800000016600f0b1315614b4d57700100000000058b90bfbe9ddbac5e109cce0260801c5b600083630400000016600f0b1315614b765770010000000002c5c85fdf4b15de6f17eb0d0260801c5b600083630200000016600f0b1315614b9f577001000000000162e42fefa494f1478fde050260801c5b600083630100000016600f0b1315614bc85770010000000000b17217f7d20cf927c8e94c0260801c5b6000836280000016600f0b1315614bf0577001000000000058b90bfbe8f71cb4e4b33d0260801c5b6000836240000016600f0b1315614c1857700100000000002c5c85fdf477b662b269450260801c5b6000836220000016600f0b1315614c405770010000000000162e42fefa3ae53369388c0260801c5b6000836210000016600f0b1315614c6857700100000000000b17217f7d1d351a389d400260801c5b6000836208000016600f0b1315614c905770010000000000058b90bfbe8e8b2d3d4ede0260801c5b6000836204000016600f0b1315614cb8577001000000000002c5c85fdf4741bea6e77e0260801c5b6000836202000016600f0b1315614ce057700100000000000162e42fefa39fe95583c20260801c5b6000836201000016600f0b1315614d08577001000000000000b17217f7d1cfb72b45e10260801c5b60008361800016600f0b1315614d2f57700100000000000058b90bfbe8e7cc35c3f00260801c5b60008361400016600f0b1315614d565770010000000000002c5c85fdf473e242ea380260801c5b60008361200016600f0b1315614d7d577001000000000000162e42fefa39f02b772c0260801c5b60008361100016600f0b1315614da45770010000000000000b17217f7d1cf7d83c1a0260801c5b60008361080016600f0b1315614dcb577001000000000000058b90bfbe8e7bdcbe2e0260801c5b60008361040016600f0b1315614df257700100000000000002c5c85fdf473dea871f0260801c5b60008361020016600f0b1315614e195770010000000000000162e42fefa39ef44d910260801c5b60008361010016600f0b1315614e4057700100000000000000b17217f7d1cf79e9490260801c5b600083608016600f0b1315614e665770010000000000000058b90bfbe8e7bce5440260801c5b600083604016600f0b1315614e8c577001000000000000002c5c85fdf473de6eca0260801c5b600083602016600f0b1315614eb257700100000000000000162e42fefa39ef366f0260801c5b600083601016600f0b1315614ed8577001000000000000000b17217f7d1cf79afa0260801c5b600083600816600f0b1315614efe57700100000000000000058b90bfbe8e7bcd6d0260801c5b600083600416600f0b1315614f245770010000000000000002c5c85fdf473de6b20260801c5b600083600216600f0b1315614f4a577001000000000000000162e42fefa39ef3580260801c5b600083600116600f0b1315614f705770010000000000000000b17217f7d1cf79ab0260801c5b600f83810b60401d603f03900b1c60016001607f1b0381111561091457600080fd5b828054614f9e90615c56565b90600052602060002090601f016020900481019282614fc05760008555615006565b82601f10614fd957805160ff1916838001178555615006565b82800160010185558215615006579182015b82811115615006578251825591602001919060010190614feb565b50615012929150615016565b5090565b5b808211156150125760008155600101615017565b600067ffffffffffffffff8084111561504657615046615d47565b604051601f8501601f19908116603f0116810190828211818310171561506e5761506e615d47565b8160405280935085815286868601111561508757600080fd5b858560208301376000602087830101525050509392505050565b600082601f8301126150b1578081fd5b61272e8383356020850161502b565b60006101a082840312156150d2578081fd5b50919050565b803563ffffffff8116811461433e57600080fd5b6000602082840312156150fd578081fd5b813561272e81615d5d565b600060208284031215615119578081fd5b815161272e81615d5d565b60008060408385031215615136578081fd5b823561514181615d5d565b9150602083013561515181615d5d565b809150509250929050565b600080600060608486031215615170578081fd5b833561517b81615d5d565b9250602084013561518b81615d5d565b929592945050506040919091013590565b600080600080608085870312156151b1578081fd5b84356151bc81615d5d565b935060208501356151cc81615d5d565b925060408501359150606085013567ffffffffffffffff8111156151ee578182fd5b8501601f810187136151fe578182fd5b61520d8782356020840161502b565b91505092959194509250565b6000806040838503121561522b578182fd5b823561523681615d5d565b9150602083013561515181615d72565b60008060408385031215615258578182fd5b823561526381615d5d565b946020939093013593505050565b600060208284031215615282578081fd5b813561272e81615d72565b60006020828403121561529e578081fd5b815161272e81615d72565b600080600080600060a086880312156152c0578283fd5b85356152cb81615d72565b97602087013597506040870135966060810135965060800135945092505050565b60008060008060008060c08789031215615304578384fd5b863561530f81615d72565b9860208801359850604088013597606081013597506080810135965060a00135945092505050565b600060208284031215615348578081fd5b5035919050565b60008060408385031215615361578182fd5b82359150602083013561515181615d5d565b60008060408385031215615385578182fd5b82359150602083013561515181615d72565b6000806000606084860312156153ab578081fd5b833592506020840135915060408401356153c481615d72565b809150509250925092565b6000602082840312156153e0578081fd5b813561272e81615d80565b6000602082840312156153fc578081fd5b815161272e81615d80565b600080600080600080600060e0888a031215615421578485fd5b873561542c81615d5d565b9650602088013561543c81615d5d565b9550604088013561544c81615d5d565b9450606088013561545c81615d5d565b935060808801356003811061546f578182fd5b925060a088013567ffffffffffffffff8082111561548b578283fd5b6154978b838c016150a1565b935060c08a01359150808211156154ac578283fd5b506154b98a828b016150a1565b91505092959891949750929550565b6000602082840312156154d9578081fd5b5051919050565b6000602082840312156154f1578081fd5b813567ffffffffffffffff811115615507578182fd5b61105b848285016150c0565b60008060408385031215615525578182fd5b823567ffffffffffffffff81111561553b578283fd5b615547858286016150c0565b925050615556602084016150d8565b90509250929050565b600060208284031215615570578081fd5b813561272e81615d96565b60006020828403121561558c578081fd5b815161272e81615d96565b600080604083850312156155a9578182fd5b82356155b481615d96565b9150615556602084016150d8565b600080604083850312156155d4578182fd5b50508035926020909101359150565b6000602082840312156155f4578081fd5b61272e826150d8565b60006020828403121561560e578081fd5b815160ff8116811461272e578182fd5b60008151808452615636816020860160208601615c13565b601f01601f19169290920160200192915050565b6003811061565a5761565a615d31565b9052565b6000815461566b81615c56565b808552602060018381168015615688576001811461569c576156ca565b60ff198516888401526040880195506156ca565b866000528260002060005b858110156156c25781548a82018601529083019084016156a7565b890184019650505b505050505092915050565b600081546156e281615c56565b600182811680156156fa576001811461570b5761573a565b60ff1984168752828701945061573a565b8560005260208060002060005b858110156157315781548a820152908401908201615718565b50505082870194505b5050505092915050565b60008251615756818460208701615c13565b9190910192915050565b60008351615772818460208801615c13565b835190830190615786818360208801615c13565b01949350505050565b600061272b61579e83866156d5565b846156d5565b7f416363657373436f6e74726f6c3a206163636f756e74200000000000000000008152600083516157dc816017850160208801615c13565b7001034b99036b4b9b9b4b733903937b6329607d1b601791840191820152835161580d816028840160208801615c13565b01602801949350505050565b6001600160a01b03878116825286811660208301528516604082015260c06060820181905260009061584d9083018661565e565b828103608084015261585f818661565e565b91505061415660a083018461564a565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090612bbb9083018461561e565b60208101610914828461564a565b610120810160048b106158c5576158c5615d31565b9981526001600160801b0398909816602089015260408801969096526060870194909452608086019290925263ffffffff90811660a086015260c08501919091521660e083015215156101009091015290565b60208152816020820152818360408301376000818301604090810191909152601f909201601f19160101919050565b60208152600061272e602083018461561e565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6020808252602e908201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560408201526d1c881b9bdc88185c1c1c9bdd995960921b606082015260800190565b6000808335601e19843603018112615a10578283fd5b83018035915067ffffffffffffffff821115615a2a578283fd5b602001915036819003821315615a3f57600080fd5b9250929050565b600080821280156001600160ff1b0384900385131615615a6857615a68615d05565b600160ff1b8390038412811615615a8157615a81615d05565b50500190565b60008219821115615a9a57615a9a615d05565b500190565b600082615aae57615aae615d1b565b500490565b600181815b80851115615aee578160001904821115615ad457615ad4615d05565b80851615615ae157918102915b93841c9390800290615ab8565b509250929050565b600061272e8383600082615b0c57506001610914565b81615b1957506000610914565b8160018114615b2f5760028114615b3957615b55565b6001915050610914565b60ff841115615b4a57615b4a615d05565b50506001821b610914565b5060208310610133831016604e8410600b8410161715615b78575081810a610914565b615b828383615ab3565b8060001904821115615b9657615b96615d05565b029392505050565b6000816000190483118215151615615bb857615bb8615d05565b500290565b60008083128015600160ff1b850184121615615bdb57615bdb615d05565b6001600160ff1b0384018313811615615bf657615bf6615d05565b50500390565b600082821015615c0e57615c0e615d05565b500390565b60005b83811015615c2e578181015183820152602001615c16565b838111156127675750506000910152565b600081615c4e57615c4e615d05565b506000190190565b600181811c90821680615c6a57607f821691505b602082108114156150d257634e487b7160e01b600052602260045260246000fd5b6000600019821415615c9f57615c9f615d05565b5060010190565b60006001600160801b0380841680615cc057615cc0615d1b565b92169190910692915050565b600082615cdb57615cdb615d1b565b500690565b600081600f0b60016001607f1b0319811415615cfe57615cfe615d05565b9003919050565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114611d4657600080fd5b8015158114611d4657600080fd5b6001600160e01b031981168114611d4657600080fd5b6001600160801b0381168114611d4657600080fdfe7a05a596cb0ce7fdea8a1e1ec73be300bdb35097c944ce1897202f7a13122eb2a26469706673582212205f7bd74cf944844069e0d24c2960179523225b4e17d34230165721d84e4acfed64736f6c63430008040033

[ Download: CSV Export  ]

A token is a representation of an on-chain or off-chain asset. The token page shows information such as price, total supply, holders, transfers and social links. Learn more about this page in our Knowledge Base.