ETH Price: $2,052.99 (+6.66%)

Contract

0x619ba1500F922577e56a30178D93A93e4Ee13dC3

Overview

ETH Balance

0 ETH

ETH Value

$0.00

More Info

Private Name Tags

Multichain Info

No addresses found
Transaction Hash
Block
From
To

There are no matching entries

Please try again later

Parent Transaction Hash Block From To
View All Internal Transactions

Cross-Chain Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
ResolveBlocker

Compiler Version
v0.8.20+commit.a1b79de6

Optimization Enabled:
Yes with 200 runs

Other Settings:
paris EvmVersion
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "../../utils/proxy/ProxyOwned.sol";
import "../../utils/proxy/ProxyPausable.sol";
import "../../utils/proxy/ProxyReentrancyGuard.sol";

import "../../interfaces/ISportsAMMV2Data.sol";
import "../../interfaces/ISportsAMMV2Manager.sol";
import "./../AMM/Ticket.sol";

contract ResolveBlocker is Initializable, ProxyOwned, ProxyPausable, ProxyReentrancyGuard {
    /// @notice The interface for accessing sports AMM data
    ISportsAMMV2Data public sportsAMMData;

    /// @notice The interface for the sports AMM manager
    ISportsAMMV2Manager public manager;

    /// @notice Mapping to track if a game is blocked for resolution
    /// @dev Maps gameId to a boolean indicating if the game is blocked
    mapping(bytes32 => bool) public gameIdBlockedForResolution;
    /// @dev Maps gameId to the reason for blocking the game
    mapping(bytes32 => string) public gameIdBlockReason;
    /// @notice Mapping to track if a game has been unblocked by an admin
    /// @dev Maps gameId to a boolean indicating if the game was unblocked by an admin
    mapping(bytes32 => bool) public gameIdUnblockedByAdmin;

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

    /// @notice Initializes the contract with the owner, SportsAMMV2Data, and manager addresses
    /// @param _owner The address of the contract owner
    /// @param _sportsAMMV2Data The address of the SportsAMMV2Data contract
    /// @param _manager The address of the manager contract
    function initialize(address _owner, address _sportsAMMV2Data, address _manager) external initializer {
        setOwner(_owner);
        initNonReentrant();
        sportsAMMData = ISportsAMMV2Data(_sportsAMMV2Data);
        manager = ISportsAMMV2Manager(_manager);
    }

    /// @notice Retrieves the blocked and unblocked status for a list of game IDs
    /// @param gameIds An array of game IDs to check
    /// @return blockedGames An array of booleans indicating if each game is blocked
    /// @return unblockedByAdmin An array of booleans indicating if each game is unblocked by admin
    function getGamesBlockedForResolution(
        bytes32[] memory gameIds
    ) external view returns (bool[] memory blockedGames, bool[] memory unblockedByAdmin, string[] memory blockReason) {
        blockedGames = new bool[](gameIds.length);
        unblockedByAdmin = new bool[](gameIds.length);
        blockReason = new string[](gameIds.length);
        for (uint i = 0; i < gameIds.length; i++) {
            blockedGames[i] = gameIdBlockedForResolution[gameIds[i]];
            unblockedByAdmin[i] = gameIdUnblockedByAdmin[gameIds[i]];
            blockReason[i] = gameIdBlockReason[gameIds[i]];
        }
    }

    /// @notice Checks if an address is whitelisted for unblocking games
    /// @param _address The address to check
    /// @return True if the address is whitelisted, false otherwise
    function isWhitelistedForUnblock(address _address) external view returns (bool) {
        return
            owner == _address ||
            manager.isWhitelistedAddress(_address, ISportsAMMV2Manager.Role.TICKET_PAUSER) ||
            manager.isWhitelistedAddress(_address, ISportsAMMV2Manager.Role.MARKET_RESOLVING);
    }

    /// @notice Blocks a list of games for resolution
    /// @param _gameIds An array of game IDs to block
    /// @param _reason The reason for blocking the games
    function blockGames(bytes32[] memory _gameIds, string memory _reason) external onlyWhitelistedForBlock {
        _blockGames(_gameIds, _reason, true);
        emit GamesBlockedForResolution(_gameIds, _reason);
    }

    /// @notice Unblocks a list of games for resolution
    /// @param _gameIds An array of game IDs to unblock
    function unblockGames(bytes32[] memory _gameIds) external onlyWhitelistedForUnblock {
        _blockGames(_gameIds, "", false);
        emit GamesUnblockedForResolution(_gameIds);
    }

    /// @notice Internal function to block or unblock games
    /// @param _gameIds An array of game IDs to block or unblock
    /// @param _blockGame A boolean indicating whether to block (true) or unblock (false) the games
    function _blockGames(bytes32[] memory _gameIds, string memory _reason, bool _blockGame) internal {
        for (uint i = 0; i < _gameIds.length; i++) {
            if (!_blockGame && gameIdBlockedForResolution[_gameIds[i]]) {
                gameIdUnblockedByAdmin[_gameIds[i]] = true;
            } else if (_blockGame && gameIdUnblockedByAdmin[_gameIds[i]]) {
                gameIdUnblockedByAdmin[_gameIds[i]] = false;
            }
            gameIdBlockedForResolution[_gameIds[i]] = _blockGame;
            if (bytes(_reason).length > 0) {
                gameIdBlockReason[_gameIds[i]] = _reason;
            }
        }
    }

    /// @notice Sets the Sports AMM Manager contract address
    /// @param _manager The address of Sports AMM Manager contract
    function setManager(address _manager) external onlyOwner {
        require(_manager != address(0), "Invalid address");
        manager = ISportsAMMV2Manager(_manager);
        emit SetManager(_manager);
    }

    /// @notice Sets the Sports AMM Data contract address
    /// @param _sportsAMMData The address of Sports AMM Data contract
    function setSportsAMMData(address _sportsAMMData) external onlyOwner {
        require(_sportsAMMData != address(0), "Invalid address");
        sportsAMMData = ISportsAMMV2Data(_sportsAMMData);
        emit SetSportsAMMData(_sportsAMMData);
    }

    /* ========== MODIFIERS ========== */
    /// @notice Modifier to ensure only whitelisted addresses can unblock games
    modifier onlyWhitelistedForUnblock() {
        require(
            msg.sender == owner ||
                manager.isWhitelistedAddress(msg.sender, ISportsAMMV2Manager.Role.TICKET_PAUSER) ||
                manager.isWhitelistedAddress(msg.sender, ISportsAMMV2Manager.Role.MARKET_RESOLVING),
            "Invalid sender"
        );
        _;
    }

    /// @notice Modifier to ensure only whitelisted addresses can block games
    modifier onlyWhitelistedForBlock() {
        require(
            msg.sender == owner ||
                manager.isWhitelistedAddress(msg.sender, ISportsAMMV2Manager.Role.TICKET_PAUSER) ||
                manager.isWhitelistedAddress(msg.sender, ISportsAMMV2Manager.Role.MARKET_RESOLVING),
            "Invalid sender"
        );
        _;
    }

    /* ========== EVENTS ========== */
    /// @notice Emitted when the Sports AMM Data contract address is set
    event SetSportsAMMData(address sportsAMMData);
    /// @notice Emitted when the Sports AMM Manager contract address is set
    event SetManager(address manager);
    /// @notice Emitted when games are blocked for resolution
    event GamesBlockedForResolution(bytes32[] gameIds, string reason);
    /// @notice Emitted when games are unblocked for resolution
    event GamesUnblockedForResolution(bytes32[] gameIds);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol)

pragma solidity ^0.8.20;

/**
 * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
 * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
 * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
 * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
 *
 * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
 * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
 * case an upgrade adds a module that needs to be initialized.
 *
 * For example:
 *
 * [.hljs-theme-light.nopadding]
 * ```solidity
 * contract MyToken is ERC20Upgradeable {
 *     function initialize() initializer public {
 *         __ERC20_init("MyToken", "MTK");
 *     }
 * }
 *
 * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
 *     function initializeV2() reinitializer(2) public {
 *         __ERC20Permit_init("MyToken");
 *     }
 * }
 * ```
 *
 * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
 * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
 *
 * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
 * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
 *
 * [CAUTION]
 * ====
 * Avoid leaving a contract uninitialized.
 *
 * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
 * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
 * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * /// @custom:oz-upgrades-unsafe-allow constructor
 * constructor() {
 *     _disableInitializers();
 * }
 * ```
 * ====
 */
abstract contract Initializable {
    /**
     * @dev Storage of the initializable contract.
     *
     * It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions
     * when using with upgradeable contracts.
     *
     * @custom:storage-location erc7201:openzeppelin.storage.Initializable
     */
    struct InitializableStorage {
        /**
         * @dev Indicates that the contract has been initialized.
         */
        uint64 _initialized;
        /**
         * @dev Indicates that the contract is in the process of being initialized.
         */
        bool _initializing;
    }

    // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Initializable")) - 1)) & ~bytes32(uint256(0xff))
    bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;

    /**
     * @dev The contract is already initialized.
     */
    error InvalidInitialization();

    /**
     * @dev The contract is not initializing.
     */
    error NotInitializing();

    /**
     * @dev Triggered when the contract has been initialized or reinitialized.
     */
    event Initialized(uint64 version);

    /**
     * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
     * `onlyInitializing` functions can be used to initialize parent contracts.
     *
     * Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any
     * number of times. This behavior in the constructor can be useful during testing and is not expected to be used in
     * production.
     *
     * Emits an {Initialized} event.
     */
    modifier initializer() {
        // solhint-disable-next-line var-name-mixedcase
        InitializableStorage storage $ = _getInitializableStorage();

        // Cache values to avoid duplicated sloads
        bool isTopLevelCall = !$._initializing;
        uint64 initialized = $._initialized;

        // Allowed calls:
        // - initialSetup: the contract is not in the initializing state and no previous version was
        //                 initialized
        // - construction: the contract is initialized at version 1 (no reininitialization) and the
        //                 current contract is just being deployed
        bool initialSetup = initialized == 0 && isTopLevelCall;
        bool construction = initialized == 1 && address(this).code.length == 0;

        if (!initialSetup && !construction) {
            revert InvalidInitialization();
        }
        $._initialized = 1;
        if (isTopLevelCall) {
            $._initializing = true;
        }
        _;
        if (isTopLevelCall) {
            $._initializing = false;
            emit Initialized(1);
        }
    }

    /**
     * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
     * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
     * used to initialize parent contracts.
     *
     * A reinitializer may be used after the original initialization step. This is essential to configure modules that
     * are added through upgrades and that require initialization.
     *
     * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
     * cannot be nested. If one is invoked in the context of another, execution will revert.
     *
     * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
     * a contract, executing them in the right order is up to the developer or operator.
     *
     * WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization.
     *
     * Emits an {Initialized} event.
     */
    modifier reinitializer(uint64 version) {
        // solhint-disable-next-line var-name-mixedcase
        InitializableStorage storage $ = _getInitializableStorage();

        if ($._initializing || $._initialized >= version) {
            revert InvalidInitialization();
        }
        $._initialized = version;
        $._initializing = true;
        _;
        $._initializing = false;
        emit Initialized(version);
    }

    /**
     * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
     * {initializer} and {reinitializer} modifiers, directly or indirectly.
     */
    modifier onlyInitializing() {
        _checkInitializing();
        _;
    }

    /**
     * @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}.
     */
    function _checkInitializing() internal view virtual {
        if (!_isInitializing()) {
            revert NotInitializing();
        }
    }

    /**
     * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
     * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
     * to any version. It is recommended to use this to lock implementation contracts that are designed to be called
     * through proxies.
     *
     * Emits an {Initialized} event the first time it is successfully executed.
     */
    function _disableInitializers() internal virtual {
        // solhint-disable-next-line var-name-mixedcase
        InitializableStorage storage $ = _getInitializableStorage();

        if ($._initializing) {
            revert InvalidInitialization();
        }
        if ($._initialized != type(uint64).max) {
            $._initialized = type(uint64).max;
            emit Initialized(type(uint64).max);
        }
    }

    /**
     * @dev Returns the highest version that has been initialized. See {reinitializer}.
     */
    function _getInitializedVersion() internal view returns (uint64) {
        return _getInitializableStorage()._initialized;
    }

    /**
     * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
     */
    function _isInitializing() internal view returns (bool) {
        return _getInitializableStorage()._initializing;
    }

    /**
     * @dev Returns a pointer to the storage namespace.
     */
    // solhint-disable-next-line var-name-mixedcase
    function _getInitializableStorage() private pure returns (InitializableStorage storage $) {
        assembly {
            $.slot := INITIALIZABLE_STORAGE
        }
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol)

pragma solidity ^0.8.20;

/**
 * @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.
 *
 * ==== Security Considerations
 *
 * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
 * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
 * considered as an intention to spend the allowance in any specific way. The second is that because permits have
 * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
 * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
 * generally recommended is:
 *
 * ```solidity
 * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
 *     try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
 *     doThing(..., value);
 * }
 *
 * function doThing(..., uint256 value) public {
 *     token.safeTransferFrom(msg.sender, address(this), value);
 *     ...
 * }
 * ```
 *
 * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
 * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
 * {SafeERC20-safeTransferFrom}).
 *
 * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
 * contracts should have entry points that don't rely on permit.
 */
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].
     *
     * CAUTION: See Security Considerations above.
     */
    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);
}

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

pragma solidity ^0.8.20;

/**
 * @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 value of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

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

    /**
     * @dev Moves a `value` amount of 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 value) 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 a `value` amount of tokens 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 value) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to` using the
     * allowance mechanism. `value` 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 value) external returns (bool);
}

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

pragma solidity ^0.8.20;

import {IERC20} from "../IERC20.sol";
import {IERC20Permit} from "../extensions/IERC20Permit.sol";
import {Address} from "../../../utils/Address.sol";

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

    /**
     * @dev An operation with an ERC20 token failed.
     */
    error SafeERC20FailedOperation(address token);

    /**
     * @dev Indicates a failed `decreaseAllowance` request.
     */
    error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);

    /**
     * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeTransfer(IERC20 token, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
    }

    /**
     * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
     * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
     */
    function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
    }

    /**
     * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 oldAllowance = token.allowance(address(this), spender);
        forceApprove(token, spender, oldAllowance + value);
    }

    /**
     * @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
     * value, non-reverting calls are assumed to be successful.
     */
    function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
        unchecked {
            uint256 currentAllowance = token.allowance(address(this), spender);
            if (currentAllowance < requestedDecrease) {
                revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
            }
            forceApprove(token, spender, currentAllowance - requestedDecrease);
        }
    }

    /**
     * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
     * to be set to zero before setting it to a non-zero value, such as USDT.
     */
    function forceApprove(IERC20 token, address spender, uint256 value) internal {
        bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));

        if (!_callOptionalReturnBool(token, approvalCall)) {
            _callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
            _callOptionalReturn(token, approvalCall);
        }
    }

    /**
     * @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);
        if (returndata.length != 0 && !abi.decode(returndata, (bool))) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @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).
     *
     * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
     */
    function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
        // 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 cannot use {Address-functionCall} here since this should return false
        // and not revert is the subcall reverts.

        (bool success, bytes memory returndata) = address(token).call(data);
        return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && address(token).code.length > 0;
    }
}

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

pragma solidity ^0.8.20;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev The ETH balance of the account is not enough to perform the operation.
     */
    error AddressInsufficientBalance(address account);

    /**
     * @dev There's no code at `target` (it is not a contract).
     */
    error AddressEmptyCode(address target);

    /**
     * @dev A call to an address target failed. The target may have reverted.
     */
    error FailedInnerCall();

    /**
     * @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://consensys.net/diligence/blog/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.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        if (address(this).balance < amount) {
            revert AddressInsufficientBalance(address(this));
        }

        (bool success, ) = recipient.call{value: amount}("");
        if (!success) {
            revert FailedInnerCall();
        }
    }

    /**
     * @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 or custom error, it is bubbled
     * up by this function (like regular Solidity function calls). However, if
     * the call reverted with no returned reason, this function reverts with a
     * {FailedInnerCall} error.
     *
     * 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.
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0);
    }

    /**
     * @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`.
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
        if (address(this).balance < value) {
            revert AddressInsufficientBalance(address(this));
        }
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
     * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an
     * unsuccessful call.
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata
    ) internal view returns (bytes memory) {
        if (!success) {
            _revert(returndata);
        } else {
            // only check if target is a contract if the call was successful and the return data is empty
            // otherwise we already know that it was a contract
            if (returndata.length == 0 && target.code.length == 0) {
                revert AddressEmptyCode(target);
            }
            return returndata;
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
     * revert reason or with a default {FailedInnerCall} error.
     */
    function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
        if (!success) {
            _revert(returndata);
        } else {
            return returndata;
        }
    }

    /**
     * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.
     */
    function _revert(bytes memory returndata) private pure {
        // 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 FailedInnerCall();
        }
    }
}

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

import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
// internal
import "../../interfaces/ISportsAMMV2Manager.sol";
import "../../interfaces/ISportsAMMV2.sol";

contract Ticket {
    using SafeERC20 for IERC20;
    uint private constant ONE = 1e18;

    enum Phase {
        Trading,
        Maturity,
        Expiry
    }

    struct MarketData {
        bytes32 gameId;
        uint16 sportId;
        uint16 typeId;
        uint maturity;
        uint8 status;
        int24 line;
        uint24 playerId;
        uint8 position;
        uint odd;
        ISportsAMMV2.CombinedPosition[] combinedPositions;
    }

    struct TicketInit {
        MarketData[] _markets;
        uint _buyInAmount;
        uint _fees;
        uint _totalQuote;
        address _sportsAMM;
        address _ticketOwner;
        IERC20 _collateral;
        uint _expiry;
        bool _isLive;
    }

    ISportsAMMV2 public sportsAMM;
    address public ticketOwner;
    IERC20 public collateral;

    uint public buyInAmount;
    uint public fees;
    uint public totalQuote;
    uint public numOfMarkets;
    uint public expiry;
    uint public createdAt;

    bool public resolved;
    bool public paused;
    bool public initialized;
    bool public cancelled;

    bool public isLive;

    mapping(uint => MarketData) public markets;

    uint public finalPayout;

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

    /// @notice initialize the ticket contract
    /// @param params all parameters for Init
    function initialize(TicketInit calldata params) external {
        require(!initialized, "Ticket already initialized");
        initialized = true;
        sportsAMM = ISportsAMMV2(params._sportsAMM);
        numOfMarkets = params._markets.length;
        for (uint i = 0; i < numOfMarkets; i++) {
            markets[i] = params._markets[i];
        }
        buyInAmount = params._buyInAmount;
        fees = params._fees;
        totalQuote = params._totalQuote;
        ticketOwner = params._ticketOwner;
        collateral = params._collateral;
        expiry = params._expiry;
        isLive = params._isLive;
        createdAt = block.timestamp;
    }

    /* ========== EXTERNAL READ FUNCTIONS ========== */

    /// @notice checks if the user lost the ticket
    /// @return isTicketLost true/false
    function isTicketLost() public view returns (bool) {
        for (uint i = 0; i < numOfMarkets; i++) {
            bool isMarketResolved = sportsAMM.resultManager().isMarketResolved(
                markets[i].gameId,
                markets[i].typeId,
                markets[i].playerId,
                markets[i].line,
                markets[i].combinedPositions
            );
            bool isWinningMarketPosition = sportsAMM.resultManager().isWinningMarketPosition(
                markets[i].gameId,
                markets[i].typeId,
                markets[i].playerId,
                markets[i].line,
                markets[i].position,
                markets[i].combinedPositions
            );
            if (isMarketResolved && !isWinningMarketPosition) {
                return true;
            }
        }
        return false;
    }

    /// @notice checks are all markets of the ticket resolved
    /// @return areAllMarketsResolved true/false
    function areAllMarketsResolved() public view returns (bool) {
        for (uint i = 0; i < numOfMarkets; i++) {
            if (
                !sportsAMM.resultManager().isMarketResolved(
                    markets[i].gameId,
                    markets[i].typeId,
                    markets[i].playerId,
                    markets[i].line,
                    markets[i].combinedPositions
                )
            ) {
                return false;
            }
        }
        return true;
    }

    /// @notice checks if the user won the ticket
    /// @return hasUserWon true/false
    function isUserTheWinner() external view returns (bool hasUserWon) {
        hasUserWon = _isUserTheWinner();
    }

    /// @notice checks if the ticket ready to be exercised
    /// @return isExercisable true/false
    function isTicketExercisable() public view returns (bool isExercisable) {
        isExercisable = !resolved && (areAllMarketsResolved() || isTicketLost());
    }

    /// @notice gets current phase of the ticket
    /// @return phase ticket phase
    function phase() public view returns (Phase) {
        return
            isTicketExercisable() || resolved ? ((expiry < block.timestamp) ? Phase.Expiry : Phase.Maturity) : Phase.Trading;
    }

    /// @notice gets combined positions of the game
    /// @return combinedPositions game combined positions
    function getCombinedPositions(
        uint _marketIndex
    ) public view returns (ISportsAMMV2.CombinedPosition[] memory combinedPositions) {
        return markets[_marketIndex].combinedPositions;
    }

    /* ========== EXTERNAL WRITE FUNCTIONS ========== */

    /// @notice exercise ticket
    function exercise(address _exerciseCollateral) external onlyAMM returns (uint) {
        require(!paused, "Market paused");
        bool isExercisable = isTicketExercisable();
        require(isExercisable, "Ticket not exercisable yet");

        uint payoutWithFees = collateral.balanceOf(address(this));
        uint payout = payoutWithFees - fees;
        bool isCancelled = false;

        if (_isUserTheWinner()) {
            finalPayout = payout;
            isCancelled = true;
            for (uint i = 0; i < numOfMarkets; i++) {
                bool isCancelledMarketPosition = sportsAMM.resultManager().isCancelledMarketPosition(
                    markets[i].gameId,
                    markets[i].typeId,
                    markets[i].playerId,
                    markets[i].line,
                    markets[i].position,
                    markets[i].combinedPositions
                );
                if (isCancelledMarketPosition) {
                    finalPayout = (finalPayout * markets[i].odd) / ONE;
                } else {
                    isCancelled = false;
                }
            }
            if (isCancelled) {
                finalPayout = buyInAmount;
            }
            collateral.safeTransfer(
                _exerciseCollateral == address(0) || _exerciseCollateral == address(collateral)
                    ? address(ticketOwner)
                    : address(sportsAMM),
                finalPayout
            );
        }

        // if user is lost or if the user payout was less than anticipated due to cancelled games, send the remainder to AMM
        uint balance = collateral.balanceOf(address(this));
        if (balance != 0) {
            collateral.safeTransfer(address(sportsAMM), balance);
        }

        _resolve(!isTicketLost(), isCancelled);
        return finalPayout;
    }

    /// @notice expire ticket
    function expire(address _beneficiary) external onlyAMM {
        require(phase() == Phase.Expiry, "Ticket not in expiry phase");
        require(!resolved, "Can't expire resolved ticket");
        emit Expired(_beneficiary);
        _selfDestruct(_beneficiary);
    }

    /// @notice cancel the ticket
    function cancel() external onlyAMM returns (uint) {
        require(!paused, "Market paused");

        finalPayout = buyInAmount;
        collateral.safeTransfer(address(ticketOwner), finalPayout);

        uint balance = collateral.balanceOf(address(this));
        if (balance != 0) {
            collateral.safeTransfer(address(sportsAMM), balance);
        }

        _resolve(true, true);
        return finalPayout;
    }

    /// @notice withdraw collateral from the ticket
    function withdrawCollateral(address recipient) external onlyAMM {
        collateral.safeTransfer(recipient, collateral.balanceOf(address(this)));
    }

    /* ========== INTERNAL FUNCTIONS ========== */

    function _resolve(bool _hasUserWon, bool _cancelled) internal {
        resolved = true;
        cancelled = _cancelled;
        emit Resolved(_hasUserWon, _cancelled);
    }

    function _selfDestruct(address beneficiary) internal {
        uint balance = collateral.balanceOf(address(this));
        if (balance != 0) {
            collateral.safeTransfer(beneficiary, balance);
        }
    }

    function _isUserTheWinner() internal view returns (bool hasUserWon) {
        if (areAllMarketsResolved()) {
            hasUserWon = !isTicketLost();
        }
    }

    /* ========== SETTERS ========== */

    function setPaused(bool _paused) external {
        require(msg.sender == address(sportsAMM.manager()), "Invalid sender");
        if (paused == _paused) return;
        paused = _paused;
        emit PauseUpdated(_paused);
    }

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

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

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

    event Resolved(bool isUserTheWinner, bool cancelled);
    event Expired(address beneficiary);
    event PauseUpdated(bool paused);
}

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

import "./IProxyBetting.sol";

interface IFreeBetsHolder is IProxyBetting {
    function confirmLiveTrade(bytes32 requestId, address _createdTicket, uint _buyInAmount, address _collateral) external;
}

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

interface IProxyBetting {
    function getActiveTicketsPerUser(uint _index, uint _pageSize, address _user) external view returns (address[] memory);
    function numOfActiveTicketsPerUser(address _user) external view returns (uint);
    function getResolvedTicketsPerUser(uint _index, uint _pageSize, address _user) external view returns (address[] memory);
    function numOfResolvedTicketsPerUser(address _user) external view returns (uint);

    function confirmTicketResolved(address _resolvedTicket) external;
}

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

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "../interfaces/ISportsAMMV2Manager.sol";
import "../interfaces/ISportsAMMV2ResultManager.sol";
import "../interfaces/ISportsAMMV2RiskManager.sol";
import "../interfaces/ISportsAMMV2Manager.sol";
import "../interfaces/IFreeBetsHolder.sol";
import "../interfaces/IStakingThalesBettingProxy.sol";

interface ISportsAMMV2 {
    struct CombinedPosition {
        uint16 typeId;
        uint8 position;
        int24 line;
    }

    struct TradeData {
        bytes32 gameId;
        uint16 sportId;
        uint16 typeId;
        uint maturity;
        uint8 status;
        int24 line;
        uint24 playerId;
        uint[] odds;
        bytes32[] merkleProof;
        uint8 position;
        CombinedPosition[][] combinedPositions;
    }

    function defaultCollateral() external view returns (IERC20);

    function manager() external view returns (ISportsAMMV2Manager);

    function resultManager() external view returns (ISportsAMMV2ResultManager);

    function safeBoxFee() external view returns (uint);

    function exerciseTicket(address _ticket) external;

    function riskManager() external view returns (ISportsAMMV2RiskManager);

    function freeBetsHolder() external view returns (IFreeBetsHolder);

    function stakingThalesBettingProxy() external view returns (IStakingThalesBettingProxy);

    function tradeLive(
        TradeData[] calldata _tradeData,
        uint _buyInAmount,
        uint _expectedQuote,
        address _recipient,
        address _referrer,
        address _collateral
    ) external returns (address _createdTicket);

    function trade(
        TradeData[] calldata _tradeData,
        uint _buyInAmount,
        uint _expectedQuote,
        uint _additionalSlippage,
        address _referrer,
        address _collateral,
        bool _isEth
    ) external returns (address _createdTicket);

    function rootPerGame(bytes32 game) external view returns (bytes32);

    function paused() external view returns (bool);
}

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

import "./ISportsAMMV2.sol";

interface ISportsAMMV2Data {
    struct MarketData {
        bytes32 gameId;
        uint16 sportId;
        uint16 typeId;
        uint maturity;
        int24 line;
        uint24 playerId;
        uint8 position;
        uint odd;
        ISportsAMMV2.CombinedPosition[] combinedPositions;
    }

    struct MarketResult {
        ISportsAMMV2ResultManager.MarketPositionStatus status;
        int24[] results;
    }

    struct TicketData {
        address id;
        MarketData[] marketsData;
        MarketResult[] marketsResult;
        address collateral;
        address ticketOwner;
        uint buyInAmount;
        uint fees;
        uint totalQuote;
        uint numOfMarkets;
        uint expiry;
        uint createdAt;
        bool resolved;
        bool paused;
        bool cancelled;
        bool isLost;
        bool isUserTheWinner;
        bool isExercisable;
        uint finalPayout;
        bool isLive;
    }

    function getTicketsDataPerGame(
        bytes32 gameId,
        uint _startIndex,
        uint _pageSize
    ) external view returns (TicketData[] memory);
}

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

import "./ISportsAMMV2.sol";

interface ISportsAMMV2Manager {
    enum Role {
        ROOT_SETTING,
        RISK_MANAGING,
        MARKET_RESOLVING,
        TICKET_PAUSER
    }

    function isWhitelistedAddress(address _address, Role role) external view returns (bool);

    function decimals() external view returns (uint);

    function feeToken() external view returns (address);

    function isActiveTicket(address _ticket) external view returns (bool);

    function getActiveTickets(uint _index, uint _pageSize) external view returns (address[] memory);

    function numOfActiveTickets() external view returns (uint);

    function getActiveTicketsPerUser(uint _index, uint _pageSize, address _user) external view returns (address[] memory);

    function numOfActiveTicketsPerUser(address _user) external view returns (uint);

    function getResolvedTicketsPerUser(uint _index, uint _pageSize, address _user) external view returns (address[] memory);

    function numOfResolvedTicketsPerUser(address _user) external view returns (uint);

    function getTicketsPerGame(uint _index, uint _pageSize, bytes32 _gameId) external view returns (address[] memory);

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

    function isKnownTicket(address _ticket) external view returns (bool);

    function addNewKnownTicket(ISportsAMMV2.TradeData[] memory _tradeData, address ticket, address user) external;

    function resolveKnownTicket(address ticket, address ticketOwner) external;
}

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

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "./ISportsAMMV2.sol";

interface ISportsAMMV2ResultManager {
    enum MarketPositionStatus {
        Open,
        Cancelled,
        Winning,
        Losing
    }

    function isMarketResolved(
        bytes32 _gameId,
        uint16 _typeId,
        uint24 _playerId,
        int24 _line,
        ISportsAMMV2.CombinedPosition[] memory combinedPositions
    ) external view returns (bool isResolved);

    function getMarketPositionStatus(
        bytes32 _gameId,
        uint16 _typeId,
        uint24 _playerId,
        int24 _line,
        uint _position,
        ISportsAMMV2.CombinedPosition[] memory _combinedPositions
    ) external view returns (MarketPositionStatus status);

    function isWinningMarketPosition(
        bytes32 _gameId,
        uint16 _typeId,
        uint24 _playerId,
        int24 _line,
        uint _position,
        ISportsAMMV2.CombinedPosition[] memory _combinedPositions
    ) external view returns (bool isWinning);

    function isCancelledMarketPosition(
        bytes32 _gameId,
        uint16 _typeId,
        uint24 _playerId,
        int24 _line,
        uint _position,
        ISportsAMMV2.CombinedPosition[] memory _combinedPositions
    ) external view returns (bool isCancelled);

    function getResultsPerMarket(
        bytes32 _gameId,
        uint16 _typeId,
        uint24 _playerId
    ) external view returns (int24[] memory results);

    function resultTypePerMarketType(uint _typeId) external view returns (uint8 marketType);

    function setResultsPerMarkets(
        bytes32[] memory _gameIds,
        uint16[] memory _typeIds,
        uint24[] memory _playerIds,
        int24[][] memory _results
    ) external;

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

    function cancelGames(bytes32[] memory _gameIds) external;

    function cancelMarkets(
        bytes32[] memory _gameIds,
        uint16[] memory _typeIds,
        uint24[] memory _playerIds,
        int24[] memory _lines
    ) external;

    function cancelMarket(bytes32 _gameId, uint16 _typeId, uint24 _playerId, int24 _line) external;

    function cancelGame(bytes32 _gameId) external;
}

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

import "./ISportsAMMV2.sol";

interface ISportsAMMV2RiskManager {
    struct TypeCap {
        uint typeId;
        uint cap;
    }

    struct CapData {
        uint capPerSport;
        uint capPerChild;
        TypeCap[] capPerType;
    }

    struct DynamicLiquidityData {
        uint cutoffTimePerSport;
        uint cutoffDividerPerSport;
    }

    struct RiskData {
        uint sportId;
        CapData capData;
        uint riskMultiplierPerSport;
        DynamicLiquidityData dynamicLiquidityData;
    }

    enum RiskStatus {
        NoRisk,
        OutOfLiquidity,
        InvalidCombination
    }

    function minBuyInAmount() external view returns (uint);

    function maxTicketSize() external view returns (uint);

    function maxSupportedAmount() external view returns (uint);

    function maxSupportedOdds() external view returns (uint);

    function expiryDuration() external view returns (uint);

    function liveTradingPerSportAndTypeEnabled(uint _sportId, uint _typeId) external view returns (bool _enabled);

    function calculateCapToBeUsed(
        bytes32 _gameId,
        uint16 _sportId,
        uint16 _typeId,
        uint24 _playerId,
        int24 _line,
        uint _maturity,
        bool _isLive
    ) external view returns (uint cap);

    function checkRisks(
        ISportsAMMV2.TradeData[] memory _tradeData,
        uint _buyInAmount,
        bool _isLive
    ) external view returns (ISportsAMMV2RiskManager.RiskStatus riskStatus, bool[] memory isMarketOutOfLiquidity);

    function checkLimits(
        uint _buyInAmount,
        uint _totalQuote,
        uint _payout,
        uint _expectedPayout,
        uint _additionalSlippage,
        uint _ticketSize
    ) external view;

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

    function checkAndUpdateRisks(ISportsAMMV2.TradeData[] memory _tradeData, uint _buyInAmount, bool _isLive) external;

    function verifyMerkleTree(ISportsAMMV2.TradeData memory _marketTradeData, bytes32 _rootPerGame) external pure;

    function isSportIdFuture(uint16 _sportsId) external view returns (bool);
}

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "./IProxyBetting.sol";

interface IStakingThalesBettingProxy is IProxyBetting {
    function preConfirmLiveTrade(bytes32 requestId, uint _buyInAmount) external;
    function confirmLiveTrade(bytes32 requestId, address _createdTicket, uint _buyInAmount) external;
}

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

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

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

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

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

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

    modifier onlyOwner() {
        _onlyOwner();
        _;
    }

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

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

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

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

// Clone of syntetix contract without constructor
contract ProxyPausable is ProxyOwned {
    uint public lastPauseTime;
    bool public paused;

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

        // Set our paused state.
        paused = _paused;

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

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

    event PauseChanged(bool isPaused);

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

File 18 of 18 : ProxyReentrancyGuard.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

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

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

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

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

Contract Security Audit

Contract ABI

API
[{"inputs":[],"name":"InvalidInitialization","type":"error"},{"inputs":[],"name":"NotInitializing","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32[]","name":"gameIds","type":"bytes32[]"},{"indexed":false,"internalType":"string","name":"reason","type":"string"}],"name":"GamesBlockedForResolution","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32[]","name":"gameIds","type":"bytes32[]"}],"name":"GamesUnblockedForResolution","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"version","type":"uint64"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldOwner","type":"address"},{"indexed":false,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnerChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnerNominated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"isPaused","type":"bool"}],"name":"PauseChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"manager","type":"address"}],"name":"SetManager","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"sportsAMMData","type":"address"}],"name":"SetSportsAMMData","type":"event"},{"inputs":[],"name":"acceptOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32[]","name":"_gameIds","type":"bytes32[]"},{"internalType":"string","name":"_reason","type":"string"}],"name":"blockGames","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"gameIdBlockReason","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"gameIdBlockedForResolution","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"gameIdUnblockedByAdmin","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32[]","name":"gameIds","type":"bytes32[]"}],"name":"getGamesBlockedForResolution","outputs":[{"internalType":"bool[]","name":"blockedGames","type":"bool[]"},{"internalType":"bool[]","name":"unblockedByAdmin","type":"bool[]"},{"internalType":"string[]","name":"blockReason","type":"string[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"initNonReentrant","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address","name":"_sportsAMMV2Data","type":"address"},{"internalType":"address","name":"_manager","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"}],"name":"isWhitelistedForUnblock","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastPauseTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"contract ISportsAMMV2Manager","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"nominateNewOwner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"nominatedOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_manager","type":"address"}],"name":"setManager","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"setOwner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_paused","type":"bool"}],"name":"setPaused","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_sportsAMMData","type":"address"}],"name":"setSportsAMMData","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"sportsAMMData","outputs":[{"internalType":"contract ISportsAMMV2Data","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"proxyAddress","type":"address"}],"name":"transferOwnershipAtInit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32[]","name":"_gameIds","type":"bytes32[]"}],"name":"unblockGames","outputs":[],"stateMutability":"nonpayable","type":"function"}]

608060405234801561001057600080fd5b50611995806100206000396000f3fe608060405234801561001057600080fd5b50600436106101425760003560e01c80638da5cb5b116100b8578063c0c53b8b1161007c578063c0c53b8b146102cd578063c3b83f5f146102e0578063d0ebdbe7146102f3578063ea85c60d14610306578063ebc7977214610319578063ed4e92421461032157600080fd5b80638da5cb5b1461025b5780638ea42a9c1461026e57806391b4ded91461028157806397e8908414610298578063a8d95de2146102ab57600080fd5b806343a0e2211161010a57806343a0e221146101cd578063481c6a75146101f057806353a47bb71461021b57806358a6315c1461022e5780635c975abb1461024657806379ba50971461025357600080fd5b806313af4035146101475780631627540c1461015c57806316c38b3c1461016f5780632fa898e914610182578063407fd7df146101aa575b600080fd5b61015a610155366004611366565b610341565b005b61015a61016a366004611366565b610477565b61015a61017d366004611396565b6104cd565b610195610190366004611366565b61053f565b60405190151581526020015b60405180910390f35b6101956101b83660046113b3565b60096020526000908152604090205460ff1681565b6101956101db3660046113b3565b60076020526000908152604090205460ff1681565b600654610203906001600160a01b031681565b6040516001600160a01b0390911681526020016101a1565b600154610203906001600160a01b031681565b6005546102039061010090046001600160a01b031681565b6003546101959060ff1681565b61015a61064b565b600054610203906001600160a01b031681565b61015a61027c366004611366565b610735565b61028a60025481565b6040519081526020016101a1565b61015a6102a6366004611493565b6107b9565b6102be6102b9366004611493565b610942565b6040516101a193929190611553565b61015a6102db3660046115da565b610bd8565b61015a6102ee366004611366565b610d31565b61015a610301366004611366565b610e18565b61015a61031436600461161d565b610e94565b61015a61101c565b61033461032f3660046113b3565b61107a565b6040516101a191906116d4565b6001600160a01b03811661039c5760405162461bcd60e51b815260206004820152601960248201527f4f776e657220616464726573732063616e6e6f7420626520300000000000000060448201526064015b60405180910390fd5b600154600160a01b900460ff16156104085760405162461bcd60e51b815260206004820152602960248201527f416c726561647920696e697469616c697a65642c20757365206e6f6d696e617460448201526832a732bba7bbb732b960b91b6064820152608401610393565b6001805460ff60a01b1916600160a01b179055600080546001600160a01b0383166001600160a01b0319909116811782556040805192835260208301919091527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c91015b60405180910390a150565b61047f611114565b600180546001600160a01b0319166001600160a01b0383169081179091556040519081527f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce229060200161046c565b6104d5611114565b60035460ff1615158115151461053c576003805460ff191682151590811790915560ff161561050357426002555b60035460405160ff909116151581527f8fb6c181ee25a520cf3dd6565006ef91229fcfe5a989566c2a3b8c115570cec59060200161046c565b50565b600080546001600160a01b03838116911614806105cb575060065460405163e760c39560e01b81526001600160a01b039091169063e760c3959061058a9085906003906004016116e7565b602060405180830381865afa1580156105a7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105cb9190611722565b80610645575060065460405163e760c39560e01b81526001600160a01b039091169063e760c395906106049085906002906004016116e7565b602060405180830381865afa158015610621573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106459190611722565b92915050565b6001546001600160a01b031633146106c35760405162461bcd60e51b815260206004820152603560248201527f596f75206d757374206265206e6f6d696e61746564206265666f726520796f7560448201527402063616e20616363657074206f776e65727368697605c1b6064820152608401610393565b600054600154604080516001600160a01b0393841681529290911660208301527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c910160405180910390a160018054600080546001600160a01b03199081166001600160a01b03841617909155169055565b61073d611114565b6001600160a01b0381166107635760405162461bcd60e51b81526004016103939061173f565b60058054610100600160a81b0319166101006001600160a01b038416908102919091179091556040519081527f54c5c53c287ea64170cc62cb879092dac85feb8dc55d855180328703788b6f559060200161046c565b6000546001600160a01b0316331480610841575060065460405163e760c39560e01b81526001600160a01b039091169063e760c395906108009033906003906004016116e7565b602060405180830381865afa15801561081d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108419190611722565b806108bb575060065460405163e760c39560e01b81526001600160a01b039091169063e760c3959061087a9033906002906004016116e7565b602060405180830381865afa158015610897573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108bb9190611722565b6108f85760405162461bcd60e51b815260206004820152600e60248201526d24b73b30b634b21039b2b73232b960911b6044820152606401610393565b61091381604051806020016040528060008152506000611188565b7f80b995603e506a1ba59eaba8ca8494a66734d7e837e3d1a5c0cd630df2bdb13c8160405161046c9190611798565b6060806060835167ffffffffffffffff811115610961576109616113cc565b60405190808252806020026020018201604052801561098a578160200160208202803683370190505b509250835167ffffffffffffffff8111156109a7576109a76113cc565b6040519080825280602002602001820160405280156109d0578160200160208202803683370190505b509150835167ffffffffffffffff8111156109ed576109ed6113cc565b604051908082528060200260200182016040528015610a2057816020015b6060815260200190600190039081610a0b5790505b50905060005b8451811015610bd05760076000868381518110610a4557610a456117ab565b6020026020010151815260200190815260200160002060009054906101000a900460ff16848281518110610a7b57610a7b6117ab565b60200260200101901515908115158152505060096000868381518110610aa357610aa36117ab565b6020026020010151815260200190815260200160002060009054906101000a900460ff16838281518110610ad957610ad96117ab565b60200260200101901515908115158152505060086000868381518110610b0157610b016117ab565b602002602001015181526020019081526020016000208054610b22906117c1565b80601f0160208091040260200160405190810160405280929190818152602001828054610b4e906117c1565b8015610b9b5780601f10610b7057610100808354040283529160200191610b9b565b820191906000526020600020905b815481529060010190602001808311610b7e57829003601f168201915b5050505050828281518110610bb257610bb26117ab565b60200260200101819052508080610bc8906117fb565b915050610a26565b509193909250565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a008054600160401b810460ff16159067ffffffffffffffff16600081158015610c1e5750825b905060008267ffffffffffffffff166001148015610c3b5750303b155b905081158015610c49575080155b15610c675760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff191660011785558315610c9157845460ff60401b1916600160401b1785555b610c9a88610341565b610ca261101c565b60058054610100600160a81b0319166101006001600160a01b038a81169190910291909117909155600680546001600160a01b0319169188169190911790558315610d2757845460ff60401b19168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b5050505050505050565b610d39611114565b6001600160a01b038116610d5f5760405162461bcd60e51b81526004016103939061173f565b600154600160a81b900460ff1615610daf5760405162461bcd60e51b8152602060048201526013602482015272105b1c9958591e481d1c985b9cd9995c9c9959606a1b6044820152606401610393565b600080546001600160a01b0383166001600160a01b031990911681179091556001805460ff60a81b1916600160a81b1790556040805182815260208101929092527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c910161046c565b610e20611114565b6001600160a01b038116610e465760405162461bcd60e51b81526004016103939061173f565b600680546001600160a01b0319166001600160a01b0383169081179091556040519081527f54a6385aa0292b04e1ef8513253c17d1863f7cdfc87029d77fd55cc4c2e717e29060200161046c565b6000546001600160a01b0316331480610f1c575060065460405163e760c39560e01b81526001600160a01b039091169063e760c39590610edb9033906003906004016116e7565b602060405180830381865afa158015610ef8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f1c9190611722565b80610f96575060065460405163e760c39560e01b81526001600160a01b039091169063e760c39590610f559033906002906004016116e7565b602060405180830381865afa158015610f72573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f969190611722565b610fd35760405162461bcd60e51b815260206004820152600e60248201526d24b73b30b634b21039b2b73232b960911b6044820152606401610393565b610fdf82826001611188565b7f4f7d99ccb93e80df2cdae8633c37ba04373f08483d7a1713551738b7978701ac8282604051611010929190611822565b60405180910390a15050565b60055460ff16156110655760405162461bcd60e51b8152602060048201526013602482015272105b1c9958591e481a5b9a5d1a585b1a5e9959606a1b6044820152606401610393565b6005805460ff19166001908117909155600455565b60086020526000908152604090208054611093906117c1565b80601f01602080910402602001604051908101604052809291908181526020018280546110bf906117c1565b801561110c5780601f106110e15761010080835404028352916020019161110c565b820191906000526020600020905b8154815290600101906020018083116110ef57829003601f168201915b505050505081565b6000546001600160a01b031633146111865760405162461bcd60e51b815260206004820152602f60248201527f4f6e6c792074686520636f6e7472616374206f776e6572206d6179207065726660448201526e37b936903a3434b99030b1ba34b7b760891b6064820152608401610393565b565b60005b835181101561134457811580156111d25750600760008583815181106111b3576111b36117ab565b60209081029190910181015182528101919091526040016000205460ff165b15611221576001600960008684815181106111ef576111ef6117ab565b6020026020010151815260200190815260200160002060006101000a81548160ff0219169083151502179055506112a9565b81801561125e57506009600085838151811061123f5761123f6117ab565b60209081029190910181015182528101919091526040016000205460ff165b156112a95760006009600086848151811061127b5761127b6117ab565b6020026020010151815260200190815260200160002060006101000a81548160ff0219169083151502179055505b81600760008684815181106112c0576112c06117ab565b6020026020010151815260200190815260200160002060006101000a81548160ff02191690831515021790555060008351111561133257826008600086848151811061130e5761130e6117ab565b602002602001015181526020019081526020016000209081611330919061189f565b505b8061133c816117fb565b91505061118b565b50505050565b80356001600160a01b038116811461136157600080fd5b919050565b60006020828403121561137857600080fd5b6113818261134a565b9392505050565b801515811461053c57600080fd5b6000602082840312156113a857600080fd5b813561138181611388565b6000602082840312156113c557600080fd5b5035919050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff8111828210171561140b5761140b6113cc565b604052919050565b600082601f83011261142457600080fd5b8135602067ffffffffffffffff821115611440576114406113cc565b8160051b61144f8282016113e2565b928352848101820192828101908785111561146957600080fd5b83870192505b848310156114885782358252918301919083019061146f565b979650505050505050565b6000602082840312156114a557600080fd5b813567ffffffffffffffff8111156114bc57600080fd5b6114c884828501611413565b949350505050565b600081518084526020808501945080840160005b838110156115025781511515875295820195908201906001016114e4565b509495945050505050565b6000815180845260005b8181101561153357602081850181015186830182015201611517565b506000602082860101526020601f19601f83011685010191505092915050565b60608152600061156660608301866114d0565b60208382038185015261157982876114d0565b915083820360408501528185518084528284019150828160051b85010183880160005b838110156115ca57601f198784030185526115b883835161150d565b9486019492509085019060010161159c565b50909a9950505050505050505050565b6000806000606084860312156115ef57600080fd5b6115f88461134a565b92506116066020850161134a565b91506116146040850161134a565b90509250925092565b6000806040838503121561163057600080fd5b823567ffffffffffffffff8082111561164857600080fd5b61165486838701611413565b935060209150818501358181111561166b57600080fd5b8501601f8101871361167c57600080fd5b80358281111561168e5761168e6113cc565b6116a0601f8201601f191685016113e2565b925080835287848284010111156116b657600080fd5b80848301858501376000848285010152505080925050509250929050565b602081526000611381602083018461150d565b6001600160a01b0383168152604081016004831061171557634e487b7160e01b600052602160045260246000fd5b8260208301529392505050565b60006020828403121561173457600080fd5b815161138181611388565b6020808252600f908201526e496e76616c6964206164647265737360881b604082015260600190565b600081518084526020808501945080840160005b838110156115025781518752958201959082019060010161177c565b6020815260006113816020830184611768565b634e487b7160e01b600052603260045260246000fd5b600181811c908216806117d557607f821691505b6020821081036117f557634e487b7160e01b600052602260045260246000fd5b50919050565b60006001820161181b57634e487b7160e01b600052601160045260246000fd5b5060010190565b6040815260006118356040830185611768565b8281036020840152611847818561150d565b95945050505050565b601f82111561189a57600081815260208120601f850160051c810160208610156118775750805b601f850160051c820191505b8181101561189657828155600101611883565b5050505b505050565b815167ffffffffffffffff8111156118b9576118b96113cc565b6118cd816118c784546117c1565b84611850565b602080601f83116001811461190257600084156118ea5750858301515b600019600386901b1c1916600185901b178555611896565b600085815260208120601f198616915b8281101561193157888601518255948401946001909101908401611912565b508582101561194f5787850151600019600388901b60f8161c191681555b5050505050600190811b0190555056fea2646970667358221220646c639571b27a38e01f43f65714d3f819f5616bfd2b77eca0d489f8b35be00564736f6c63430008140033

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106101425760003560e01c80638da5cb5b116100b8578063c0c53b8b1161007c578063c0c53b8b146102cd578063c3b83f5f146102e0578063d0ebdbe7146102f3578063ea85c60d14610306578063ebc7977214610319578063ed4e92421461032157600080fd5b80638da5cb5b1461025b5780638ea42a9c1461026e57806391b4ded91461028157806397e8908414610298578063a8d95de2146102ab57600080fd5b806343a0e2211161010a57806343a0e221146101cd578063481c6a75146101f057806353a47bb71461021b57806358a6315c1461022e5780635c975abb1461024657806379ba50971461025357600080fd5b806313af4035146101475780631627540c1461015c57806316c38b3c1461016f5780632fa898e914610182578063407fd7df146101aa575b600080fd5b61015a610155366004611366565b610341565b005b61015a61016a366004611366565b610477565b61015a61017d366004611396565b6104cd565b610195610190366004611366565b61053f565b60405190151581526020015b60405180910390f35b6101956101b83660046113b3565b60096020526000908152604090205460ff1681565b6101956101db3660046113b3565b60076020526000908152604090205460ff1681565b600654610203906001600160a01b031681565b6040516001600160a01b0390911681526020016101a1565b600154610203906001600160a01b031681565b6005546102039061010090046001600160a01b031681565b6003546101959060ff1681565b61015a61064b565b600054610203906001600160a01b031681565b61015a61027c366004611366565b610735565b61028a60025481565b6040519081526020016101a1565b61015a6102a6366004611493565b6107b9565b6102be6102b9366004611493565b610942565b6040516101a193929190611553565b61015a6102db3660046115da565b610bd8565b61015a6102ee366004611366565b610d31565b61015a610301366004611366565b610e18565b61015a61031436600461161d565b610e94565b61015a61101c565b61033461032f3660046113b3565b61107a565b6040516101a191906116d4565b6001600160a01b03811661039c5760405162461bcd60e51b815260206004820152601960248201527f4f776e657220616464726573732063616e6e6f7420626520300000000000000060448201526064015b60405180910390fd5b600154600160a01b900460ff16156104085760405162461bcd60e51b815260206004820152602960248201527f416c726561647920696e697469616c697a65642c20757365206e6f6d696e617460448201526832a732bba7bbb732b960b91b6064820152608401610393565b6001805460ff60a01b1916600160a01b179055600080546001600160a01b0383166001600160a01b0319909116811782556040805192835260208301919091527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c91015b60405180910390a150565b61047f611114565b600180546001600160a01b0319166001600160a01b0383169081179091556040519081527f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce229060200161046c565b6104d5611114565b60035460ff1615158115151461053c576003805460ff191682151590811790915560ff161561050357426002555b60035460405160ff909116151581527f8fb6c181ee25a520cf3dd6565006ef91229fcfe5a989566c2a3b8c115570cec59060200161046c565b50565b600080546001600160a01b03838116911614806105cb575060065460405163e760c39560e01b81526001600160a01b039091169063e760c3959061058a9085906003906004016116e7565b602060405180830381865afa1580156105a7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105cb9190611722565b80610645575060065460405163e760c39560e01b81526001600160a01b039091169063e760c395906106049085906002906004016116e7565b602060405180830381865afa158015610621573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106459190611722565b92915050565b6001546001600160a01b031633146106c35760405162461bcd60e51b815260206004820152603560248201527f596f75206d757374206265206e6f6d696e61746564206265666f726520796f7560448201527402063616e20616363657074206f776e65727368697605c1b6064820152608401610393565b600054600154604080516001600160a01b0393841681529290911660208301527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c910160405180910390a160018054600080546001600160a01b03199081166001600160a01b03841617909155169055565b61073d611114565b6001600160a01b0381166107635760405162461bcd60e51b81526004016103939061173f565b60058054610100600160a81b0319166101006001600160a01b038416908102919091179091556040519081527f54c5c53c287ea64170cc62cb879092dac85feb8dc55d855180328703788b6f559060200161046c565b6000546001600160a01b0316331480610841575060065460405163e760c39560e01b81526001600160a01b039091169063e760c395906108009033906003906004016116e7565b602060405180830381865afa15801561081d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108419190611722565b806108bb575060065460405163e760c39560e01b81526001600160a01b039091169063e760c3959061087a9033906002906004016116e7565b602060405180830381865afa158015610897573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108bb9190611722565b6108f85760405162461bcd60e51b815260206004820152600e60248201526d24b73b30b634b21039b2b73232b960911b6044820152606401610393565b61091381604051806020016040528060008152506000611188565b7f80b995603e506a1ba59eaba8ca8494a66734d7e837e3d1a5c0cd630df2bdb13c8160405161046c9190611798565b6060806060835167ffffffffffffffff811115610961576109616113cc565b60405190808252806020026020018201604052801561098a578160200160208202803683370190505b509250835167ffffffffffffffff8111156109a7576109a76113cc565b6040519080825280602002602001820160405280156109d0578160200160208202803683370190505b509150835167ffffffffffffffff8111156109ed576109ed6113cc565b604051908082528060200260200182016040528015610a2057816020015b6060815260200190600190039081610a0b5790505b50905060005b8451811015610bd05760076000868381518110610a4557610a456117ab565b6020026020010151815260200190815260200160002060009054906101000a900460ff16848281518110610a7b57610a7b6117ab565b60200260200101901515908115158152505060096000868381518110610aa357610aa36117ab565b6020026020010151815260200190815260200160002060009054906101000a900460ff16838281518110610ad957610ad96117ab565b60200260200101901515908115158152505060086000868381518110610b0157610b016117ab565b602002602001015181526020019081526020016000208054610b22906117c1565b80601f0160208091040260200160405190810160405280929190818152602001828054610b4e906117c1565b8015610b9b5780601f10610b7057610100808354040283529160200191610b9b565b820191906000526020600020905b815481529060010190602001808311610b7e57829003601f168201915b5050505050828281518110610bb257610bb26117ab565b60200260200101819052508080610bc8906117fb565b915050610a26565b509193909250565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a008054600160401b810460ff16159067ffffffffffffffff16600081158015610c1e5750825b905060008267ffffffffffffffff166001148015610c3b5750303b155b905081158015610c49575080155b15610c675760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff191660011785558315610c9157845460ff60401b1916600160401b1785555b610c9a88610341565b610ca261101c565b60058054610100600160a81b0319166101006001600160a01b038a81169190910291909117909155600680546001600160a01b0319169188169190911790558315610d2757845460ff60401b19168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b5050505050505050565b610d39611114565b6001600160a01b038116610d5f5760405162461bcd60e51b81526004016103939061173f565b600154600160a81b900460ff1615610daf5760405162461bcd60e51b8152602060048201526013602482015272105b1c9958591e481d1c985b9cd9995c9c9959606a1b6044820152606401610393565b600080546001600160a01b0383166001600160a01b031990911681179091556001805460ff60a81b1916600160a81b1790556040805182815260208101929092527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c910161046c565b610e20611114565b6001600160a01b038116610e465760405162461bcd60e51b81526004016103939061173f565b600680546001600160a01b0319166001600160a01b0383169081179091556040519081527f54a6385aa0292b04e1ef8513253c17d1863f7cdfc87029d77fd55cc4c2e717e29060200161046c565b6000546001600160a01b0316331480610f1c575060065460405163e760c39560e01b81526001600160a01b039091169063e760c39590610edb9033906003906004016116e7565b602060405180830381865afa158015610ef8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f1c9190611722565b80610f96575060065460405163e760c39560e01b81526001600160a01b039091169063e760c39590610f559033906002906004016116e7565b602060405180830381865afa158015610f72573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f969190611722565b610fd35760405162461bcd60e51b815260206004820152600e60248201526d24b73b30b634b21039b2b73232b960911b6044820152606401610393565b610fdf82826001611188565b7f4f7d99ccb93e80df2cdae8633c37ba04373f08483d7a1713551738b7978701ac8282604051611010929190611822565b60405180910390a15050565b60055460ff16156110655760405162461bcd60e51b8152602060048201526013602482015272105b1c9958591e481a5b9a5d1a585b1a5e9959606a1b6044820152606401610393565b6005805460ff19166001908117909155600455565b60086020526000908152604090208054611093906117c1565b80601f01602080910402602001604051908101604052809291908181526020018280546110bf906117c1565b801561110c5780601f106110e15761010080835404028352916020019161110c565b820191906000526020600020905b8154815290600101906020018083116110ef57829003601f168201915b505050505081565b6000546001600160a01b031633146111865760405162461bcd60e51b815260206004820152602f60248201527f4f6e6c792074686520636f6e7472616374206f776e6572206d6179207065726660448201526e37b936903a3434b99030b1ba34b7b760891b6064820152608401610393565b565b60005b835181101561134457811580156111d25750600760008583815181106111b3576111b36117ab565b60209081029190910181015182528101919091526040016000205460ff165b15611221576001600960008684815181106111ef576111ef6117ab565b6020026020010151815260200190815260200160002060006101000a81548160ff0219169083151502179055506112a9565b81801561125e57506009600085838151811061123f5761123f6117ab565b60209081029190910181015182528101919091526040016000205460ff165b156112a95760006009600086848151811061127b5761127b6117ab565b6020026020010151815260200190815260200160002060006101000a81548160ff0219169083151502179055505b81600760008684815181106112c0576112c06117ab565b6020026020010151815260200190815260200160002060006101000a81548160ff02191690831515021790555060008351111561133257826008600086848151811061130e5761130e6117ab565b602002602001015181526020019081526020016000209081611330919061189f565b505b8061133c816117fb565b91505061118b565b50505050565b80356001600160a01b038116811461136157600080fd5b919050565b60006020828403121561137857600080fd5b6113818261134a565b9392505050565b801515811461053c57600080fd5b6000602082840312156113a857600080fd5b813561138181611388565b6000602082840312156113c557600080fd5b5035919050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff8111828210171561140b5761140b6113cc565b604052919050565b600082601f83011261142457600080fd5b8135602067ffffffffffffffff821115611440576114406113cc565b8160051b61144f8282016113e2565b928352848101820192828101908785111561146957600080fd5b83870192505b848310156114885782358252918301919083019061146f565b979650505050505050565b6000602082840312156114a557600080fd5b813567ffffffffffffffff8111156114bc57600080fd5b6114c884828501611413565b949350505050565b600081518084526020808501945080840160005b838110156115025781511515875295820195908201906001016114e4565b509495945050505050565b6000815180845260005b8181101561153357602081850181015186830182015201611517565b506000602082860101526020601f19601f83011685010191505092915050565b60608152600061156660608301866114d0565b60208382038185015261157982876114d0565b915083820360408501528185518084528284019150828160051b85010183880160005b838110156115ca57601f198784030185526115b883835161150d565b9486019492509085019060010161159c565b50909a9950505050505050505050565b6000806000606084860312156115ef57600080fd5b6115f88461134a565b92506116066020850161134a565b91506116146040850161134a565b90509250925092565b6000806040838503121561163057600080fd5b823567ffffffffffffffff8082111561164857600080fd5b61165486838701611413565b935060209150818501358181111561166b57600080fd5b8501601f8101871361167c57600080fd5b80358281111561168e5761168e6113cc565b6116a0601f8201601f191685016113e2565b925080835287848284010111156116b657600080fd5b80848301858501376000848285010152505080925050509250929050565b602081526000611381602083018461150d565b6001600160a01b0383168152604081016004831061171557634e487b7160e01b600052602160045260246000fd5b8260208301529392505050565b60006020828403121561173457600080fd5b815161138181611388565b6020808252600f908201526e496e76616c6964206164647265737360881b604082015260600190565b600081518084526020808501945080840160005b838110156115025781518752958201959082019060010161177c565b6020815260006113816020830184611768565b634e487b7160e01b600052603260045260246000fd5b600181811c908216806117d557607f821691505b6020821081036117f557634e487b7160e01b600052602260045260246000fd5b50919050565b60006001820161181b57634e487b7160e01b600052601160045260246000fd5b5060010190565b6040815260006118356040830185611768565b8281036020840152611847818561150d565b95945050505050565b601f82111561189a57600081815260208120601f850160051c810160208610156118775750805b601f850160051c820191505b8181101561189657828155600101611883565b5050505b505050565b815167ffffffffffffffff8111156118b9576118b96113cc565b6118cd816118c784546117c1565b84611850565b602080601f83116001811461190257600084156118ea5750858301515b600019600386901b1c1916600185901b178555611896565b600085815260208120601f198616915b8281101561193157888601518255948401946001909101908401611912565b508582101561194f5787850151600019600388901b60f8161c191681555b5050505050600190811b0190555056fea2646970667358221220646c639571b27a38e01f43f65714d3f819f5616bfd2b77eca0d489f8b35be00564736f6c63430008140033

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading

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