POL Price: $0.400759 (-2.48%)
Gas: 45 GWei
 

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Transfer To Admi...423258052023-05-05 6:59:09499 days ago1683269949IN
0x7533d674...e61876891
0 POL0.0793782,000
Claim422985582023-05-04 14:24:16500 days ago1683210256IN
0x7533d674...e61876891
0 POL0.02651563260.1
Claim422495652023-05-03 8:55:00501 days ago1683104100IN
0x7533d674...e61876891
0 POL0.02004884206.8
Transfer To Admi...422461682023-05-03 6:50:46501 days ago1683096646IN
0x7533d674...e61876891
0 POL0.0793782,000
Claim422285242023-05-02 20:13:01501 days ago1683058381IN
0x7533d674...e61876891
0 POL0.0242273249.9
Claim422227702023-05-02 16:45:09501 days ago1683045909IN
0x7533d674...e61876891
0 POL0.02661222274.5
Transfer To Admi...420944852023-04-29 10:53:11505 days ago1682765591IN
0x7533d674...e61876891
0 POL0.0793542,000
Transfer To Admi...418243702023-04-22 11:47:11512 days ago1682164031IN
0x7533d674...e61876891
0 POL0.0793542,000
Claim418182312023-04-22 8:07:46512 days ago1682150866IN
0x7533d674...e61876891
0 POL0.02407984248.1
Transfer To Admi...417276232023-04-20 0:35:48514 days ago1681950948IN
0x7533d674...e61876891
0 POL0.0793542,000
Transfer To Admi...417032262023-04-19 8:15:08515 days ago1681892108IN
0x7533d674...e61876891
0 POL0.0793542,000
Transfer To Admi...416561012023-04-18 2:21:04516 days ago1681784464IN
0x7533d674...e61876891
0 POL0.0793782,000
Transfer To Admi...415433812023-04-15 2:08:27519 days ago1681524507IN
0x7533d674...e61876891
0 POL0.0793542,000
Refund Users415370732023-04-14 22:04:34519 days ago1681509874IN
0x7533d674...e61876891
0 POL0.01840671186.8
Transfer To Admi...414879612023-04-13 15:10:38520 days ago1681398638IN
0x7533d674...e61876891
0 POL0.0793542,000
Transfer To Admi...414820722023-04-13 11:21:34521 days ago1681384894IN
0x7533d674...e61876891
0 POL0.0793782,000
Claim414381132023-04-12 8:04:11522 days ago1681286651IN
0x7533d674...e61876891
0 POL0.0193041291.22439543
Claim414381062023-04-12 8:03:51522 days ago1681286631IN
0x7533d674...e61876891
0 POL0.02005313302.52442989
Refund Users414380962023-04-12 8:03:31522 days ago1681286611IN
0x7533d674...e61876891
0 POL0.01202193156.11893517
Claim414380942023-04-12 8:03:25522 days ago1681286605IN
0x7533d674...e61876891
0 POL0.02098052316.51519515
Claim414380772023-04-12 8:02:49522 days ago1681286569IN
0x7533d674...e61876891
0 POL0.03487837333.13637259
Refund Users414380752023-04-12 8:02:45522 days ago1681286565IN
0x7533d674...e61876891
0 POL0.00976926170.44274514
Claim414380712023-04-12 8:02:37522 days ago1681286557IN
0x7533d674...e61876891
0 POL0.03629946346.77591
Refund Users414380692023-04-12 8:02:33522 days ago1681286553IN
0x7533d674...e61876891
0 POL0.01369651177.86530806
Claim414380672023-04-12 8:02:29522 days ago1681286549IN
0x7533d674...e61876891
0 POL0.02349915354.51162044
View all transactions

Latest 25 internal transactions (View All)

Parent Transaction Hash Block From To
423258052023-05-05 6:59:09499 days ago1683269949
0x7533d674...e61876891
0.8791 POL
423029152023-05-04 16:58:36499 days ago1683219516
0x7533d674...e61876891
0.8791 POL
422985582023-05-04 14:24:16500 days ago1683210256
0x7533d674...e61876891
0.4875 POL
422495652023-05-03 8:55:00501 days ago1683104100
0x7533d674...e61876891
0.4875 POL
422461682023-05-03 6:50:46501 days ago1683096646
0x7533d674...e61876891
0.8388475 POL
422294262023-05-02 20:45:00501 days ago1683060300
0x7533d674...e61876891
0.79105 POL
422285242023-05-02 20:13:01501 days ago1683058381
0x7533d674...e61876891
0.65914875 POL
422239812023-05-02 17:29:19501 days ago1683048559
0x7533d674...e61876891
0.67605 POL
422227702023-05-02 16:45:09501 days ago1683045909
0x7533d674...e61876891
1.20495375 POL
422148212023-05-02 12:01:57502 days ago1683028917
0x7533d674...e61876891
1.23585 POL
420944852023-04-29 10:53:11505 days ago1682765591
0x7533d674...e61876891
0.0125 POL
420839132023-04-29 4:28:22505 days ago1682742502
0x7533d674...e61876891
0.5 POL
419090632023-04-24 17:12:35509 days ago1682356355
0x7533d674...e61876891
0.2746 POL
419090052023-04-24 17:10:31509 days ago1682356231
0x7533d674...e61876891
0.2746 POL
418243702023-04-22 11:47:11512 days ago1682164031
0x7533d674...e61876891
0.025 POL
418182312023-04-22 8:07:46512 days ago1682150866
0x7533d674...e61876891
0.975 POL
417858962023-04-21 12:28:07513 days ago1682080087
0x7533d674...e61876891
1 POL
417276232023-04-20 0:35:48514 days ago1681950948
0x7533d674...e61876891
0.025 POL
417225232023-04-19 21:33:20514 days ago1681940000
0x7533d674...e61876891
1 POL
417032262023-04-19 8:15:08515 days ago1681892108
0x7533d674...e61876891
0.4 POL
416944222023-04-19 2:43:09515 days ago1681872189
0x7533d674...e61876891
0.4 POL
416561012023-04-18 2:21:04516 days ago1681784464
0x7533d674...e61876891
0.11825 POL
416452492023-04-17 19:06:11516 days ago1681758371
0x7533d674...e61876891
0.11825 POL
415433812023-04-15 2:08:27519 days ago1681524507
0x7533d674...e61876891
0.0125 POL
415370732023-04-14 22:04:34519 days ago1681509874
0x7533d674...e61876891
0.4875 POL
View All Internal Transactions
Loading...
Loading

Similar Match Source Code
This contract matches the deployed Bytecode of the Source Code for Contract 0x9184f1fc...f66BDDE5D
The constructor portion of the code might be different and could alter the actual behaviour of the contract

Contract Name:
BhavishPrediction

Compiler Version
v0.8.13+commit.abaa5c0e

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 24 : BhavishPrediction.sol
// SPDX-License-Identifier: BSD-4-Clause

pragma solidity ^0.8.13;

import "@openzeppelin/contracts/security/Pausable.sol";
import "@openzeppelin/contracts/access/AccessControl.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/utils/Address.sol";
import ".././Interface/IBhavishAdministrator.sol";
import ".././Interface/IPriceManager.sol";
import ".././Interface/IBhavishPrediction.sol";
import "./BhavishPredictionStorage.sol";
import "./../Integrations/Swap/BhavishSwap.sol";
import "./../Integrations/Gasless/BaseRelayRecipient.sol";

/**
 * @title BhavishPrediction
 */
contract BhavishPrediction is IBhavishPrediction, AccessControl, Pausable, ReentrancyGuard {
    using Address for address;
    uint256 public currentRoundId;
    uint256 public roundTime; //10 mintues of round
    uint256 public roundzeroStartTimestamp;

    PredictionMarketStatus public marketStatus;

    uint256 public treasuryFee;
    uint256 public constant MAX_TREASURY_FEE = 100; // 10%
    uint256 public minPredictAmount; // minimum prediction amount (denominated in wei)
    uint256 public treasuryAmount; // funds in treasury collected from fee
    uint256 public decimals = 3;

    // State variables for storing the underlying and strike asset names -- Need to revisit this logic in later versions
    AssetPair public assetPair;

    IBhavishAdministrator public bhavishAdmin;
    IPriceManager public bhavishPriceManager;
    BhavishPredictionStorage public bhavishPredictionStorage;
    BhavishSwap public bhavishSwap;

    bytes32 public constant OPERATOR_ROLE = keccak256("OPERATOR_ROLE");
    bytes32 public constant MANAGER_ROLE = keccak256("MANAGER_ROLE");

    event PausedMarket(uint256 currentRoundId);
    event UnPausedMarket(uint256 currentRoundId);

    event CreateRound(uint256 indexed roundId);
    event StartRound(uint256 indexed roundId);
    event EndRound(uint256 indexed roundId);
    event CancelRound(uint256 indexed roundId);
    event PredictUp(address indexed sender, uint256 indexed roundId, uint256 amount);
    event PredictDown(address indexed sender, uint256 indexed roundId, uint256 amount);
    event RewardsCalculated(
        uint256 indexed roundId,
        uint256 rewardBaseCalAmount,
        uint256 rewardAmount,
        uint256 treasuryAmount
    );
    event Refund(uint256 indexed roundId, address indexed recipient, uint256 refundDispersed, uint256 timestamp);

    event NewMinPredictAmount(uint256 minPredictAmount);
    event NewTreasuryFee(uint256 treasuryFee);
    event NewOperator(address indexed operator);
    event NewAdmin(address indexed admin);
    event TransferToAdmin(address indexed bhavishAdmin, uint256 amount);
    event Claim(address indexed sender, uint256 indexed roundId, uint256 amount);

    /**
     * @notice Constructor
     * @param _minPredictAmount minimum bet amounts (in wei)
     * @param _treasuryFee treasury fee (1000 = 10%)
     * @param _bhavishAdmin Bhavish Administrator
     * @param _bhavishPriceManager Price Manager
     * @param _underlying Name of the underlying asset
     * @param _strike Name of the strike asset
     */
    constructor(
        uint256 _minPredictAmount,
        uint256 _treasuryFee,
        IBhavishAdministrator _bhavishAdmin,
        IPriceManager _bhavishPriceManager,
        BhavishPredictionStorage _bhavishPredictionStorage,
        uint256 _roundTime,
        bytes32 _underlying,
        bytes32 _strike
    ) {
        require(_minPredictAmount > 0, "Invalid Min Predict amount");
        require(_treasuryFee > 0 && _treasuryFee < MAX_TREASURY_FEE, "Treasury fee is too high");
        require(0 < _roundTime && _roundTime <= 86400, "Round Time should be between 1 sec to 3600 sec");

        minPredictAmount = _minPredictAmount;
        treasuryFee = _treasuryFee;
        bhavishAdmin = _bhavishAdmin;
        bhavishPriceManager = _bhavishPriceManager;
        bhavishPredictionStorage = _bhavishPredictionStorage;
        AssetPair memory pair = AssetPair(_underlying, _strike);
        assetPair = pair;
        roundTime = _roundTime;
        currentRoundId = bhavishPredictionStorage.latestRoundId();
        _setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
    }

    // Modifiers go here --------

    modifier onlyAdmin(address _address) {
        require(hasRole(DEFAULT_ADMIN_ROLE, _address), "Address not an admin");
        _;
    }

    modifier onlyOperator(address _address) {
        require(hasRole(OPERATOR_ROLE, _address), "Address not an operator");
        _;
    }

    // Roles granting goes here --------

    /**
     * @notice Set operator
     * @dev callable by Admin of the contract
     * @param _operator new operator address
     */
    function setOperator(address _operator) external onlyAdmin(msg.sender) {
        require(!address(_operator).isContract(), "Operator cannot be a contract");
        require(_operator != address(0), "Cannot be zero address");
        grantRole(OPERATOR_ROLE, _operator);

        emit NewOperator(_operator);
    }

    /**
     * @notice Set the bhavish administrator
     * @param _bhavishAdministrator Address of the bhavish admin contract
     */
    function setBhavishAdministrator(IBhavishAdministrator _bhavishAdministrator) external onlyAdmin(msg.sender) {
        require(address(_bhavishAdministrator).isContract(), "Not Bhavish Administrator");
        bhavishAdmin = _bhavishAdministrator;
    }

    /**
     * @notice Remove operator
     * @dev callable by Admin of the contract
     * @param _address current operator
     */
    function removeOperator(address _address) external onlyAdmin(msg.sender) {
        revokeRole(OPERATOR_ROLE, _address);
    }

    /**
     * @notice set the bhavish swap
     * @param _bhavishSwap bhavish swap address
     */
    function setBhavishSwap(BhavishSwap _bhavishSwap) external onlyAdmin(msg.sender) {
        require(address(_bhavishSwap).isContract(), "Swapper is not a contract");
        bhavishSwap = _bhavishSwap;
    }

    // This is need for this contract to accept native currency

    /**
     * @notice Add funds
     */
    receive() external payable {}

    // Pause/Unpause the contract logic goes here --------

    /**
     * @notice Pause the contract
     * @dev Callable by admin
     */
    function pause() external whenNotPaused onlyAdmin(msg.sender) {
        _pause();
        for (
            uint256 tempRoundId = currentRoundId;
            tempRoundId <= bhavishPredictionStorage.latestRoundId();
            tempRoundId++
        ) {
            Round memory round = bhavishPredictionStorage.getPredictionRound(tempRoundId);
            if (round.roundState != RoundState.CANCELLED) {
                _cancelRound(tempRoundId);
            }
        }

        emit PausedMarket(currentRoundId);
    }

    /**
     * @notice Unpuase the contract
     * @dev Callable by admin
     */
    function unPause() external whenPaused onlyAdmin(msg.sender) {
        marketStatus.createPredictionMarketOnce = false;
        marketStatus.startPredictionMarketOnce = false;
        currentRoundId = bhavishPredictionStorage.latestRoundId();
        _unpause();

        emit UnPausedMarket(currentRoundId);
    }

    // Set the min reqs for the contract goes here ---------

    /**
     * @notice Set minPredictAmount
     * @dev Callable by admin
     * @param _minPredictAmount minimum Predict amount to be set
     */
    function setMinPredictAmount(uint256 _minPredictAmount) external whenPaused onlyAdmin(msg.sender) {
        require(_minPredictAmount > 0, "Must be superior to 0");
        minPredictAmount = _minPredictAmount;

        emit NewMinPredictAmount(_minPredictAmount);
    }

    /**
     * @notice Set Treasury Fee
     * @dev Callable by admin
     * @param _treasuryFee new treasury fee
     */
    function setTreasuryFee(uint256 _treasuryFee) external whenPaused onlyAdmin(msg.sender) {
        require(_treasuryFee > 0 && _treasuryFee < MAX_TREASURY_FEE, "Treasury fee is too high");
        treasuryFee = _treasuryFee;

        emit NewTreasuryFee(_treasuryFee);
    }

    /**
     * @notice Set the round time
     * @dev Callable by operator
     * @param _roundTime round time
     */
    function setRoundTime(uint256 _roundTime) external whenPaused onlyOperator(msg.sender) {
        require(0 < _roundTime && _roundTime <= 86400, "Round Time should be between 1 sec to 3600 sec");
        roundTime = _roundTime;
    }

    // Prediction logic goes here --------

    /**
     * @notice Create Round
     * @param roundId round Id
     * @param _startTimestamp Round start timestamp
     */
    function _createRound(uint256 roundId, uint256 _startTimestamp) private {
        Round memory round = bhavishPredictionStorage.getPredictionRound(roundId);
        require(round.roundId == 0, "Round already exists");
        require(_startTimestamp - roundTime >= block.timestamp, "Round time is too short");
        round.roundId = roundId;
        round.roundStartTimestamp = _startTimestamp;
        round.roundEndTimestamp = round.roundStartTimestamp + roundTime;
        round.roundState = RoundState.CREATED;

        bhavishPredictionStorage.createPredictionRound(round);

        emit CreateRound(roundId);
    }

    /**
     * @notice Start Round
     * @param _predictRoundId round Id
     * @param _price Price of the asset
     */
    function _startRound(uint256 _predictRoundId, uint256 _price) private {
        Round memory round = bhavishPredictionStorage.getPredictionRound(_predictRoundId);
        if (_price == 0) {
            _cancelRound(_predictRoundId);
        } else {
            require(round.roundState == RoundState.CREATED, "Round should be created");
            require(round.roundStartTimestamp <= block.timestamp, "Too early to start the round");

            bhavishPredictionStorage.setRoundState(_predictRoundId, RoundState.STARTED, _price, true);

            emit StartRound(_predictRoundId);
        }
    }

    /**
     * @notice Cancel the round
     * @param _predictRoundId Round id of the round that needs to be cancelled
     */
    function _cancelRound(uint256 _predictRoundId) private {
        Round memory round = bhavishPredictionStorage.getPredictionRound(_predictRoundId);
        require(round.roundState != RoundState.CANCELLED, "Cannot cancel already cancelled round");

        bhavishPredictionStorage.cancelRound(_predictRoundId);
        emit CancelRound(_predictRoundId);
    }

    /**
     * @notice End Round
     * @param _predictRoundId round Id
     * @param _price Price of the asset
     */
    function _endRound(uint256 _predictRoundId, uint256 _price) private {
        Round memory round = bhavishPredictionStorage.getPredictionRound(_predictRoundId);
        require(round.roundState == RoundState.STARTED, "Round is not started yet");
        require(round.roundEndTimestamp <= block.timestamp, "Too early to end the round");

        bhavishPredictionStorage.setRoundState(_predictRoundId, RoundState.ENDED, _price, false);

        emit EndRound(_predictRoundId);
    }

    /**
     * @notice Calculate Rewards for the round
     * @param _predictRoundId round Id
     */
    function _calculateRewards(uint256 _predictRoundId) private {
        Round memory round = bhavishPredictionStorage.getPredictionRound(_predictRoundId);
        require(round.roundState == RoundState.ENDED, "Round is not ended");
        uint256 rewardBaseCalAmount;
        uint256 treasuryAmt;
        uint256 rewardAmount;

        treasuryAmt = (round.totalAmount * treasuryFee) / (10**decimals);

        // Bull wins
        if (round.endPrice > round.startPrice) {
            rewardBaseCalAmount = round.upPredictAmount;
            rewardAmount = round.totalAmount - treasuryAmt;
            // case when there are no bets on winning side. loosing side bets should be moved to treasury
            if (rewardBaseCalAmount == 0) {
                treasuryAmt = round.downPredictAmount;
                rewardAmount = 0;
            }
        }
        // Bear wins
        else if (round.endPrice < round.startPrice) {
            rewardBaseCalAmount = round.downPredictAmount;
            rewardAmount = round.totalAmount - treasuryAmt;
            // case when there are no bets on winning side. loosing side bets should be moved to treasury
            if (rewardBaseCalAmount == 0) {
                treasuryAmt = round.upPredictAmount;
                rewardAmount = 0;
            }
        }
        // draw or tie
        else {
            rewardBaseCalAmount = 0;
            rewardAmount = 0;
        }

        treasuryAmount += treasuryAmt;
        bhavishPredictionStorage.setRewardAmountForRound(_predictRoundId, rewardAmount, rewardBaseCalAmount);

        emit RewardsCalculated(_predictRoundId, rewardBaseCalAmount, rewardAmount, treasuryAmount);
    }

    /**
     * @notice Transfer
     * @param to recipient address
     * @param value value
     */
    function _safeTransfer(address to, uint256 value) private {
        (bool success, ) = to.call{ value: value }("");
        require(success, "TransferHelper: TRANSFER_FAILED");
    }

    /**
     * @notice Check whether the round is refundable
     * @param _predictRound round details
     */
    function _refundable(Round memory _predictRound) private pure returns (bool) {
        return
            _predictRound.rewardBaseCalAmount == 0 &&
            _predictRound.rewardAmount == 0 &&
            _predictRound.startPrice == _predictRound.endPrice;
    }

    /**
     * @notice Transfer the funds to bhavish admin contract_predictRound
     * @param _amount Amount to be transfered
     */
    function transferToAdmin(uint256 _amount) external payable nonReentrant onlyAdmin(msg.sender) {
        require(_amount <= treasuryAmount, "Transfer amount is too large");
        treasuryAmount -= _amount;
        address bhavishAdminAddress = address(bhavishAdmin);
        (bool success, ) = payable(bhavishAdminAddress).call{ value: _amount }("");
        require(success, "TransferHelper: TRANSFER_FAILED");

        emit TransferToAdmin(bhavishAdminAddress, _amount);
    }

    /**
     * @notice Bet Bull position
     * @param _predictRoundId Round Id
     * @param _userAddress Address of the user
     */
    function predictUp(uint256 _predictRoundId, address _userAddress)
        external
        payable
        override
        whenNotPaused
        nonReentrant
    {
        Round memory round = bhavishPredictionStorage.getPredictionRound(_predictRoundId);

        require(round.roundState == RoundState.CREATED && round.roundId != 0, "Bet is too early/late");
        require(block.timestamp <= round.roundStartTimestamp, "round already started");
        require(msg.value >= minPredictAmount, "Bet amount must be greater than minBetAmount");

        // Update round data
        uint256 amount = msg.value;
        bhavishPredictionStorage.setAmount(_predictRoundId, amount, true);

        BetInfo memory betInfo = bhavishPredictionStorage.getBetInfo(_predictRoundId, _userAddress);
        // Update user data
        if (betInfo.upPredictAmount == 0 && betInfo.downPredictAmount == 0) {
            bhavishPredictionStorage.setLedgerInfo(_userAddress, _predictRoundId);
        }
        bhavishPredictionStorage.setBetInfo(amount, _predictRoundId, _userAddress, true);

        emit PredictUp(_userAddress, _predictRoundId, msg.value);
    }

    /**
     * @notice Bet Bear position
     * @param _predictRoundId Round Id
     * @param _userAddress Address of the user
     */
    function predictDown(uint256 _predictRoundId, address _userAddress)
        external
        payable
        override
        whenNotPaused
        nonReentrant
    {
        Round memory round = bhavishPredictionStorage.getPredictionRound(_predictRoundId);

        require(block.timestamp <= round.roundStartTimestamp, "round already started");
        require(round.roundState == RoundState.CREATED && round.roundId != 0, "Bet is too early/late");
        require(msg.value >= minPredictAmount, "Bet amount must be greater than minBetAmount");

        // Update round data
        uint256 amount = msg.value;
        bhavishPredictionStorage.setAmount(_predictRoundId, amount, false);

        // Update user data
        BetInfo memory betInfo = bhavishPredictionStorage.getBetInfo(_predictRoundId, _userAddress);

        if (betInfo.upPredictAmount == 0 && betInfo.downPredictAmount == 0) {
            bhavishPredictionStorage.setLedgerInfo(_userAddress, _predictRoundId);
        }

        bhavishPredictionStorage.setBetInfo(amount, _predictRoundId, _userAddress, false);

        emit PredictDown(_userAddress, _predictRoundId, msg.value);
    }

    /**
     * @notice Create Round Zero round
     * @dev callable by Operator
     * @param _roundzeroStartTimestamp round zero round start timestamp
     */
    function createPredictionMarket(uint256 _roundzeroStartTimestamp)
        external
        override
        whenNotPaused
        onlyOperator(msg.sender)
    {
        require(!marketStatus.createPredictionMarketOnce, "Can only run roundzeroCreateRound once");
        currentRoundId = currentRoundId + 1;
        roundzeroStartTimestamp = _roundzeroStartTimestamp;
        _createRound(currentRoundId, _roundzeroStartTimestamp);
        marketStatus.createPredictionMarketOnce = true;

        //create next 3 rounds to be able to bet by users
        _createRound(currentRoundId + 1, roundzeroStartTimestamp + roundTime);
        _createRound(currentRoundId + 2, roundzeroStartTimestamp + roundTime + roundTime);
        _createRound(currentRoundId + 3, roundzeroStartTimestamp + roundTime + roundTime + roundTime);
    }

    /**
     * @notice Start Zero round
     * @dev callable by Operator
     */
    function startPredictionMarket() external override whenNotPaused onlyOperator(msg.sender) {
        require(marketStatus.createPredictionMarketOnce, "Can only run after roundzeroCreateRound is triggered");
        require(!marketStatus.startPredictionMarketOnce, "Can only run roundzeroStartRound once");

        require(block.timestamp >= roundzeroStartTimestamp, "Round cannot be started early");

        (uint256 price, ) = bhavishPriceManager.getPrice(
            assetPair.underlying,
            assetPair.strike,
            roundzeroStartTimestamp
        );

        _startRound(currentRoundId, price);

        marketStatus.startPredictionMarketOnce = true;
    }

    /**
     * @notice Get the _claimable stats of specific round id and user account
     * @param _round: round details
     * @param _betInfo: bet info of a user
     */
    function _claimable(Round memory _round, BetInfo memory _betInfo) public pure returns (bool) {
        return
            (_betInfo.upPredictAmount != 0 || _betInfo.downPredictAmount != 0) &&
            _betInfo.amountDispersed == 0 &&
            ((_round.endPrice > _round.startPrice && _betInfo.upPredictAmount != 0) ||
                (_round.endPrice < _round.startPrice && _betInfo.downPredictAmount != 0) ||
                (_round.endPrice == _round.startPrice));
    }

    /**
     * @notice claim reward
     * @param roundIds: round Ids
     */
    function claim(
        uint256[] calldata roundIds,
        bytes32 toAsset,
        bool convert,
        uint256 slippage,
        address userAddress
    ) external nonReentrant {
        uint256 reward = 0;
        for (uint256 i = 0; i < roundIds.length; i++) {
            Round memory round = bhavishPredictionStorage.getPredictionRound(roundIds[i]);
            BetInfo memory betInfo = bhavishPredictionStorage.getBetInfo(roundIds[i], userAddress);

            require(round.roundState == RoundState.ENDED, "Round not eligible for rewards");
            require(round.totalAmount > 0, "No bets in the round");

            if (round.startPrice == round.endPrice) {
                require(_refundable(round), "Not eligible for refund");
            }

            if (_claimable(round, betInfo)) {
                uint256 addedReward = _calcRewardsForUser(round, betInfo);

                bhavishPredictionStorage.setBetAmountDispersed(round.roundId, userAddress, addedReward);
                reward += addedReward;
                emit Claim(userAddress, roundIds[i], addedReward);
            }
        }

        if (convert && reward > 0) {
            BhavishSwap.SwapStruct memory swapStruct = BhavishSwap.SwapStruct({
                deadline: block.timestamp + (roundTime * 2),
                fromAsset: bytes32("MATIC"),
                toAsset: toAsset,
                amountIn: 0
            });
            bhavishSwap.swapExactETHForTokens{ value: reward }(swapStruct, userAddress, slippage);
        } else if (reward > 0) {
            _safeTransfer(address(userAddress), reward);
        }
    }

    function getAverageBetAmount(uint256[] calldata roundIds, address userAddress)
        external
        view
        override
        returns (uint256 betAmount)
    {
        for (uint256 i = 0; i < roundIds.length; i++) {
            BetInfo memory betInfo = bhavishPredictionStorage.getBetInfo(roundIds[i], userAddress);
            betAmount += betInfo.downPredictAmount + betInfo.upPredictAmount;
        }
        if (roundIds.length > 0) betAmount /= roundIds.length;
    }

    /**
     * @notice getRewards reward
     * @param roundIds: round Ids
     */
    function getRewards(uint256[] calldata roundIds, address userAddress) public view returns (uint256) {
        uint256 reward = 0;
        for (uint256 i = 0; i < roundIds.length; i++) {
            Round memory round = bhavishPredictionStorage.getPredictionRound(roundIds[i]);
            BetInfo memory betInfo = bhavishPredictionStorage.getBetInfo(roundIds[i], userAddress);

            if (!_claimable(round, betInfo)) {
                continue;
            }

            reward += _calcRewardsForUser(round, betInfo);
        }

        return reward;
    }

    function _calcRewardsForUser(Round memory _round, BetInfo memory _betInfo)
        private
        view
        returns (uint256 addedReward)
    {
        addedReward = 0;
        //check's for a tie
        if (_round.endPrice == _round.startPrice) {
            if (_refundable(_round)) {
                uint256 userTotalBetAmount = _betInfo.upPredictAmount + _betInfo.downPredictAmount;
                addedReward = userTotalBetAmount - ((userTotalBetAmount * treasuryFee) / 10**decimals);
            }
        } else if (_round.endPrice > _round.startPrice) {
            addedReward = (_betInfo.upPredictAmount * _round.rewardAmount) / _round.rewardBaseCalAmount;
        } else if (_round.endPrice < _round.startPrice) {
            addedReward = (_betInfo.downPredictAmount * _round.rewardAmount) / _round.rewardBaseCalAmount;
        }
    }

    /**
     * @notice Refund to users if a round is cancelled
     * @param _predictRoundId Round id of the cancelled round
     */
    function refundUsers(uint256 _predictRoundId, address userAddress) public override nonReentrant {
        Round memory round = bhavishPredictionStorage.getPredictionRound(_predictRoundId);
        require(round.roundState == RoundState.CANCELLED, "User not eligible for refund");

        BetInfo memory betInfo = bhavishPredictionStorage.getBetInfo(_predictRoundId, userAddress);
        uint256 amtInvested = betInfo.upPredictAmount + betInfo.downPredictAmount;
        uint256 tresFeeAmount = 0;
        if (amtInvested > 0) {
            tresFeeAmount = (amtInvested * treasuryFee) / 10**decimals;
            amtInvested -= tresFeeAmount;
            _safeTransfer(userAddress, amtInvested);
            emit Refund(_predictRoundId, userAddress, amtInvested, block.timestamp);
        }
        treasuryAmount += tresFeeAmount;
    }

    /**
     * @notice Execute round
     * @dev Callable by Operator
     */
    function executeRound() external override whenNotPaused {
        require(
            marketStatus.createPredictionMarketOnce && marketStatus.startPredictionMarketOnce,
            "Can only run after roundzeroStartRound"
        );
        Round memory curRound = bhavishPredictionStorage.getPredictionRound(currentRoundId);
        Round memory roundPlusThree = bhavishPredictionStorage.getPredictionRound(currentRoundId + 3);

        // currentRoundId refers to current round n
        // fetch price to end current round and start new round
        (uint256 price, ) = bhavishPriceManager.getPrice(
            assetPair.underlying,
            assetPair.strike,
            curRound.roundEndTimestamp
        );

        // End and Disperse current round
        if (curRound.roundState != RoundState.CANCELLED && price != 0) {
            _endRound(currentRoundId, price);

            _calculateRewards(currentRoundId);
        } else if (curRound.roundState != RoundState.CANCELLED && price == 0) {
            _cancelRound(currentRoundId);
        }

        // Start next round
        _startRound(currentRoundId + 1, price);

        // Create a new round n+3
        _createRound(currentRoundId + 4, roundPlusThree.roundEndTimestamp);

        // Point currentRoundId to next round
        currentRoundId = currentRoundId + 1;
    }

    function getCurrentRoundDetails() external view returns (IBhavishPrediction.Round memory round) {
        round = bhavishPredictionStorage.getPredictionRound(currentRoundId);
    }
}

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

pragma solidity ^0.8.0;

import "../utils/Context.sol";

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

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

    bool private _paused;

    /**
     * @dev Initializes the contract in unpaused state.
     */
    constructor() {
        _paused = false;
    }

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

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

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

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

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

File 3 of 24 : AccessControl.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (access/AccessControl.sol)

pragma solidity ^0.8.0;

import "./IAccessControl.sol";
import "../utils/Context.sol";
import "../utils/Strings.sol";
import "../utils/introspection/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, _msgSender());
        _;
    }

    /**
     * @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 `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.
     */
    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.
     */
    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`.
     */
    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.
     *
     * [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.
     */
    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.
     */
    function _revokeRole(bytes32 role, address account) internal virtual {
        if (hasRole(role, account)) {
            _roles[role].members[account] = false;
            emit RoleRevoked(role, account, _msgSender());
        }
    }
}

File 4 of 24 : 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;
    }
}

File 5 of 24 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.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

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

File 6 of 24 : IBhavishAdministrator.sol
// SPDX-License-Identifier: BSD-4-Clause

pragma solidity ^0.8.13;

/**
 * @title IBhavishAdministrator
 */

interface IBhavishAdministrator {
    /**
     * @dev Emitted when Treasury is claimed by the admin
     * @param admin Address of the admin
     * @param amount Amount claimed by the admin
     */
    event TreasuryClaim(address indexed admin, uint256 amount);

    /**
     * @dev Claim the treasury amount. Can be performed only by admin
     * @param _amount  Amount that admin wants to claim
     */
    function claimTreasury(uint256 _amount) external;
}

File 7 of 24 : IPriceManager.sol
// SPDX-License-Identifier: BSD-4-Clause

pragma solidity ^0.8.13;

interface IPriceManager {
    /**
     * @dev Emitted when the new Oracle aggregator data has been added.
     * @param _underlying Address of the underlying asset.
     * @param _strike Address of the strike asset.
     * @param _bhavishAggregator Address of the bhavish aggregator.
     * @param _aggregator Address of the aggregator.
     */
    event AddAssetPairAggregator(
        bytes32 indexed _underlying,
        bytes32 indexed _strike,
        address _bhavishAggregator,
        address _aggregator
    );

    /**
     * @notice Function to add the price for an underlying, strike asset pair
     * @param _underlying Underlying Asset
     * @param _strike Strike Asset
     * @param _aggregator Address of the aggregator.
     */
    function setPairContract(
        bytes32 _underlying,
        bytes32 _strike,
        address _aggregator
    ) external;

    /**
     * @notice Function to get the price for an underlying asset
     * @param _underlying Underlying Asset
     * @param _strike Strike Asset
     * @param _timestamp    Timestamp
     * @return price asset price
     * @return decimals asset price decimals
     */
    function getPrice(
        bytes32 _underlying,
        bytes32 _strike,
        uint256 _timestamp
    ) external view returns (uint256 price, uint8 decimals);
}

File 8 of 24 : IBhavishPrediction.sol
// SPDX-License-Identifier: BSD-4-Clause

pragma solidity ^0.8.13;

interface IBhavishPrediction {
    enum RoundState {
        CREATED,
        STARTED,
        ENDED,
        CANCELLED
    }

    struct Round {
        uint256 roundId;
        RoundState roundState;
        uint256 upPredictAmount;
        uint256 downPredictAmount;
        uint256 totalAmount;
        uint256 rewardBaseCalAmount;
        uint256 rewardAmount;
        uint256 startPrice;
        uint256 endPrice;
        uint256 roundStartTimestamp;
        uint256 roundEndTimestamp;
    }

    struct BetInfo {
        uint256 upPredictAmount;
        uint256 downPredictAmount;
        uint256 amountDispersed;
    }

    struct AssetPair {
        bytes32 underlying;
        bytes32 strike;
    }

    struct PredictionMarketStatus {
        bool startPredictionMarketOnce;
        bool createPredictionMarketOnce;
    }

    /**
     * @notice Create Round Zero round
     * @dev callable by Operator
     * @param _roundzeroStartTimestamp: round zero round start timestamp
     */
    function createPredictionMarket(uint256 _roundzeroStartTimestamp) external;

    /**
     * @notice Start Zero round
     * @dev callable by Operator
     */
    function startPredictionMarket() external;

    /**
     * @notice Execute round
     * @dev Callable by Operator
     */
    function executeRound() external;

    /**
     * @notice Bet Bull position
     * @param roundId: Round Id
     * @param userAddress: Address of the user
     */
    function predictUp(uint256 roundId, address userAddress) external payable;

    /**
     * @notice Bet Bear position
     * @param roundId: Round Id
     * @param userAddress: Address of the user
     */
    function predictDown(uint256 roundId, address userAddress) external payable;

    function getCurrentRoundDetails() external view returns (IBhavishPrediction.Round memory);

    function claim(
        uint256[] calldata roundIds,
        bytes32 toAsset,
        bool convert,
        uint256 slippage,
        address userAddress
    ) external;

    function refundUsers(uint256 _predictRoundId, address userAddress) external;

    function getAverageBetAmount(uint256[] calldata roundIds, address userAddress) external returns (uint256);
}

File 9 of 24 : BhavishPredictionStorage.sol
// SPDX-License-Identifier: BSD-4-Clause

pragma solidity ^0.8.13;

import "@openzeppelin/contracts/access/AccessControl.sol";
import "@openzeppelin/contracts/utils/Address.sol";
import ".././Interface/IBhavishPrediction.sol";

contract BhavishPredictionStorage is AccessControl {
    using Address for address;
    bytes32 public constant MANAGER_ROLE = keccak256("MANAGER_ROLE");

    mapping(uint256 => IBhavishPrediction.Round) public rounds;
    mapping(uint256 => mapping(address => IBhavishPrediction.BetInfo)) public ledger;
    mapping(address => uint256[]) public userRounds;
    mapping(uint256 => address[]) public usersInRounds;

    uint256 public latestRoundId;

    modifier onlyManager(address _address) {
        require(hasRole(MANAGER_ROLE, _address), "caller has no access to the method");
        _;
    }

    constructor() {
        _setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
    }

    function setManager(address _address) external {
        require(_address != address(0) && _address.isContract(), "Invalid manager address");
        grantRole(MANAGER_ROLE, _address);
    }

    function createPredictionRound(IBhavishPrediction.Round memory round) external onlyManager(msg.sender) {
        rounds[round.roundId] = round;
        latestRoundId = round.roundId;
    }

    function updatePredictionRound(IBhavishPrediction.Round memory round) external onlyManager(msg.sender) {
        require(rounds[round.roundId].roundId != 0, "Cannot overwrite non existing round");
        rounds[round.roundId] = round;
    }

    function getUsersInRounds(uint256 _predictRoundId) external view returns (address[] memory userAddresses) {
        userAddresses = usersInRounds[_predictRoundId];
    }

    function getPredictionRound(uint256 roundId) external view returns (IBhavishPrediction.Round memory round) {
        round = rounds[roundId];
    }

    function getArrayRounds(uint256 from, uint256 to)
        external
        view
        returns (IBhavishPrediction.Round[] memory arrayOfRounds)
    {
        require(to <= latestRoundId, "Index out of bound");
        require(from < to, "From < To");
        uint256 len = to - from;
        arrayOfRounds = new IBhavishPrediction.Round[](to - from);

        for (uint256 i = 0; i < len; i++) {
            arrayOfRounds[i] = rounds[from];
            from += 1;
        }
    }

    function setRoundState(
        uint256 roundId,
        IBhavishPrediction.RoundState state,
        uint256 price,
        bool start
    ) external onlyManager(msg.sender) {
        IBhavishPrediction.Round storage round = rounds[roundId];
        round.roundState = state;
        if (start) round.startPrice = price;
        else round.endPrice = price;
    }

    function cancelRound(uint256 roundId) external onlyManager(msg.sender) {
        IBhavishPrediction.Round storage round = rounds[roundId];
        round.roundState = IBhavishPrediction.RoundState.CANCELLED;
    }

    function setRewardAmountForRound(
        uint256 roundId,
        uint256 rewardAmount,
        uint256 rewardBaseCalAmount
    ) external onlyManager(msg.sender) {
        IBhavishPrediction.Round storage round = rounds[roundId];
        round.rewardAmount = rewardAmount;
        round.rewardBaseCalAmount = rewardBaseCalAmount;
    }

    function setAmount(
        uint256 roundId,
        uint256 amount,
        bool directionUp
    ) external onlyManager(msg.sender) {
        IBhavishPrediction.Round storage round = rounds[roundId];
        round.totalAmount = round.totalAmount + amount;
        if (directionUp) round.upPredictAmount += amount;
        else round.downPredictAmount += amount;
    }

    function createBet(
        IBhavishPrediction.BetInfo memory betInfo,
        uint256 roundId,
        address userAddress
    ) external onlyManager(msg.sender) {
        ledger[roundId][userAddress] = betInfo;
    }

    function getBetInfo(uint256 roundId, address userAddress)
        external
        view
        returns (IBhavishPrediction.BetInfo memory betInfo)
    {
        betInfo = ledger[roundId][userAddress];
    }

    function setBetAmountDispersed(
        uint256 roundId,
        address userAddress,
        uint256 amountDispersed
    ) external onlyManager(msg.sender) {
        IBhavishPrediction.BetInfo storage betInfo = ledger[roundId][userAddress];
        betInfo.amountDispersed += amountDispersed;
    }

    function setBetInfo(
        uint256 amount,
        uint256 roundId,
        address userAddress,
        bool directionUp
    ) external onlyManager(msg.sender) {
        IBhavishPrediction.BetInfo storage betInfo = ledger[roundId][userAddress];
        if (directionUp) betInfo.upPredictAmount += amount;
        else betInfo.downPredictAmount += amount;
    }

    function setLedgerInfo(address userAddress, uint256 roundId) external onlyManager(msg.sender) {
        userRounds[userAddress].push(roundId);
        usersInRounds[roundId].push(userAddress);
    }

    function getUserRoundHistory(address userAddress)
        external
        view
        returns (IBhavishPrediction.BetInfo[] memory userRoundHistory)
    {
        userRoundHistory = new IBhavishPrediction.BetInfo[](userRounds[userAddress].length);
        for (uint256 i = 0; i < userRounds[userAddress].length; i++) {
            uint256 roundId = userRounds[userAddress][i];
            userRoundHistory[i] = ledger[roundId][userAddress];
        }
    }

    function getUserRounds(address userAddress) external view returns (uint256[] memory) {
        return userRounds[userAddress];
    }

    function getUserInRounds(uint256 roundId) external view returns (address[] memory) {
        return usersInRounds[roundId];
    }
}

File 10 of 24 : BhavishSwap.sol
// SPDX-License-Identifier: BSD-4-Clause

import "@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol";
import "@uniswap/v2-core/contracts/interfaces/IUniswapV2Factory.sol";
import "@uniswap/v2-core/contracts/interfaces/IUniswapV2Pair.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/access/AccessControl.sol";
import "../../Interface/IBhavishSDK.sol";

pragma solidity ^0.8.13;

contract BhavishSwap is AccessControl {
    using SafeERC20 for IERC20;

    address public UNISWAP_FACTORY;
    address public UNISWAP_ROUTER;
    mapping(bytes32 => address[]) public pathMapper;
    uint256 public decimals = 3;

    struct SwapStruct {
        uint256 amountIn;
        uint256 deadline;
        bytes32 fromAsset;
        bytes32 toAsset;
    }

    modifier onlyAsset(bytes32 fromAsset, bytes32 toAsset) {
        address[] memory path = getPath(fromAsset, toAsset);
        require(path.length > 1, "Asset swap not supported");
        _;
    }

    modifier onlyAdmin(address _address) {
        require(hasRole(DEFAULT_ADMIN_ROLE, _address), "Address not an admin");
        _;
    }

    constructor(address uniswapFactory, address uniswapRouter) {
        UNISWAP_FACTORY = uniswapFactory;
        UNISWAP_ROUTER = uniswapRouter;
        _setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
    }

    /**
     * @notice Add funds
     */
    receive() external payable {}

    function setPath(
        bytes32 fromAsset,
        bytes32 toAsset,
        address[] memory path
    ) external onlyAdmin(msg.sender) {
        require(path.length > 1, "Path cannot be empty or 1");
        pathMapper[keccak256((abi.encode(fromAsset, toAsset)))] = path;
    }

    function getPath(bytes32 fromAsset, bytes32 toAsset) public view returns (address[] memory) {
        return pathMapper[keccak256(abi.encode(fromAsset, toAsset))];
    }

    // Get the amounts out for the specified path
    function getAmountsOut(
        uint256 amountIn,
        bytes32 fromAsset,
        bytes32 toAsset
    ) public view onlyAsset(fromAsset, toAsset) returns (uint256[] memory amounts) {
        address[] memory path = getPath(fromAsset, toAsset);
        amounts = new uint256[](path.length);
        amounts = IUniswapV2Router02(UNISWAP_ROUTER).getAmountsOut(amountIn, path);
    }

    function swapExactTokensForETH(
        SwapStruct memory _swapStruct,
        address to,
        uint256 slippage
    ) external onlyAsset(_swapStruct.fromAsset, _swapStruct.toAsset) returns (uint256[] memory amounts) {
        address[] memory path = getPath(_swapStruct.fromAsset, _swapStruct.toAsset);
        uint256[] memory amountsOut = getAmountsOut(_swapStruct.amountIn, _swapStruct.fromAsset, _swapStruct.toAsset);
        uint256 amountOut = amountsOut[amountsOut.length - 1] -
            ((amountsOut[amountsOut.length - 1] * slippage) / 10**decimals);
        IERC20(path[0]).safeApprove(UNISWAP_ROUTER, _swapStruct.amountIn);
        amounts = IUniswapV2Router02(UNISWAP_ROUTER).swapExactTokensForETH(
            _swapStruct.amountIn,
            amountOut,
            path,
            to,
            _swapStruct.deadline
        );
    }

    function swapExactETHForTokens(
        SwapStruct memory _swapStruct,
        address to,
        uint256 slippage
    ) external payable onlyAsset(_swapStruct.fromAsset, _swapStruct.toAsset) returns (uint256[] memory amounts) {
        address[] memory path = getPath(_swapStruct.fromAsset, _swapStruct.toAsset);
        uint256[] memory amountsOut = getAmountsOut(msg.value, _swapStruct.fromAsset, _swapStruct.toAsset);
        uint256 amountOut = amountsOut[amountsOut.length - 1] -
            ((amountsOut[amountsOut.length - 1] * slippage) / 10**decimals);
        amounts = IUniswapV2Router02(UNISWAP_ROUTER).swapExactETHForTokens{ value: msg.value }(
            amountOut,
            path,
            to,
            _swapStruct.deadline
        );
    }
}

File 11 of 24 : BaseRelayRecipient.sol
// SPDX-License-Identifier: BSD-4-Clause

pragma solidity ^0.8.13;

import "./IRelayRecipient.sol";

/**
 * A base contract to be inherited by any contract that want to receive relayed transactions
 * A subclass must use "_msgSender()" instead of "msg.sender"
 */
abstract contract BaseRelayRecipient is IRelayRecipient {
    /*
     * Forwarder singleton we accept calls from
     */

    address[] public trustedForwarder;

    /*
     * require a function to be called through GSN only
     */
    modifier trustedForwarderOnly() {
        require(isTrustedForwarder(msg.sender), "Function can only be called through the trusted Forwarder");
        _;
    }

    function isTrustedForwarder(address forwarder) public view override returns (bool) {
        for (uint256 i = 0; i < trustedForwarder.length; i++) if (forwarder == trustedForwarder[i]) return true;
        return false;
    }

    /**
     * return the sender of this call.
     * if the call came through our trusted forwarder, return the original sender.
     * otherwise, return `msg.sender`.
     * should be used in the contract anywhere instead of msg.sender
     */
    function msgSender() internal view virtual override returns (address ret) {
        if (msg.data.length >= 24 && isTrustedForwarder(msg.sender)) {
            // At this point we know that the sender is a trusted forwarder,
            // so we trust that the last bytes of msg.data are the verified sender address.
            // extract sender address from the end of msg.data
            assembly {
                ret := shr(96, calldataload(sub(calldatasize(), 20)))
            }
        } else {
            return msg.sender;
        }
    }
}

File 12 of 24 : Context.sol
// 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;
    }
}

File 13 of 24 : IAccessControl.sol
// 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;
}

File 14 of 24 : Strings.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)

pragma solidity ^0.8.0;

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

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

File 15 of 24 : ERC165.sol
// 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;
    }
}

File 16 of 24 : IERC165.sol
// 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 17 of 24 : IUniswapV2Router02.sol
pragma solidity >=0.6.2;

import './IUniswapV2Router01.sol';

interface IUniswapV2Router02 is IUniswapV2Router01 {
    function removeLiquidityETHSupportingFeeOnTransferTokens(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external returns (uint amountETH);
    function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline,
        bool approveMax, uint8 v, bytes32 r, bytes32 s
    ) external returns (uint amountETH);

    function swapExactTokensForTokensSupportingFeeOnTransferTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external;
    function swapExactETHForTokensSupportingFeeOnTransferTokens(
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external payable;
    function swapExactTokensForETHSupportingFeeOnTransferTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external;
}

File 18 of 24 : IUniswapV2Factory.sol
pragma solidity >=0.5.0;

interface IUniswapV2Factory {
    event PairCreated(address indexed token0, address indexed token1, address pair, uint);

    function feeTo() external view returns (address);
    function feeToSetter() external view returns (address);

    function getPair(address tokenA, address tokenB) external view returns (address pair);
    function allPairs(uint) external view returns (address pair);
    function allPairsLength() external view returns (uint);

    function createPair(address tokenA, address tokenB) external returns (address pair);

    function setFeeTo(address) external;
    function setFeeToSetter(address) external;
}

File 19 of 24 : IUniswapV2Pair.sol
pragma solidity >=0.5.0;

interface IUniswapV2Pair {
    event Approval(address indexed owner, address indexed spender, uint value);
    event Transfer(address indexed from, address indexed to, uint value);

    function name() external pure returns (string memory);
    function symbol() external pure returns (string memory);
    function decimals() external pure returns (uint8);
    function totalSupply() external view returns (uint);
    function balanceOf(address owner) external view returns (uint);
    function allowance(address owner, address spender) external view returns (uint);

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

    function DOMAIN_SEPARATOR() external view returns (bytes32);
    function PERMIT_TYPEHASH() external pure returns (bytes32);
    function nonces(address owner) external view returns (uint);

    function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;

    event Mint(address indexed sender, uint amount0, uint amount1);
    event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);
    event Swap(
        address indexed sender,
        uint amount0In,
        uint amount1In,
        uint amount0Out,
        uint amount1Out,
        address indexed to
    );
    event Sync(uint112 reserve0, uint112 reserve1);

    function MINIMUM_LIQUIDITY() external pure returns (uint);
    function factory() external view returns (address);
    function token0() external view returns (address);
    function token1() external view returns (address);
    function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);
    function price0CumulativeLast() external view returns (uint);
    function price1CumulativeLast() external view returns (uint);
    function kLast() external view returns (uint);

    function mint(address to) external returns (uint liquidity);
    function burn(address to) external returns (uint amount0, uint amount1);
    function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;
    function skim(address to) external;
    function sync() external;

    function initialize(address, address) external;
}

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

File 21 of 24 : IBhavishSDK.sol
// SPDX-License-Identifier: BSD-4-Clause

pragma solidity ^0.8.13;

import "./../Integrations/Swap/BhavishSwap.sol";

interface IBhavishSDK {
    event PredictionMarketProvider(uint256 indexed _month, address indexed _provider);

    struct PredictionStruct {
        bytes32 underlying;
        bytes32 strike;
        uint256 roundId;
        bool directionUp;
    }

    function predict(
        PredictionStruct memory _predStruct,
        address _userAddress,
        address _provider
    ) external payable;

    function predictWithGasless(PredictionStruct memory _predStruct, address _provider) external payable;

    function minimumGaslessBetAmount() external returns (uint256);

    function swapAndPredict(
        BhavishSwap.SwapStruct memory _swapStruct,
        PredictionStruct memory _predStruct,
        uint256 slippage,
        address _provider
    ) external;

    function swapAndPredictWithGasless(
        BhavishSwap.SwapStruct memory _swapStruct,
        PredictionStruct memory _predStruct,
        uint256 slippage,
        address _provider
    ) external;
}

File 22 of 24 : IUniswapV2Router01.sol
pragma solidity >=0.6.2;

interface IUniswapV2Router01 {
    function factory() external pure returns (address);
    function WETH() external pure returns (address);

    function addLiquidity(
        address tokenA,
        address tokenB,
        uint amountADesired,
        uint amountBDesired,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline
    ) external returns (uint amountA, uint amountB, uint liquidity);
    function addLiquidityETH(
        address token,
        uint amountTokenDesired,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external payable returns (uint amountToken, uint amountETH, uint liquidity);
    function removeLiquidity(
        address tokenA,
        address tokenB,
        uint liquidity,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline
    ) external returns (uint amountA, uint amountB);
    function removeLiquidityETH(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external returns (uint amountToken, uint amountETH);
    function removeLiquidityWithPermit(
        address tokenA,
        address tokenB,
        uint liquidity,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline,
        bool approveMax, uint8 v, bytes32 r, bytes32 s
    ) external returns (uint amountA, uint amountB);
    function removeLiquidityETHWithPermit(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline,
        bool approveMax, uint8 v, bytes32 r, bytes32 s
    ) external returns (uint amountToken, uint amountETH);
    function swapExactTokensForTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external returns (uint[] memory amounts);
    function swapTokensForExactTokens(
        uint amountOut,
        uint amountInMax,
        address[] calldata path,
        address to,
        uint deadline
    ) external returns (uint[] memory amounts);
    function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)
        external
        payable
        returns (uint[] memory amounts);
    function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
        external
        returns (uint[] memory amounts);
    function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
        external
        returns (uint[] memory amounts);
    function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)
        external
        payable
        returns (uint[] memory amounts);

    function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);
    function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);
    function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);
    function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);
    function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);
}

File 23 of 24 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

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

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

    /**
     * @dev Moves `amount` tokens from the caller's account to `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);

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

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

File 24 of 24 : IRelayRecipient.sol
// SPDX-License-Identifier: BSD-4-Clause

pragma solidity ^0.8.13;

/**
 * a contract must implement this interface in order to support relayed transaction.
 * It is better to inherit the BaseRelayRecipient as its implementation.
 */
abstract contract IRelayRecipient {
    /**
     * return if the forwarder is trusted to forward relayed transactions to us.
     * the forwarder is required to verify the sender's signature, and verify
     * the call is not a replay.
     */
    function isTrustedForwarder(address forwarder) public view virtual returns (bool);

    /**
     * return the sender of this call.
     * if the call came through our trusted forwarder, then the real sender is appended as the last 20 bytes
     * of the msg.data.
     * otherwise, return `msg.sender`
     * should be used in the contract anywhere instead of msg.sender
     */
    function msgSender() internal view virtual returns (address);

    function versionRecipient() external view virtual returns (string memory);
}

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"uint256","name":"_minPredictAmount","type":"uint256"},{"internalType":"uint256","name":"_treasuryFee","type":"uint256"},{"internalType":"contract IBhavishAdministrator","name":"_bhavishAdmin","type":"address"},{"internalType":"contract IPriceManager","name":"_bhavishPriceManager","type":"address"},{"internalType":"contract BhavishPredictionStorage","name":"_bhavishPredictionStorage","type":"address"},{"internalType":"uint256","name":"_roundTime","type":"uint256"},{"internalType":"bytes32","name":"_underlying","type":"bytes32"},{"internalType":"bytes32","name":"_strike","type":"bytes32"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"roundId","type":"uint256"}],"name":"CancelRound","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":true,"internalType":"uint256","name":"roundId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Claim","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"roundId","type":"uint256"}],"name":"CreateRound","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"roundId","type":"uint256"}],"name":"EndRound","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"admin","type":"address"}],"name":"NewAdmin","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"minPredictAmount","type":"uint256"}],"name":"NewMinPredictAmount","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"}],"name":"NewOperator","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"treasuryFee","type":"uint256"}],"name":"NewTreasuryFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"currentRoundId","type":"uint256"}],"name":"PausedMarket","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":true,"internalType":"uint256","name":"roundId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"PredictDown","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":true,"internalType":"uint256","name":"roundId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"PredictUp","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"roundId","type":"uint256"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"refundDispersed","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"Refund","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"roundId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"rewardBaseCalAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"rewardAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"treasuryAmount","type":"uint256"}],"name":"RewardsCalculated","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":"uint256","name":"roundId","type":"uint256"}],"name":"StartRound","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"bhavishAdmin","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"TransferToAdmin","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"currentRoundId","type":"uint256"}],"name":"UnPausedMarket","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MANAGER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_TREASURY_FEE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"OPERATOR_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"roundId","type":"uint256"},{"internalType":"enum IBhavishPrediction.RoundState","name":"roundState","type":"uint8"},{"internalType":"uint256","name":"upPredictAmount","type":"uint256"},{"internalType":"uint256","name":"downPredictAmount","type":"uint256"},{"internalType":"uint256","name":"totalAmount","type":"uint256"},{"internalType":"uint256","name":"rewardBaseCalAmount","type":"uint256"},{"internalType":"uint256","name":"rewardAmount","type":"uint256"},{"internalType":"uint256","name":"startPrice","type":"uint256"},{"internalType":"uint256","name":"endPrice","type":"uint256"},{"internalType":"uint256","name":"roundStartTimestamp","type":"uint256"},{"internalType":"uint256","name":"roundEndTimestamp","type":"uint256"}],"internalType":"struct IBhavishPrediction.Round","name":"_round","type":"tuple"},{"components":[{"internalType":"uint256","name":"upPredictAmount","type":"uint256"},{"internalType":"uint256","name":"downPredictAmount","type":"uint256"},{"internalType":"uint256","name":"amountDispersed","type":"uint256"}],"internalType":"struct IBhavishPrediction.BetInfo","name":"_betInfo","type":"tuple"}],"name":"_claimable","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"assetPair","outputs":[{"internalType":"bytes32","name":"underlying","type":"bytes32"},{"internalType":"bytes32","name":"strike","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"bhavishAdmin","outputs":[{"internalType":"contract IBhavishAdministrator","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"bhavishPredictionStorage","outputs":[{"internalType":"contract BhavishPredictionStorage","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"bhavishPriceManager","outputs":[{"internalType":"contract IPriceManager","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"bhavishSwap","outputs":[{"internalType":"contract BhavishSwap","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"roundIds","type":"uint256[]"},{"internalType":"bytes32","name":"toAsset","type":"bytes32"},{"internalType":"bool","name":"convert","type":"bool"},{"internalType":"uint256","name":"slippage","type":"uint256"},{"internalType":"address","name":"userAddress","type":"address"}],"name":"claim","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_roundzeroStartTimestamp","type":"uint256"}],"name":"createPredictionMarket","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"currentRoundId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"executeRound","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"roundIds","type":"uint256[]"},{"internalType":"address","name":"userAddress","type":"address"}],"name":"getAverageBetAmount","outputs":[{"internalType":"uint256","name":"betAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getCurrentRoundDetails","outputs":[{"components":[{"internalType":"uint256","name":"roundId","type":"uint256"},{"internalType":"enum IBhavishPrediction.RoundState","name":"roundState","type":"uint8"},{"internalType":"uint256","name":"upPredictAmount","type":"uint256"},{"internalType":"uint256","name":"downPredictAmount","type":"uint256"},{"internalType":"uint256","name":"totalAmount","type":"uint256"},{"internalType":"uint256","name":"rewardBaseCalAmount","type":"uint256"},{"internalType":"uint256","name":"rewardAmount","type":"uint256"},{"internalType":"uint256","name":"startPrice","type":"uint256"},{"internalType":"uint256","name":"endPrice","type":"uint256"},{"internalType":"uint256","name":"roundStartTimestamp","type":"uint256"},{"internalType":"uint256","name":"roundEndTimestamp","type":"uint256"}],"internalType":"struct IBhavishPrediction.Round","name":"round","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"roundIds","type":"uint256[]"},{"internalType":"address","name":"userAddress","type":"address"}],"name":"getRewards","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":"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":[],"name":"marketStatus","outputs":[{"internalType":"bool","name":"startPredictionMarketOnce","type":"bool"},{"internalType":"bool","name":"createPredictionMarketOnce","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minPredictAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_predictRoundId","type":"uint256"},{"internalType":"address","name":"_userAddress","type":"address"}],"name":"predictDown","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_predictRoundId","type":"uint256"},{"internalType":"address","name":"_userAddress","type":"address"}],"name":"predictUp","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_predictRoundId","type":"uint256"},{"internalType":"address","name":"userAddress","type":"address"}],"name":"refundUsers","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"}],"name":"removeOperator","outputs":[],"stateMutability":"nonpayable","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":[],"name":"roundTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"roundzeroStartTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IBhavishAdministrator","name":"_bhavishAdministrator","type":"address"}],"name":"setBhavishAdministrator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract BhavishSwap","name":"_bhavishSwap","type":"address"}],"name":"setBhavishSwap","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_minPredictAmount","type":"uint256"}],"name":"setMinPredictAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_operator","type":"address"}],"name":"setOperator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_roundTime","type":"uint256"}],"name":"setRoundTime","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_treasuryFee","type":"uint256"}],"name":"setTreasuryFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"startPredictionMarket","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"transferToAdmin","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"treasuryAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"treasuryFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unPause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]

Deployed Bytecode

0x6080604052600436106102765760003560e01c8063965547571161014f578063e0e081d7116100c1578063f2b3c8091161007a578063f2b3c80914610758578063f5b541a61461076d578063f7b188a51461078f578063fa65cb04146107a4578063fb2f897a146107c4578063fc572b18146107e457600080fd5b8063e0e081d714610681578063e44bb72f146106bb578063e8712bd4146106ce578063ec87621c146106ee578063ee5f8c8f14610722578063efc3b2ea1461073857600080fd5b8063a217fddf11610113578063a217fddf146105d6578063a23e9884146105eb578063ac8a584a1461060b578063b3ab15fb1461062b578063cc32d1761461064b578063d547741f1461066157600080fd5b8063965547571461053e5780639b87eade1461055e5780639bb6eb701461057e5780639cbe5efd146105a0578063a2003734146105b657600080fd5b8063445769cd116101e857806377e0181f116101ac57806377e0181f1461049f57806377e741c7146104b4578063795c2960146104d45780637b3205f5146104f45780638456cb591461050957806391d148541461051e57600080fd5b8063445769cd146104115780634b14c3d4146104315780635a9aa957146104515780635c975abb14610467578063733436201461047f57600080fd5b80632f2ff15d1161023a5780632f2ff15d1461034d578063313ce5671461036d578063325f700e1461038357806335538b69146103bb57806336568abe146103db578063368acb09146103fb57600080fd5b806301ffc9a71461028257806309fffec0146102b757806310082c75146102cc5780631c389c28146102fc578063248a9ca31461030f57600080fd5b3661027d57005b600080fd5b34801561028e57600080fd5b506102a261029d3660046139cd565b6107fa565b60405190151581526020015b60405180910390f35b6102ca6102c53660046139f7565b610831565b005b3480156102d857600080fd5b50600b54600c546102e7919082565b604080519283526020830191909152016102ae565b6102ca61030a366004613a28565b6109e5565b34801561031b57600080fd5b5061033f61032a3660046139f7565b60009081526020819052604090206001015490565b6040519081526020016102ae565b34801561035957600080fd5b506102ca610368366004613a28565b610d9e565b34801561037957600080fd5b5061033f600a5481565b34801561038f57600080fd5b50600d546103a3906001600160a01b031681565b6040516001600160a01b0390911681526020016102ae565b3480156103c757600080fd5b506102ca6103d63660046139f7565b610dc9565b3480156103e757600080fd5b506102ca6103f6366004613a28565b610f40565b34801561040757600080fd5b5061033f60095481565b34801561041d57600080fd5b506102ca61042c3660046139f7565b610fba565b34801561043d57600080fd5b506010546103a3906001600160a01b031681565b34801561045d57600080fd5b5061033f60055481565b34801561047357600080fd5b5060015460ff166102a2565b34801561048b57600080fd5b506102ca61049a366004613a28565b611089565b3480156104ab57600080fd5b506102ca6112c2565b3480156104c057600080fd5b506102ca6104cf3660046139f7565b6114e5565b3480156104e057600080fd5b5061033f6104ef366004613aa4565b6115c0565b34801561050057600080fd5b506102ca6116b8565b34801561051557600080fd5b506102ca61199f565b34801561052a57600080fd5b506102a2610539366004613a28565b611b5c565b34801561054a57600080fd5b506102ca610559366004613afb565b611b85565b34801561056a57600080fd5b506102ca610579366004613b7c565b61202b565b34801561058a57600080fd5b506105936120cd565b6040516102ae9190613bd1565b3480156105ac57600080fd5b5061033f60035481565b3480156105c257600080fd5b506102a26105d1366004613d3e565b6121a7565b3480156105e257600080fd5b5061033f600081565b3480156105f757600080fd5b506102ca610606366004613b7c565b612222565b34801561061757600080fd5b506102ca610626366004613b7c565b6122c4565b34801561063757600080fd5b506102ca610646366004613b7c565b612304565b34801561065757600080fd5b5061033f60075481565b34801561066d57600080fd5b506102ca61067c366004613a28565b612423565b34801561068d57600080fd5b506006546106a49060ff8082169161010090041682565b6040805192151583529015156020830152016102ae565b6102ca6106c9366004613a28565b612449565b3480156106da57600080fd5b50600f546103a3906001600160a01b031681565b3480156106fa57600080fd5b5061033f7f241ecf16d79d0f8dbfb92cbc07fe17840425976cf0667f022fe9877caa831b0881565b34801561072e57600080fd5b5061033f60045481565b34801561074457600080fd5b50600e546103a3906001600160a01b031681565b34801561076457600080fd5b5061033f606481565b34801561077957600080fd5b5061033f6000805160206143e783398151915281565b34801561079b57600080fd5b506102ca6127ee565b3480156107b057600080fd5b506102ca6107bf3660046139f7565b6128ef565b3480156107d057600080fd5b5061033f6107df366004613aa4565b6129c2565b3480156107f057600080fd5b5061033f60085481565b60006001600160e01b03198216637965db0b60e01b148061082b57506301ffc9a760e01b6001600160e01b03198316145b92915050565b600280540361085b5760405162461bcd60e51b815260040161085290613dfc565b60405180910390fd5b600280553361086b600082611b5c565b6108875760405162461bcd60e51b815260040161085290613e33565b6009548211156108d95760405162461bcd60e51b815260206004820152601c60248201527f5472616e7366657220616d6f756e7420697320746f6f206c61726765000000006044820152606401610852565b81600960008282546108eb9190613e77565b9091555050600d546040516001600160a01b0390911690600090829085908381818185875af1925050503d8060008114610941576040519150601f19603f3d011682016040523d82523d6000602084013e610946565b606091505b50509050806109975760405162461bcd60e51b815260206004820152601f60248201527f5472616e7366657248656c7065723a205452414e534645525f4641494c4544006044820152606401610852565b816001600160a01b03167fc9262544ea8cacb7a3eea4ea7b4023ea10ac8bc73701610edba13308190f9cb1856040516109d291815260200190565b60405180910390a2505060016002555050565b60015460ff1615610a085760405162461bcd60e51b815260040161085290613e8e565b6002805403610a295760405162461bcd60e51b815260040161085290613dfc565b60028055600f5460405163168a468560e11b8152600481018490526000916001600160a01b031690632d148d0a9060240161016060405180830381865afa158015610a78573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a9c9190613ec3565b9050600081602001516003811115610ab657610ab6613b99565b148015610ac35750805115155b610b075760405162461bcd60e51b815260206004820152601560248201527442657420697320746f6f206561726c792f6c61746560581b6044820152606401610852565b806101200151421115610b545760405162461bcd60e51b81526020600482015260156024820152741c9bdd5b9908185b1c9958591e481cdd185c9d1959605a1b6044820152606401610852565b600854341015610b765760405162461bcd60e51b815260040161085290613f5d565b600f5460405163ec4773a760e01b815260048101859052346024820181905260016044830152916001600160a01b03169063ec4773a790606401600060405180830381600087803b158015610bca57600080fd5b505af1158015610bde573d6000803e3d6000fd5b5050600f54604051630736449d60e11b8152600481018890526001600160a01b038781166024830152600094509091169150630e6c893a90604401606060405180830381865afa158015610c36573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c5a9190613fa9565b8051909150158015610c6e57506020810151155b15610cda57600f54604051634a966a1b60e01b81526001600160a01b0386811660048301526024820188905290911690634a966a1b90604401600060405180830381600087803b158015610cc157600080fd5b505af1158015610cd5573d6000803e3d6000fd5b505050505b600f546040516331e1f08360e11b815260048101849052602481018790526001600160a01b03868116604483015260016064830152909116906363c3e10690608401600060405180830381600087803b158015610d3657600080fd5b505af1158015610d4a573d6000803e3d6000fd5b5050505084846001600160a01b03167f0bab430d5cfc26b856f9867d7019c5af92e6fb9f0eef60afadab9f0d53ff1fd334604051610d8a91815260200190565b60405180910390a350506001600255505050565b600082815260208190526040902060010154610dba8133612b48565b610dc48383612bac565b505050565b60015460ff1615610dec5760405162461bcd60e51b815260040161085290613e8e565b33610e056000805160206143e783398151915282611b5c565b610e215760405162461bcd60e51b815260040161085290614005565b600654610100900460ff1615610e885760405162461bcd60e51b815260206004820152602660248201527f43616e206f6e6c792072756e20726f756e647a65726f437265617465526f756e60448201526564206f6e636560d01b6064820152608401610852565b600354610e9690600161403c565b60038190556005839055610eaa9083612c30565b6006805461ff001916610100179055600354610ee090610ecb90600161403c565b600454600554610edb919061403c565b612c30565b610f0d6003546002610ef2919061403c565b600454600554610f0390829061403c565b610edb919061403c565b610f3c6003546003610f1f919061403c565b6004546005548190610f3290829061403c565b610f03919061403c565b5050565b6001600160a01b0381163314610fb05760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608401610852565b610f3c8282612dfc565b60015460ff16610fdc5760405162461bcd60e51b815260040161085290614054565b33610fe8600082611b5c565b6110045760405162461bcd60e51b815260040161085290613e33565b6000821161104c5760405162461bcd60e51b815260206004820152601560248201527404d757374206265207375706572696f7220746f203605c1b6044820152606401610852565b60088290556040518281527f06a2e1014d8503fc3c899acda61fc50ab1918a70e8f904759a1f72f03bbd9cda906020015b60405180910390a15050565b60028054036110aa5760405162461bcd60e51b815260040161085290613dfc565b60028055600f5460405163168a468560e11b8152600481018490526000916001600160a01b031690632d148d0a9060240161016060405180830381865afa1580156110f9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061111d9190613ec3565b905060038160200151600381111561113757611137613b99565b146111845760405162461bcd60e51b815260206004820152601c60248201527f55736572206e6f7420656c696769626c6520666f7220726566756e64000000006044820152606401610852565b600f54604051630736449d60e11b8152600481018590526001600160a01b0384811660248301526000921690630e6c893a90604401606060405180830381865afa1580156111d6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111fa9190613fa9565b9050600081602001518260000151611212919061403c565b90506000811561129e57600a805461122991614166565b6007546112369084614172565b6112409190614191565b905061124c8183613e77565b91506112588583612e61565b604080518381524260208201526001600160a01b0387169188917faba4210cad11f1112f31ba136a61cdc0f6ab4c2b478da8c93eec1d9769e97a89910160405180910390a35b80600960008282546112b0919061403c565b90915550506001600255505050505050565b60015460ff16156112e55760405162461bcd60e51b815260040161085290613e8e565b336112fe6000805160206143e783398151915282611b5c565b61131a5760405162461bcd60e51b815260040161085290614005565b600654610100900460ff1661138e5760405162461bcd60e51b815260206004820152603460248201527f43616e206f6e6c792072756e20616674657220726f756e647a65726f437265616044820152731d19549bdd5b99081a5cc81d1c9a59d9d95c995960621b6064820152608401610852565b60065460ff16156113ef5760405162461bcd60e51b815260206004820152602560248201527f43616e206f6e6c792072756e20726f756e647a65726f5374617274526f756e64604482015264206f6e636560d81b6064820152608401610852565b6005544210156114415760405162461bcd60e51b815260206004820152601d60248201527f526f756e642063616e6e6f742062652073746172746564206561726c790000006044820152606401610852565b600e54600b54600c546005546040516319f59e5f60e01b81526004810193909352602483019190915260448201526000916001600160a01b0316906319f59e5f906064016040805180830381865afa1580156114a1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114c591906141b3565b5090506114d460035482612f04565b50506006805460ff19166001179055565b60015460ff166115075760405162461bcd60e51b815260040161085290614054565b33611513600082611b5c565b61152f5760405162461bcd60e51b815260040161085290613e33565b60008211801561153f5750606482105b61158b5760405162461bcd60e51b815260206004820152601860248201527f54726561737572792066656520697320746f6f206869676800000000000000006044820152606401610852565b60078290556040518281527f938d9272b26145999fe14f6124b73f122e1e023fc5de069c74ade1254408a9769060200161107d565b6000805b8381101561169d57600f546000906001600160a01b0316630e6c893a8787858181106115f2576115f26141de565b90506020020135866040518363ffffffff1660e01b81526004016116299291909182526001600160a01b0316602082015260400190565b606060405180830381865afa158015611646573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061166a9190613fa9565b8051602082015191925061167d9161403c565b611687908461403c565b9250508080611695906141f4565b9150506115c4565b5082156116b1576116ae8382614191565b90505b9392505050565b60015460ff16156116db5760405162461bcd60e51b815260040161085290613e8e565b600654610100900460ff1680156116f4575060065460ff165b61174f5760405162461bcd60e51b815260206004820152602660248201527f43616e206f6e6c792072756e20616674657220726f756e647a65726f537461726044820152651d149bdd5b9960d21b6064820152608401610852565b600f5460035460405163168a468560e11b815260048101919091526000916001600160a01b031690632d148d0a9060240161016060405180830381865afa15801561179e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117c29190613ec3565b600f54600380549293506000926001600160a01b0390921691632d148d0a916117eb919061403c565b6040518263ffffffff1660e01b815260040161180991815260200190565b61016060405180830381865afa158015611827573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061184b9190613ec3565b600e54600b54600c546101408601516040516319f59e5f60e01b81526004810193909352602483019190915260448201529192506000916001600160a01b03909116906319f59e5f906064016040805180830381865afa1580156118b3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118d791906141b3565b5090506003836020015160038111156118f2576118f2613b99565b141580156118ff57508015155b1561192057611910600354826130d9565b61191b60035461329e565b611954565b60038360200151600381111561193857611938613b99565b14158015611944575080155b15611954576119546003546134f4565b61196c6003546001611966919061403c565b82612f04565b611989600354600461197e919061403c565b836101400151612c30565b60035461199790600161403c565b600355505050565b60015460ff16156119c25760405162461bcd60e51b815260040161085290613e8e565b336119ce600082611b5c565b6119ea5760405162461bcd60e51b815260040161085290613e33565b6119f2613665565b6003545b600f60009054906101000a90046001600160a01b03166001600160a01b03166311a8f4136040518163ffffffff1660e01b8152600401602060405180830381865afa158015611a49573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a6d919061420d565b8111611b1d57600f5460405163168a468560e11b8152600481018390526000916001600160a01b031690632d148d0a9060240161016060405180830381865afa158015611abe573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ae29190613ec3565b9050600381602001516003811115611afc57611afc613b99565b14611b0a57611b0a826134f4565b5080611b15816141f4565b9150506119f6565b507fa382c86dbb1fba726013556ec174337b8f9ddac70b97ddb00d2e79e8b565d4f5600354604051611b5191815260200190565b60405180910390a150565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b6002805403611ba65760405162461bcd60e51b815260040161085290613dfc565b600280556000805b86811015611f0957600f546000906001600160a01b0316632d148d0a8a8a85818110611bdc57611bdc6141de565b905060200201356040518263ffffffff1660e01b8152600401611c0191815260200190565b61016060405180830381865afa158015611c1f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c439190613ec3565b600f549091506000906001600160a01b0316630e6c893a8b8b86818110611c6c57611c6c6141de565b90506020020135876040518363ffffffff1660e01b8152600401611ca39291909182526001600160a01b0316602082015260400190565b606060405180830381865afa158015611cc0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ce49190613fa9565b9050600282602001516003811115611cfe57611cfe613b99565b14611d4b5760405162461bcd60e51b815260206004820152601e60248201527f526f756e64206e6f7420656c696769626c6520666f72207265776172647300006044820152606401610852565b6000826080015111611d965760405162461bcd60e51b8152602060048201526014602482015273139bc818995d1cc81a5b881d1a19481c9bdd5b9960621b6044820152606401610852565b8161010001518260e0015103611dfb57611daf826136d4565b611dfb5760405162461bcd60e51b815260206004820152601760248201527f4e6f7420656c696769626c6520666f7220726566756e640000000000000000006044820152606401610852565b611e0582826121a7565b15611ef4576000611e168383613704565b600f54845160405163720988c960e11b815260048101919091526001600160a01b0389811660248301526044820184905292935091169063e413119290606401600060405180830381600087803b158015611e7057600080fd5b505af1158015611e84573d6000803e3d6000fd5b505050508085611e94919061403c565b94508a8a85818110611ea857611ea86141de565b90506020020135866001600160a01b03167f34fcbac0073d7c3d388e51312faf357774904998eeb8fca628b9e6f65ee1cbf783604051611eea91815260200190565b60405180910390a3505b50508080611f01906141f4565b915050611bae565b50838015611f175750600081115b1561200d5760006040518060800160405280600081526020016004546002611f3f9190614172565b611f49904261403c565b8152644d4154494360d81b60208083019190915260409182018990526010548251630c44410b60e41b815284516004820152918401516024830152918301516044820152606083015160648201526001600160a01b03868116608483015260a4820188905292935091169063c44410b090849060c40160006040518083038185885af1158015611fdd573d6000803e3d6000fd5b50505050506040513d6000823e601f3d908101601f191682016040526120069190810190614226565b505061201d565b801561201d5761201d8282612e61565b505060016002555050505050565b33612037600082611b5c565b6120535760405162461bcd60e51b815260040161085290613e33565b6001600160a01b0382163b6120aa5760405162461bcd60e51b815260206004820152601960248201527f53776170706572206973206e6f74206120636f6e7472616374000000000000006044820152606401610852565b50601080546001600160a01b0319166001600160a01b0392909216919091179055565b61212b6040805161016081019091526000808252602082019081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b600f5460035460405163168a468560e11b81526001600160a01b0390921691632d148d0a916121609160040190815260200190565b61016060405180830381865afa15801561217e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121a29190613ec3565b905090565b80516000901515806121bc5750602082015115155b80156121ca57506040820151155b80156116b157508260e001518361010001511180156121e95750815115155b8061220a57508260e0015183610100015110801561220a5750602082015115155b806116b15750505060e0810151610100909101511490565b3361222e600082611b5c565b61224a5760405162461bcd60e51b815260040161085290613e33565b6001600160a01b0382163b6122a15760405162461bcd60e51b815260206004820152601960248201527f4e6f7420426861766973682041646d696e6973747261746f72000000000000006044820152606401610852565b50600d80546001600160a01b0319166001600160a01b0392909216919091179055565b336122d0600082611b5c565b6122ec5760405162461bcd60e51b815260040161085290613e33565b610f3c6000805160206143e783398151915283612423565b33612310600082611b5c565b61232c5760405162461bcd60e51b815260040161085290613e33565b6001600160a01b0382163b156123845760405162461bcd60e51b815260206004820152601d60248201527f4f70657261746f722063616e6e6f74206265206120636f6e74726163740000006044820152606401610852565b6001600160a01b0382166123d35760405162461bcd60e51b815260206004820152601660248201527543616e6e6f74206265207a65726f206164647265737360501b6044820152606401610852565b6123eb6000805160206143e783398151915283610d9e565b6040516001600160a01b038316907fda12ee837e6978172aaf54b16145ffe08414fd8710092ef033c71b8eb6ec189a90600090a25050565b60008281526020819052604090206001015461243f8133612b48565b610dc48383612dfc565b60015460ff161561246c5760405162461bcd60e51b815260040161085290613e8e565b600280540361248d5760405162461bcd60e51b815260040161085290613dfc565b60028055600f5460405163168a468560e11b8152600481018490526000916001600160a01b031690632d148d0a9060240161016060405180830381865afa1580156124dc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125009190613ec3565b905080610120015142111561254f5760405162461bcd60e51b81526020600482015260156024820152741c9bdd5b9908185b1c9958591e481cdd185c9d1959605a1b6044820152606401610852565b60008160200151600381111561256757612567613b99565b1480156125745750805115155b6125b85760405162461bcd60e51b815260206004820152601560248201527442657420697320746f6f206561726c792f6c61746560581b6044820152606401610852565b6008543410156125da5760405162461bcd60e51b815260040161085290613f5d565b600f5460405163ec4773a760e01b815260048101859052346024820181905260006044830152916001600160a01b03169063ec4773a790606401600060405180830381600087803b15801561262e57600080fd5b505af1158015612642573d6000803e3d6000fd5b5050600f54604051630736449d60e11b8152600481018890526001600160a01b038781166024830152600094509091169150630e6c893a90604401606060405180830381865afa15801561269a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126be9190613fa9565b80519091501580156126d257506020810151155b1561273e57600f54604051634a966a1b60e01b81526001600160a01b0386811660048301526024820188905290911690634a966a1b90604401600060405180830381600087803b15801561272557600080fd5b505af1158015612739573d6000803e3d6000fd5b505050505b600f546040516331e1f08360e11b815260048101849052602481018790526001600160a01b03868116604483015260006064830152909116906363c3e10690608401600060405180830381600087803b15801561279a57600080fd5b505af11580156127ae573d6000803e3d6000fd5b5050505084846001600160a01b03167f546f54506a25044de11c4fb0c44fbd0137d87d7e08dfd800944453931428a5ea34604051610d8a91815260200190565b60015460ff166128105760405162461bcd60e51b815260040161085290614054565b3361281c600082611b5c565b6128385760405162461bcd60e51b815260040161085290613e33565b6006805461ffff19169055600f54604080516311a8f41360e01b815290516001600160a01b03909216916311a8f413916004808201926020929091908290030181865afa15801561288d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128b1919061420d565b6003556128bc6137de565b7f0b0e422893e2219d69c6fba12911d3b270235e96e9753519998fc13013ebb2ae600354604051611b5191815260200190565b60015460ff166129115760405162461bcd60e51b815260040161085290614054565b3361292a6000805160206143e783398151915282611b5c565b6129465760405162461bcd60e51b815260040161085290614005565b8160001080156129595750620151808211155b6129bc5760405162461bcd60e51b815260206004820152602e60248201527f526f756e642054696d652073686f756c64206265206265747765656e2031207360448201526d656320746f20333630302073656360901b6064820152608401610852565b50600455565b600080805b84811015612b3f57600f546000906001600160a01b0316632d148d0a8888858181106129f5576129f56141de565b905060200201356040518263ffffffff1660e01b8152600401612a1a91815260200190565b61016060405180830381865afa158015612a38573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a5c9190613ec3565b600f549091506000906001600160a01b0316630e6c893a898986818110612a8557612a856141de565b90506020020135886040518363ffffffff1660e01b8152600401612abc9291909182526001600160a01b0316602082015260400190565b606060405180830381865afa158015612ad9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612afd9190613fa9565b9050612b0982826121a7565b612b14575050612b2d565b612b1e8282613704565b612b28908561403c565b935050505b80612b37816141f4565b9150506129c7565b50949350505050565b612b528282611b5c565b610f3c57612b6a816001600160a01b03166014613831565b612b75836020613831565b604051602001612b869291906142fc565b60408051601f198184030181529082905262461bcd60e51b825261085291600401614371565b612bb68282611b5c565b610f3c576000828152602081815260408083206001600160a01b03851684529091529020805460ff19166001179055612bec3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b600f5460405163168a468560e11b8152600481018490526000916001600160a01b031690632d148d0a9060240161016060405180830381865afa158015612c7b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c9f9190613ec3565b805190915015612ce85760405162461bcd60e51b8152602060048201526014602482015273526f756e6420616c72656164792065786973747360601b6044820152606401610852565b4260045483612cf79190613e77565b1015612d455760405162461bcd60e51b815260206004820152601760248201527f526f756e642074696d6520697320746f6f2073686f72740000000000000000006044820152606401610852565b8281526101208101829052600454612d5d908361403c565b61014082015260006020820152600f5460405163ad0197db60e01b81526001600160a01b039091169063ad0197db90612d9a908490600401613bd1565b600060405180830381600087803b158015612db457600080fd5b505af1158015612dc8573d6000803e3d6000fd5b50506040518592507f257b6e0c207001c05b4f0f88a5bc913e2c47513ab9989881a48ceea263b2a7219150600090a2505050565b612e068282611b5c565b15610f3c576000828152602081815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114612eae576040519150601f19603f3d011682016040523d82523d6000602084013e612eb3565b606091505b5050905080610dc45760405162461bcd60e51b815260206004820152601f60248201527f5472616e7366657248656c7065723a205452414e534645525f4641494c4544006044820152606401610852565b600f5460405163168a468560e11b8152600481018490526000916001600160a01b031690632d148d0a9060240161016060405180830381865afa158015612f4f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f739190613ec3565b905081600003612f8657610dc4836134f4565b600081602001516003811115612f9e57612f9e613b99565b14612feb5760405162461bcd60e51b815260206004820152601760248201527f526f756e642073686f756c6420626520637265617465640000000000000000006044820152606401610852565b4281610120015111156130405760405162461bcd60e51b815260206004820152601c60248201527f546f6f206561726c7920746f2073746172742074686520726f756e64000000006044820152606401610852565b600f546040516352f3e91960e01b81526001600160a01b03909116906352f3e91990613077908690600190879082906004016143a4565b600060405180830381600087803b15801561309157600080fd5b505af11580156130a5573d6000803e3d6000fd5b50506040518592507f939f42374aa9bf1d8d8cd56d8a9110cb040cd8dfeae44080c6fcf2645e51b4529150600090a2505050565b600f5460405163168a468560e11b8152600481018490526000916001600160a01b031690632d148d0a9060240161016060405180830381865afa158015613124573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131489190613ec3565b905060018160200151600381111561316257613162613b99565b146131af5760405162461bcd60e51b815260206004820152601860248201527f526f756e64206973206e6f7420737461727465642079657400000000000000006044820152606401610852565b4281610140015111156132045760405162461bcd60e51b815260206004820152601a60248201527f546f6f206561726c7920746f20656e642074686520726f756e640000000000006044820152606401610852565b600f546040516352f3e91960e01b81526001600160a01b03909116906352f3e9199061323c90869060029087906000906004016143a4565b600060405180830381600087803b15801561325657600080fd5b505af115801561326a573d6000803e3d6000fd5b50506040518592507f2c46d8d5cabadbc3b7c8644a09e45c97988bd5ee29b298d282a7ef8c1833d9129150600090a2505050565b600f5460405163168a468560e11b8152600481018390526000916001600160a01b031690632d148d0a9060240161016060405180830381865afa1580156132e9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061330d9190613ec3565b905060028160200151600381111561332757613327613b99565b146133695760405162461bcd60e51b8152602060048201526012602482015271149bdd5b99081a5cc81b9bdd08195b99195960721b6044820152606401610852565b6000806000600a54600a61337d9190614166565b600754856080015161338f9190614172565b6133999190614191565b91508360e0015184610100015111156133dc57836040015192508184608001516133c39190613e77565b9050826000036133d7575050606082015160005b613423565b8360e00151846101000151101561341c57836060015192508184608001516134049190613e77565b9050826000036133d757505060408201516000613423565b5060009150815b8160096000828254613435919061403c565b9091555050600f5460405163ddae3a7160e01b81526004810187905260248101839052604481018590526001600160a01b039091169063ddae3a7190606401600060405180830381600087803b15801561348e57600080fd5b505af11580156134a2573d6000803e3d6000fd5b50506009546040805187815260208101869052908101919091528792507f6dfdfcb09c8804d0058826cd2539f1acfbe3cb887c9be03d928035bce0f1a58d915060600160405180910390a25050505050565b600f5460405163168a468560e11b8152600481018390526000916001600160a01b031690632d148d0a9060240161016060405180830381865afa15801561353f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135639190613ec3565b905060038160200151600381111561357d5761357d613b99565b036135d85760405162461bcd60e51b815260206004820152602560248201527f43616e6e6f742063616e63656c20616c72656164792063616e63656c6c6564206044820152641c9bdd5b9960da1b6064820152608401610852565b600f54604051637e07ab0960e01b8152600481018490526001600160a01b0390911690637e07ab0990602401600060405180830381600087803b15801561361e57600080fd5b505af1158015613632573d6000803e3d6000fd5b50506040518492507f1316afc2a7dc68d55247ceedbef28ffd97f61bafc159c949278f4b934d448c7b9150600090a25050565b60015460ff16156136885760405162461bcd60e51b815260040161085290613e8e565b6001805460ff1916811790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258335b6040516001600160a01b03909116815260200160405180910390a1565b60008160a0015160001480156136ec575060c0820151155b801561082b57505061010081015160e0909101511490565b60008260e00151836101000151036137725761371f836136d4565b1561376d57602082015182516000916137379161403c565b9050600a54600a6137489190614166565b6007546137559083614172565b61375f9190614191565b6137699082613e77565b9150505b61082b565b8260e0015183610100015111156137aa5760a083015160c084015183516137999190614172565b6137a39190614191565b905061082b565b8260e00151836101000151101561082b578260a001518360c0015183602001516137d49190614172565b6116b19190614191565b60015460ff166138005760405162461bcd60e51b815260040161085290614054565b6001805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa336136b7565b60606000613840836002614172565b61384b90600261403c565b67ffffffffffffffff81111561386357613863613c54565b6040519080825280601f01601f19166020018201604052801561388d576020820181803683370190505b509050600360fc1b816000815181106138a8576138a86141de565b60200101906001600160f81b031916908160001a905350600f60fb1b816001815181106138d7576138d76141de565b60200101906001600160f81b031916908160001a90535060006138fb846002614172565b61390690600161403c565b90505b600181111561397e576f181899199a1a9b1b9c1cb0b131b232b360811b85600f166010811061393a5761393a6141de565b1a60f81b828281518110613950576139506141de565b60200101906001600160f81b031916908160001a90535060049490941c93613977816143cf565b9050613909565b5083156116b15760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610852565b6000602082840312156139df57600080fd5b81356001600160e01b0319811681146116b157600080fd5b600060208284031215613a0957600080fd5b5035919050565b6001600160a01b0381168114613a2557600080fd5b50565b60008060408385031215613a3b57600080fd5b823591506020830135613a4d81613a10565b809150509250929050565b60008083601f840112613a6a57600080fd5b50813567ffffffffffffffff811115613a8257600080fd5b6020830191508360208260051b8501011115613a9d57600080fd5b9250929050565b600080600060408486031215613ab957600080fd5b833567ffffffffffffffff811115613ad057600080fd5b613adc86828701613a58565b9094509250506020840135613af081613a10565b809150509250925092565b60008060008060008060a08789031215613b1457600080fd5b863567ffffffffffffffff811115613b2b57600080fd5b613b3789828a01613a58565b9097509550506020870135935060408701358015158114613b5757600080fd5b9250606087013591506080870135613b6e81613a10565b809150509295509295509295565b600060208284031215613b8e57600080fd5b81356116b181613a10565b634e487b7160e01b600052602160045260246000fd5b60048110613bcd57634e487b7160e01b600052602160045260246000fd5b9052565b81518152602080830151610160830191613bed90840182613baf565b5060408301516040830152606083015160608301526080830151608083015260a083015160a083015260c083015160c083015260e083015160e083015261010080840151818401525061012080840151818401525061014080840151818401525092915050565b634e487b7160e01b600052604160045260246000fd5b604051610160810167ffffffffffffffff81118282101715613c8e57613c8e613c54565b60405290565b604051601f8201601f1916810167ffffffffffffffff81118282101715613cbd57613cbd613c54565b604052919050565b60048110613a2557600080fd5b8035613cdd81613cc5565b919050565b600060608284031215613cf457600080fd5b6040516060810181811067ffffffffffffffff82111715613d1757613d17613c54565b80604052508091508235815260208301356020820152604083013560408201525092915050565b6000808284036101c0811215613d5357600080fd5b61016080821215613d6357600080fd5b613d6b613c6a565b915084358252613d7d60208601613cd2565b602083015260408501356040830152606085013560608301526080850135608083015260a085013560a083015260c085013560c083015260e085013560e0830152610100808601358184015250610120808601358184015250610140808601358184015250819350613df186828701613ce2565b925050509250929050565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b60208082526014908201527320b2323932b9b9903737ba1030b71030b236b4b760611b604082015260600190565b634e487b7160e01b600052601160045260246000fd5b600082821015613e8957613e89613e61565b500390565b60208082526010908201526f14185d5cd8589b194e881c185d5cd95960821b604082015260600190565b8051613cdd81613cc5565b60006101608284031215613ed657600080fd5b613ede613c6a565b82518152613eee60208401613eb8565b602082015260408301516040820152606083015160608201526080830151608082015260a083015160a082015260c083015160c082015260e083015160e08201526101008084015181830152506101208084015181830152506101408084015181830152508091505092915050565b6020808252602c908201527f42657420616d6f756e74206d7573742062652067726561746572207468616e2060408201526b1b5a5b90995d105b5bdd5b9d60a21b606082015260800190565b600060608284031215613fbb57600080fd5b6040516060810181811067ffffffffffffffff82111715613fde57613fde613c54565b80604052508251815260208301516020820152604083015160408201528091505092915050565b60208082526017908201527f41646472657373206e6f7420616e206f70657261746f72000000000000000000604082015260600190565b6000821982111561404f5761404f613e61565b500190565b60208082526014908201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604082015260600190565b600181815b808511156140bd5781600019048211156140a3576140a3613e61565b808516156140b057918102915b93841c9390800290614087565b509250929050565b6000826140d45750600161082b565b816140e15750600061082b565b81600181146140f757600281146141015761411d565b600191505061082b565b60ff84111561411257614112613e61565b50506001821b61082b565b5060208310610133831016604e8410600b8410161715614140575081810a61082b565b61414a8383614082565b806000190482111561415e5761415e613e61565b029392505050565b60006116b183836140c5565b600081600019048311821515161561418c5761418c613e61565b500290565b6000826141ae57634e487b7160e01b600052601260045260246000fd5b500490565b600080604083850312156141c657600080fd5b82519150602083015160ff81168114613a4d57600080fd5b634e487b7160e01b600052603260045260246000fd5b60006001820161420657614206613e61565b5060010190565b60006020828403121561421f57600080fd5b5051919050565b6000602080838503121561423957600080fd5b825167ffffffffffffffff8082111561425157600080fd5b818501915085601f83011261426557600080fd5b81518181111561427757614277613c54565b8060051b9150614288848301613c94565b81815291830184019184810190888411156142a257600080fd5b938501935b838510156142c0578451825293850193908501906142a7565b98975050505050505050565b60005b838110156142e75781810151838201526020016142cf565b838111156142f6576000848401525b50505050565b7f416363657373436f6e74726f6c3a206163636f756e74200000000000000000008152600083516143348160178501602088016142cc565b7001034b99036b4b9b9b4b733903937b6329607d1b60179184019182015283516143658160288401602088016142cc565b01602801949350505050565b60208152600082518060208401526143908160408501602087016142cc565b601f01601f19169190910160400192915050565b848152608081016143b86020830186613baf565b836040830152821515606083015295945050505050565b6000816143de576143de613e61565b50600019019056fe97667070c54ef182b0f5858b034beac1b6f3089aa2d3188bb1e8929f4fa9b929a264697066735822122067272c459123230fcc94ecf4ceb4e39e0b040bd429b781b1803167a49d50b3e864736f6c634300080d0033

Block Transaction Gas Used Reward
view all blocks produced

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

Validator Index Block Amount
View All Withdrawals

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

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