Contract 0x186927cedfd25663b41a45cf47db2db0f955bf65 7

 
 
Txn Hash
Method
Block
From
To
Value [Txn Fee]
0xfee8ec3318f7e6dfa702fd45cc89351715ce6e69404322b479e4e515e8f7b13dClaim458941762023-08-04 9:45:1260 days 8 hrs ago0x9db410b05018b37d8411fed70616675f3b7d8d8f IN  0x186927cedfd25663b41a45cf47db2db0f955bf650 MATIC0.0079820083 82.1
0x9047ca9e2be739127ba4c409cbaf97e18c314b46ab8ce79ae50df04c067e14d0Claim458940582023-08-04 9:41:0060 days 8 hrs ago0x9db410b05018b37d8411fed70616675f3b7d8d8f IN  0x186927cedfd25663b41a45cf47db2db0f955bf650 MATIC0.0084875679 87.3
0x53b4f95846e8cdfdb515e85345406afc5ec09d80a7a34670d9edc0f6229e7b86Start Prediction...436053132023-06-06 17:57:25119 days 8 mins ago0x9728f7772f95a7346c22c831ff6bac565662d8da IN  0x186927cedfd25663b41a45cf47db2db0f955bf650 MATIC0.006025744737 213.262953016
0x2781c2556a39dafa40733022b2bf02412b35ec1a2b661e58388bc2ba1fd76f7bStart Prediction...436053132023-06-06 17:57:25119 days 8 mins ago0x9728f7772f95a7346c22c831ff6bac565662d8da IN  0x186927cedfd25663b41a45cf47db2db0f955bf650 MATIC0.006025744737 213.262953016
0xbccc1a9ac190784bcf10d94b8552e4a22449ae64560d5925da0c677fca6d1608Refund Users435699392023-06-05 20:14:36119 days 21 hrs ago0xb7e1986efe285e5b6134fc2e47093f428855d267 IN  0x186927cedfd25663b41a45cf47db2db0f955bf650 MATIC0.018034302 171.6
0x6432ff5bc980bc9a167daf92d72e6377ee27ed19d8f367afc646d24028947204Refund Users435699112023-06-05 20:13:36119 days 21 hrs ago0xb7e1986efe285e5b6134fc2e47093f428855d267 IN  0x186927cedfd25663b41a45cf47db2db0f955bf650 MATIC0.0181459575 148.5
0xfe9478137d6490ee313620d6a826674f6cc853490bb6db08167b41984de00b41Transfer To Admi...428085972023-05-17 8:49:10139 days 9 hrs ago0x9728f7772f95a7346c22c831ff6bac565662d8da IN  0x186927cedfd25663b41a45cf47db2db0f955bf650 MATIC0.0794022,000
0x3474de494095abb6c22762e0fcbda61625c9de3ee7d245d956603c4c4fd641bbClaim425321892023-05-10 11:35:56146 days 6 hrs ago0x07eb23ec32473986b51f3b0f25286389f67c8628 IN  0x186927cedfd25663b41a45cf47db2db0f955bf650 MATIC0.0179959773 185.1
0xc35dee957597f33746ad6f2d15a075e2f71a9c28d0ea98ef2802e62d187c605dClaim425175992023-05-10 2:58:30146 days 15 hrs ago0xe59ffea75484ce9191f5a29b1390db471a08a517 IN  0x186927cedfd25663b41a45cf47db2db0f955bf650 MATIC0.0150138244 154.6
0xadb086bd1802a905db50c42e52e3ae0b4cafe5a6cbb21ab45bb2cf954435e4a6Claim425071012023-05-09 20:41:54146 days 21 hrs ago0x07eb23ec32473986b51f3b0f25286389f67c8628 IN  0x186927cedfd25663b41a45cf47db2db0f955bf650 MATIC0.0137181653 141.1
0xb2ed12a25450287afe35beca4d18c6dae345dbd47ae7739046a793d1fef4385fClaim424584422023-05-08 15:34:04148 days 2 hrs ago0x07eb23ec32473986b51f3b0f25286389f67c8628 IN  0x186927cedfd25663b41a45cf47db2db0f955bf650 MATIC0.0180640334 185.8
0x32d35738fe0a3a73d070d7bd9af5b6d2ab0f38ebfe047e132ac3383ae496ceeaTransfer To Admi...424438682023-05-08 6:51:56148 days 11 hrs ago0x9728f7772f95a7346c22c831ff6bac565662d8da IN  0x186927cedfd25663b41a45cf47db2db0f955bf650 MATIC0.0794022,000
0x561eb56a42639f947e3354d20e23070ef5a83cdf408c77c0af27dd6415673c85Claim424432322023-05-08 6:29:16148 days 11 hrs ago0x07eb23ec32473986b51f3b0f25286389f67c8628 IN  0x186927cedfd25663b41a45cf47db2db0f955bf650 MATIC0.0173445832 178.4
0xa5be6764ec7cdf31da2feb76f2917a23feeeafbd1af4865e9b981c429c0cc0e6Transfer To Admi...424366472023-05-08 2:34:46148 days 15 hrs ago0x9728f7772f95a7346c22c831ff6bac565662d8da IN  0x186927cedfd25663b41a45cf47db2db0f955bf650 MATIC0.0794022,000
0xecd2788e6b5a621777dffa3bbbf903e62dea5a0e0c40c271832f40956efbc835Claim424291132023-05-07 21:57:06148 days 20 hrs ago0x07eb23ec32473986b51f3b0f25286389f67c8628 IN  0x186927cedfd25663b41a45cf47db2db0f955bf650 MATIC0.0141883554 146.1
0xf8c4afcb921e53a4c3a2b51bd501ac81a85faa6fdf47e346a181fa5f5be29da0Claim424245712023-05-07 19:03:44148 days 23 hrs ago0x07eb23ec32473986b51f3b0f25286389f67c8628 IN  0x186927cedfd25663b41a45cf47db2db0f955bf650 MATIC0.0275529982 283.4
0xbd66218a9147273e5c013b97e5c738644a45bc8afcde22a79ef241ef9fcbfd69Claim424186292023-05-07 15:19:40149 days 2 hrs ago0x6cf79ef2c75600c6725f7d5e08726af70f036a63 IN  0x186927cedfd25663b41a45cf47db2db0f955bf650 MATIC0.020871061058 214.93955901
0xc722ce8a3b779b353155b6f840af37e27b7342b94dd742f53f3e40f56b51f274Claim424141352023-05-07 12:32:45149 days 5 hrs ago0x6cf79ef2c75600c6725f7d5e08726af70f036a63 IN  0x186927cedfd25663b41a45cf47db2db0f955bf650 MATIC0.026594508604 273.882191967
0xbf9f9bd733a393954d19cc8d454383133f9582f47718fda691937c6b77721dbcClaim423981892023-05-07 3:01:40149 days 15 hrs ago0x3c442fefacfc05f1002399989d3928cf5bf07328 IN  0x186927cedfd25663b41a45cf47db2db0f955bf650 MATIC0.034924331743359.351885986
0xf5de40924e37bcbfefe66c4ba4c5405f78b0e6ffea3924dccc8f4b88f86f8512Claim423981872023-05-07 3:01:36149 days 15 hrs ago0x68853f1f5c1c3d20a7ae5f067157b45cde6265ff IN  0x186927cedfd25663b41a45cf47db2db0f955bf650 MATIC0.036115064767371.557986892
0x33bbf90ce824d9ae7d48a4b37351494537929c134d07a0eea110442039d35550Claim423981852023-05-07 3:01:32149 days 15 hrs ago0x1e8c2ae04aa4353180afa155f4f7454121079c83 IN  0x186927cedfd25663b41a45cf47db2db0f955bf650 MATIC0.035706444022367.42963009
0xbce3e2eab69c994e030d339bc98d01b2c518e4e4def7b1b46b3a042880eaa87cClaim423981812023-05-07 3:01:24149 days 15 hrs ago0xcbb6ad674b7c7e6d4506f1cec12af855c6c4c999 IN  0x186927cedfd25663b41a45cf47db2db0f955bf650 MATIC0.035791756032368.645133716
0x052dff237fa0a739033ff6d8bc4770d608f17d20f6867386f1e0d21e9595f716Transfer To Admi...423981772023-05-07 3:01:16149 days 15 hrs ago0x9728f7772f95a7346c22c831ff6bac565662d8da IN  0x186927cedfd25663b41a45cf47db2db0f955bf650 MATIC0.0794262,000
0x8fa1081472c9c59ed1eb4613cce7323bb021dc09d5fee2d6108be83c0e00f0a1Claim423353332023-05-05 13:00:50151 days 5 hrs ago0x3c442fefacfc05f1002399989d3928cf5bf07328 IN  0x186927cedfd25663b41a45cf47db2db0f955bf650 MATIC0.056949403762586.635527742
0xe10bb8b905ad3a4a755c8be9c43a7146a52f91d3584308c63354251e335fb338Claim423353312023-05-05 13:00:46151 days 5 hrs ago0xd65b634fc09e5e5fe10adcf77772fc282c3857b1 IN  0x186927cedfd25663b41a45cf47db2db0f955bf650 MATIC0.055001934406566.504628758
[ Download CSV Export 
Latest 25 internal transaction
Parent Txn Hash Block From To Value
0xfee8ec3318f7e6dfa702fd45cc89351715ce6e69404322b479e4e515e8f7b13d458941762023-08-04 9:45:1260 days 8 hrs ago 0x186927cedfd25663b41a45cf47db2db0f955bf650x9db410b05018b37d8411fed70616675f3b7d8d8f1.970139892911169251 MATIC
0x9047ca9e2be739127ba4c409cbaf97e18c314b46ab8ce79ae50df04c067e14d0458940582023-08-04 9:41:0060 days 8 hrs ago 0x186927cedfd25663b41a45cf47db2db0f955bf650x9db410b05018b37d8411fed70616675f3b7d8d8f1.974101321451947941 MATIC
0xbccc1a9ac190784bcf10d94b8552e4a22449ae64560d5925da0c677fca6d1608435699392023-06-05 20:14:36119 days 21 hrs ago 0x186927cedfd25663b41a45cf47db2db0f955bf650xb7e1986efe285e5b6134fc2e47093f428855d2672.25225 MATIC
0x6432ff5bc980bc9a167daf92d72e6377ee27ed19d8f367afc646d24028947204435699112023-06-05 20:13:36119 days 21 hrs ago 0x186927cedfd25663b41a45cf47db2db0f955bf650xb7e1986efe285e5b6134fc2e47093f428855d2676.34725 MATIC
0xfe9478137d6490ee313620d6a826674f6cc853490bb6db08167b41984de00b41428085972023-05-17 8:49:10139 days 9 hrs ago 0x186927cedfd25663b41a45cf47db2db0f955bf65 0xf957700b17443b34debcc4343a1d82834f80351818.438791131240495897 MATIC
0xede67b53eaedfb791b8b9a342bae0cd143a2d125e38d99f1789cec0156ee6987425650172023-05-11 7:03:08145 days 11 hrs ago 0x4e60a426ea122cb35c35fbda9f5f732995b9e226 0x186927cedfd25663b41a45cf47db2db0f955bf652 MATIC
0x8d7204b78933637f4cbf77903a14183d904aecee292d8c718c492201744d9e2f425516242023-05-10 23:06:02145 days 18 hrs ago 0x4e60a426ea122cb35c35fbda9f5f732995b9e226 0x186927cedfd25663b41a45cf47db2db0f955bf652 MATIC
0x3474de494095abb6c22762e0fcbda61625c9de3ee7d245d956603c4c4fd641bb425321892023-05-10 11:35:56146 days 6 hrs ago 0x186927cedfd25663b41a45cf47db2db0f955bf650x07eb23ec32473986b51f3b0f25286389f67c86283.16875 MATIC
0xb358a6cb1c3b74823c6317facd46fc0f3720d5b77b160ca898a94ee17f81de40425256652023-05-10 7:44:40146 days 10 hrs ago 0x4e60a426ea122cb35c35fbda9f5f732995b9e226 0x186927cedfd25663b41a45cf47db2db0f955bf653.25 MATIC
0x13f93676aca13cdf8ccb300a6a7a0e106e1f570af54e1a72f8e57859c4c45265425178822023-05-10 3:08:32146 days 14 hrs ago 0x4e60a426ea122cb35c35fbda9f5f732995b9e226 0x186927cedfd25663b41a45cf47db2db0f955bf650.81915985542517457 MATIC
0x13f93676aca13cdf8ccb300a6a7a0e106e1f570af54e1a72f8e57859c4c45265425178822023-05-10 3:08:32146 days 14 hrs ago 0x4e60a426ea122cb35c35fbda9f5f732995b9e226 0x186927cedfd25663b41a45cf47db2db0f955bf650.81915985542517457 MATIC
0xc35dee957597f33746ad6f2d15a075e2f71a9c28d0ea98ef2802e62d187c605d425175992023-05-10 2:58:30146 days 15 hrs ago 0x186927cedfd25663b41a45cf47db2db0f955bf650xe59ffea75484ce9191f5a29b1390db471a08a5172.406626951572902643 MATIC
0x24726ce7429a94ef09b15c894a31dbd97aaeff1ca49006a26ca66ad61292487d425170362023-05-10 2:38:34146 days 15 hrs ago 0x186927cedfd25663b41a45cf47db2db0f955bf65 0x4125d4ea54b562a4dad8488b425de8b8c1054ac011.863839145814372339 MATIC
0x24726ce7429a94ef09b15c894a31dbd97aaeff1ca49006a26ca66ad61292487d425170362023-05-10 2:38:34146 days 15 hrs ago 0x4e60a426ea122cb35c35fbda9f5f732995b9e226 0x186927cedfd25663b41a45cf47db2db0f955bf655.191041218367986325 MATIC
0x24726ce7429a94ef09b15c894a31dbd97aaeff1ca49006a26ca66ad61292487d425170362023-05-10 2:38:34146 days 15 hrs ago 0x4e60a426ea122cb35c35fbda9f5f732995b9e226 0x186927cedfd25663b41a45cf47db2db0f955bf655.191041218367986325 MATIC
0xb80f024aa7254dc348195fe93e0868de17617518ac505da57cd73a9d349e19df425161892023-05-10 2:08:34146 days 15 hrs ago 0x4e60a426ea122cb35c35fbda9f5f732995b9e226 0x186927cedfd25663b41a45cf47db2db0f955bf650.8244438136571529 MATIC
0xb80f024aa7254dc348195fe93e0868de17617518ac505da57cd73a9d349e19df425161892023-05-10 2:08:34146 days 15 hrs ago 0x4e60a426ea122cb35c35fbda9f5f732995b9e226 0x186927cedfd25663b41a45cf47db2db0f955bf650.8244438136571529 MATIC
0x44727b3143ea000e2692e775a8b36de4ef88945fb4ead4fd22331d91ec88ef03425153412023-05-10 1:38:32146 days 16 hrs ago 0x186927cedfd25663b41a45cf47db2db0f955bf65 0x4125d4ea54b562a4dad8488b425de8b8c1054ac011.93772873969954248 MATIC
0x44727b3143ea000e2692e775a8b36de4ef88945fb4ead4fd22331d91ec88ef03425153412023-05-10 1:38:32146 days 16 hrs ago 0x4e60a426ea122cb35c35fbda9f5f732995b9e226 0x186927cedfd25663b41a45cf47db2db0f955bf655.222774610268867055 MATIC
0x44727b3143ea000e2692e775a8b36de4ef88945fb4ead4fd22331d91ec88ef03425153412023-05-10 1:38:32146 days 16 hrs ago 0x4e60a426ea122cb35c35fbda9f5f732995b9e226 0x186927cedfd25663b41a45cf47db2db0f955bf655.222774610268867055 MATIC
0xaf6c676c7296880f398492dd92b9c8873b832237bde44d731d32aa3da46c111d425144982023-05-10 1:08:34146 days 16 hrs ago 0x4e60a426ea122cb35c35fbda9f5f732995b9e226 0x186927cedfd25663b41a45cf47db2db0f955bf650.828994941082209913 MATIC
0xaf6c676c7296880f398492dd92b9c8873b832237bde44d731d32aa3da46c111d425144982023-05-10 1:08:34146 days 16 hrs ago 0x4e60a426ea122cb35c35fbda9f5f732995b9e226 0x186927cedfd25663b41a45cf47db2db0f955bf650.828994941082209913 MATIC
0x608977e29cf28d077b7377ada6e3f361a23036f66a1ef8ea62598c060aa8cd3b425136512023-05-10 0:38:34146 days 17 hrs ago 0x186927cedfd25663b41a45cf47db2db0f955bf65 0x4125d4ea54b562a4dad8488b425de8b8c1054ac012.008778305476539532 MATIC
0x608977e29cf28d077b7377ada6e3f361a23036f66a1ef8ea62598c060aa8cd3b425136512023-05-10 0:38:34146 days 17 hrs ago 0x4e60a426ea122cb35c35fbda9f5f732995b9e226 0x186927cedfd25663b41a45cf47db2db0f955bf655.255025133694391286 MATIC
0x608977e29cf28d077b7377ada6e3f361a23036f66a1ef8ea62598c060aa8cd3b425136512023-05-10 0:38:34146 days 17 hrs ago 0x4e60a426ea122cb35c35fbda9f5f732995b9e226 0x186927cedfd25663b41a45cf47db2db0f955bf655.255025133694391286 MATIC
[ Download CSV Export 
Loading

Similar Match Source Code
This contract matches the deployed ByteCode of the Source Code for Contract 0xb731EBF5D9D246aDe7135972A54af505DAD31827
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 25 : 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;
    address public bhavishSDK;

    // 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 NewBhvaishSDK(address indexed _sdk);
    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");
        _;
    }

    modifier validateUser(address _userAddress) {
        if (msg.sender != _userAddress) {
            require(msg.sender == bhavishSDK, "Invalid Caller");
        }
        _;
    }

    // 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 Bhavish SDK
     * @dev Callable by admin
     * @param _sdk new _sdk
     */
    function setBhavishSDK(address _sdk) external onlyAdmin(msg.sender) {
        require(_sdk.isContract(), "invalid address");
        bhavishSDK = _sdk;

        emit NewBhvaishSDK(_sdk);
    }

    /**
     * @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 validateUser(userAddress) {
        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);
        require(betInfo.amountDispersed == 0, "Refund already claimed");
        uint256 amtInvested = betInfo.upPredictAmount + betInfo.downPredictAmount;
        uint256 tresFeeAmount = 0;
        if (amtInvested > 0) {
            tresFeeAmount = (amtInvested * treasuryFee) / 10**decimals;
            amtInvested -= tresFeeAmount;
            bhavishPredictionStorage.setBetAmountDispersed(_predictRoundId, userAddress, amtInvested);
            _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 25 : Pausable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (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 Modifier to make a function callable only when the contract is not paused.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    modifier whenNotPaused() {
        _requireNotPaused();
        _;
    }

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

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

    /**
     * @dev Throws if the contract is paused.
     */
    function _requireNotPaused() internal view virtual {
        require(!paused(), "Pausable: paused");
    }

    /**
     * @dev Throws if the contract is not paused.
     */
    function _requirePaused() internal view virtual {
        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 25 : AccessControl.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.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);
        _;
    }

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

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

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

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

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

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

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

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

        _revokeRole(role, account);
    }

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

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

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

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

File 4 of 25 : 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 25 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 0;
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

File 6 of 25 : 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 25 : 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 25 : 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 25 : 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 + 1;
        arrayOfRounds = new IBhavishPrediction.Round[](len);

        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 25 : 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 25 : 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 25 : 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 25 : 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 25 : Strings.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

File 15 of 25 : 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 25 : 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 25 : 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 25 : 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 25 : 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 25 : SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

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

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

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

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

File 21 of 25 : 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;

    function claim(
        PredictionStruct memory _predStruct,
        uint256[] calldata roundIds,
        bytes32 toAsset,
        bool convert,
        uint256 slippage
    ) external;

    function refundUsers(PredictionStruct memory _predStruct, uint256 roundId) external;
}

File 22 of 25 : 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 25 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

File 25 of 25 : 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":true,"internalType":"address","name":"_sdk","type":"address"}],"name":"NewBhvaishSDK","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":"bhavishSDK","outputs":[{"internalType":"address","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":"address","name":"_sdk","type":"address"}],"name":"setBhavishSDK","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"}]

60806040526003600a553480156200001657600080fd5b50604051620049303803806200493083398101604081905262000039916200031f565b6001805460ff1916815560025587620000995760405162461bcd60e51b815260206004820152601a60248201527f496e76616c6964204d696e205072656469637420616d6f756e7400000000000060448201526064015b60405180910390fd5b600087118015620000aa5750606487105b620000f85760405162461bcd60e51b815260206004820152601860248201527f54726561737572792066656520697320746f6f20686967680000000000000000604482015260640162000090565b8260001080156200010c5750620151808311155b620001715760405162461bcd60e51b815260206004820152602e60248201527f526f756e642054696d652073686f756c64206265206265747765656e2031207360448201526d656320746f20333630302073656360901b606482015260840162000090565b60088890556007879055600e80546001600160a01b038089166001600160a01b031992831617909255600f80548884169083161790556010805492871692909116821790556040805180820182528481526020808201859052600c869055600d859055600487815583516311a8f41360e01b815293519294936311a8f41393818301939290918290030181865afa15801562000211573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620002379190620003a2565b6003556200024760003362000256565b505050505050505050620003bc565b62000262828262000266565b5050565b6000828152602081815260408083206001600160a01b038516845290915290205460ff1662000262576000828152602081815260408083206001600160a01b03851684529091529020805460ff19166001179055620002c23390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6001600160a01b03811681146200031c57600080fd5b50565b600080600080600080600080610100898b0312156200033d57600080fd5b88519750602089015196506040890151620003588162000306565b60608a01519096506200036b8162000306565b60808a01519095506200037e8162000306565b60a08a015160c08b015160e0909b0151999c989b5096999598909790945092505050565b600060208284031215620003b557600080fd5b5051919050565b61456480620003cc6000396000f3fe60806040526004361061028c5760003560e01c80639b87eade1161015a578063e44bb72f116100c1578063f50329801161007a578063f5032980146107a3578063f5b541a6146107c3578063f7b188a5146107e5578063fa65cb04146107fa578063fb2f897a1461081a578063fc572b181461083a57600080fd5b8063e44bb72f146106f1578063e8712bd414610704578063ec87621c14610724578063ee5f8c8f14610758578063efc3b2ea1461076e578063f2b3c8091461078e57600080fd5b8063ac8a584a11610113578063ac8a584a14610621578063b3ab15fb14610641578063bd9de03c14610661578063cc32d17614610681578063d547741f14610697578063e0e081d7146106b757600080fd5b80639b87eade146105745780639bb6eb70146105945780639cbe5efd146105b6578063a2003734146105cc578063a217fddf146105ec578063a23e98841461060157600080fd5b8063445769cd116101fe57806377e741c7116101b757806377e741c7146104ca578063795c2960146104ea5780637b3205f51461050a5780638456cb591461051f57806391d1485414610534578063965547571461055457600080fd5b8063445769cd146104275780634b14c3d4146104475780635a9aa957146104675780635c975abb1461047d578063733436201461049557806377e0181f146104b557600080fd5b80632f2ff15d116102505780632f2ff15d14610363578063313ce56714610383578063325f700e1461039957806335538b69146103d157806336568abe146103f1578063368acb091461041157600080fd5b806301ffc9a71461029857806309fffec0146102cd57806310082c75146102e25780631c389c2814610312578063248a9ca31461032557600080fd5b3661029357005b600080fd5b3480156102a457600080fd5b506102b86102b3366004613b50565b610850565b60405190151581526020015b60405180910390f35b6102e06102db366004613b7a565b610887565b005b3480156102ee57600080fd5b50600c54600d546102fd919082565b604080519283526020830191909152016102c4565b6102e0610320366004613ba8565b610a3b565b34801561033157600080fd5b50610355610340366004613b7a565b60009081526020819052604090206001015490565b6040519081526020016102c4565b34801561036f57600080fd5b506102e061037e366004613ba8565b610dd9565b34801561038f57600080fd5b50610355600a5481565b3480156103a557600080fd5b50600e546103b9906001600160a01b031681565b6040516001600160a01b0390911681526020016102c4565b3480156103dd57600080fd5b506102e06103ec366004613b7a565b610e03565b3480156103fd57600080fd5b506102e061040c366004613ba8565b610f5f565b34801561041d57600080fd5b5061035560095481565b34801561043357600080fd5b506102e0610442366004613b7a565b610fd9565b34801561045357600080fd5b506011546103b9906001600160a01b031681565b34801561047357600080fd5b5061035560055481565b34801561048957600080fd5b5060015460ff166102b8565b3480156104a157600080fd5b506102e06104b0366004613ba8565b61108e565b3480156104c157600080fd5b506102e061137e565b3480156104d657600080fd5b506102e06104e5366004613b7a565b611586565b3480156104f657600080fd5b50610355610505366004613c24565b611647565b34801561051657600080fd5b506102e061173f565b34801561052b57600080fd5b506102e0611a0b565b34801561054057600080fd5b506102b861054f366004613ba8565b611bad565b34801561056057600080fd5b506102e061056f366004613c7b565b611bd6565b34801561058057600080fd5b506102e061058f366004613cfc565b6120d9565b3480156105a057600080fd5b506105a961217b565b6040516102c49190613d51565b3480156105c257600080fd5b5061035560035481565b3480156105d857600080fd5b506102b86105e7366004613ebe565b612255565b3480156105f857600080fd5b50610355600081565b34801561060d57600080fd5b506102e061061c366004613cfc565b6122d0565b34801561062d57600080fd5b506102e061063c366004613cfc565b612372565b34801561064d57600080fd5b506102e061065c366004613cfc565b6123b2565b34801561066d57600080fd5b50600b546103b9906001600160a01b031681565b34801561068d57600080fd5b5061035560075481565b3480156106a357600080fd5b506102e06106b2366004613ba8565b6124d1565b3480156106c357600080fd5b506006546106da9060ff8082169161010090041682565b6040805192151583529015156020830152016102c4565b6102e06106ff366004613ba8565b6124f6565b34801561071057600080fd5b506010546103b9906001600160a01b031681565b34801561073057600080fd5b506103557f241ecf16d79d0f8dbfb92cbc07fe17840425976cf0667f022fe9877caa831b0881565b34801561076457600080fd5b5061035560045481565b34801561077a57600080fd5b50600f546103b9906001600160a01b031681565b34801561079a57600080fd5b50610355606481565b3480156107af57600080fd5b506102e06107be366004613cfc565b612880565b3480156107cf57600080fd5b5061035560008051602061450f83398151915281565b3480156107f157600080fd5b506102e061293c565b34801561080657600080fd5b506102e0610815366004613b7a565b612a23565b34801561082657600080fd5b50610355610835366004613c24565b612adc565b34801561084657600080fd5b5061035560085481565b60006001600160e01b03198216637965db0b60e01b148061088157506301ffc9a760e01b6001600160e01b03198316145b92915050565b60028054036108b15760405162461bcd60e51b81526004016108a890613f7c565b60405180910390fd5b60028055336108c1600082611bad565b6108dd5760405162461bcd60e51b81526004016108a890613fb3565b60095482111561092f5760405162461bcd60e51b815260206004820152601c60248201527f5472616e7366657220616d6f756e7420697320746f6f206c617267650000000060448201526064016108a8565b81600960008282546109419190613ff7565b9091555050600e546040516001600160a01b0390911690600090829085908381818185875af1925050503d8060008114610997576040519150601f19603f3d011682016040523d82523d6000602084013e61099c565b606091505b50509050806109ed5760405162461bcd60e51b815260206004820152601f60248201527f5472616e7366657248656c7065723a205452414e534645525f4641494c45440060448201526064016108a8565b816001600160a01b03167fc9262544ea8cacb7a3eea4ea7b4023ea10ac8bc73701610edba13308190f9cb185604051610a2891815260200190565b60405180910390a2505060016002555050565b610a43612c62565b6002805403610a645760405162461bcd60e51b81526004016108a890613f7c565b6002805560105460405163168a468560e11b8152600481018490526000916001600160a01b031690632d148d0a9060240161016060405180830381865afa158015610ab3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ad79190614019565b9050600081602001516003811115610af157610af1613d19565b148015610afe5750805115155b610b425760405162461bcd60e51b815260206004820152601560248201527442657420697320746f6f206561726c792f6c61746560581b60448201526064016108a8565b806101200151421115610b8f5760405162461bcd60e51b81526020600482015260156024820152741c9bdd5b9908185b1c9958591e481cdd185c9d1959605a1b60448201526064016108a8565b600854341015610bb15760405162461bcd60e51b81526004016108a8906140b3565b60105460405163ec4773a760e01b815260048101859052346024820181905260016044830152916001600160a01b03169063ec4773a790606401600060405180830381600087803b158015610c0557600080fd5b505af1158015610c19573d6000803e3d6000fd5b5050601054604051630736449d60e11b8152600481018890526001600160a01b038781166024830152600094509091169150630e6c893a90604401606060405180830381865afa158015610c71573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c9591906140ff565b8051909150158015610ca957506020810151155b15610d1557601054604051634a966a1b60e01b81526001600160a01b0386811660048301526024820188905290911690634a966a1b90604401600060405180830381600087803b158015610cfc57600080fd5b505af1158015610d10573d6000803e3d6000fd5b505050505b6010546040516331e1f08360e11b815260048101849052602481018790526001600160a01b03868116604483015260016064830152909116906363c3e10690608401600060405180830381600087803b158015610d7157600080fd5b505af1158015610d85573d6000803e3d6000fd5b5050505084846001600160a01b03167f0bab430d5cfc26b856f9867d7019c5af92e6fb9f0eef60afadab9f0d53ff1fd334604051610dc591815260200190565b60405180910390a350506001600255505050565b600082815260208190526040902060010154610df481612caa565b610dfe8383612cb7565b505050565b610e0b612c62565b33610e2460008051602061450f83398151915282611bad565b610e405760405162461bcd60e51b81526004016108a89061415b565b600654610100900460ff1615610ea75760405162461bcd60e51b815260206004820152602660248201527f43616e206f6e6c792072756e20726f756e647a65726f437265617465526f756e60448201526564206f6e636560d01b60648201526084016108a8565b600354610eb5906001614192565b60038190556005839055610ec99083612d3b565b6006805461ff001916610100179055600354610eff90610eea906001614192565b600454600554610efa9190614192565b612d3b565b610f2c6003546002610f119190614192565b600454600554610f22908290614192565b610efa9190614192565b610f5b6003546003610f3e9190614192565b6004546005548190610f51908290614192565b610f229190614192565b5050565b6001600160a01b0381163314610fcf5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084016108a8565b610f5b8282612f07565b610fe1612f6c565b33610fed600082611bad565b6110095760405162461bcd60e51b81526004016108a890613fb3565b600082116110515760405162461bcd60e51b815260206004820152601560248201527404d757374206265207375706572696f7220746f203605c1b60448201526064016108a8565b60088290556040518281527f06a2e1014d8503fc3c899acda61fc50ab1918a70e8f904759a1f72f03bbd9cda906020015b60405180910390a15050565b60028054036110af5760405162461bcd60e51b81526004016108a890613f7c565b6002805560105460405163168a468560e11b8152600481018490526000916001600160a01b031690632d148d0a9060240161016060405180830381865afa1580156110fe573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111229190614019565b905060038160200151600381111561113c5761113c613d19565b146111895760405162461bcd60e51b815260206004820152601c60248201527f55736572206e6f7420656c696769626c6520666f7220726566756e640000000060448201526064016108a8565b601054604051630736449d60e11b8152600481018590526001600160a01b0384811660248301526000921690630e6c893a90604401606060405180830381865afa1580156111db573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111ff91906140ff565b9050806040015160001461124e5760405162461bcd60e51b81526020600482015260166024820152751499599d5b9908185b1c9958591e4818db185a5b595960521b60448201526064016108a8565b6020810151815160009161126191614192565b90506000811561135a57600a80546112789161428e565b600754611285908461429a565b61128f91906142b9565b905061129b8183613ff7565b60105460405163720988c960e11b8152600481018990526001600160a01b0388811660248301526044820184905292945091169063e413119290606401600060405180830381600087803b1580156112f257600080fd5b505af1158015611306573d6000803e3d6000fd5b505050506113148583612fb5565b604080518381524260208201526001600160a01b0387169188917faba4210cad11f1112f31ba136a61cdc0f6ab4c2b478da8c93eec1d9769e97a89910160405180910390a35b806009600082825461136c9190614192565b90915550506001600255505050505050565b611386612c62565b3361139f60008051602061450f83398151915282611bad565b6113bb5760405162461bcd60e51b81526004016108a89061415b565b600654610100900460ff1661142f5760405162461bcd60e51b815260206004820152603460248201527f43616e206f6e6c792072756e20616674657220726f756e647a65726f437265616044820152731d19549bdd5b99081a5cc81d1c9a59d9d95c995960621b60648201526084016108a8565b60065460ff16156114905760405162461bcd60e51b815260206004820152602560248201527f43616e206f6e6c792072756e20726f756e647a65726f5374617274526f756e64604482015264206f6e636560d81b60648201526084016108a8565b6005544210156114e25760405162461bcd60e51b815260206004820152601d60248201527f526f756e642063616e6e6f742062652073746172746564206561726c7900000060448201526064016108a8565b600f54600c54600d546005546040516319f59e5f60e01b81526004810193909352602483019190915260448201526000916001600160a01b0316906319f59e5f906064016040805180830381865afa158015611542573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061156691906142db565b50905061157560035482613058565b50506006805460ff19166001179055565b61158e612f6c565b3361159a600082611bad565b6115b65760405162461bcd60e51b81526004016108a890613fb3565b6000821180156115c65750606482105b6116125760405162461bcd60e51b815260206004820152601860248201527f54726561737572792066656520697320746f6f2068696768000000000000000060448201526064016108a8565b60078290556040518281527f938d9272b26145999fe14f6124b73f122e1e023fc5de069c74ade1254408a97690602001611082565b6000805b83811015611724576010546000906001600160a01b0316630e6c893a87878581811061167957611679614306565b90506020020135866040518363ffffffff1660e01b81526004016116b09291909182526001600160a01b0316602082015260400190565b606060405180830381865afa1580156116cd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116f191906140ff565b8051602082015191925061170491614192565b61170e9084614192565b925050808061171c9061431c565b91505061164b565b5082156117385761173583826142b9565b90505b9392505050565b611747612c62565b600654610100900460ff168015611760575060065460ff165b6117bb5760405162461bcd60e51b815260206004820152602660248201527f43616e206f6e6c792072756e20616674657220726f756e647a65726f537461726044820152651d149bdd5b9960d21b60648201526084016108a8565b60105460035460405163168a468560e11b815260048101919091526000916001600160a01b031690632d148d0a9060240161016060405180830381865afa15801561180a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061182e9190614019565b601054600380549293506000926001600160a01b0390921691632d148d0a916118579190614192565b6040518263ffffffff1660e01b815260040161187591815260200190565b61016060405180830381865afa158015611893573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118b79190614019565b600f54600c54600d546101408601516040516319f59e5f60e01b81526004810193909352602483019190915260448201529192506000916001600160a01b03909116906319f59e5f906064016040805180830381865afa15801561191f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061194391906142db565b50905060038360200151600381111561195e5761195e613d19565b1415801561196b57508015155b1561198c5761197c6003548261322d565b6119876003546133f2565b6119c0565b6003836020015160038111156119a4576119a4613d19565b141580156119b0575080155b156119c0576119c0600354613648565b6119d860035460016119d29190614192565b82613058565b6119f560035460046119ea9190614192565b836101400151612d3b565b600354611a03906001614192565b600355505050565b611a13612c62565b33611a1f600082611bad565b611a3b5760405162461bcd60e51b81526004016108a890613fb3565b611a436137b9565b6003545b601060009054906101000a90046001600160a01b03166001600160a01b03166311a8f4136040518163ffffffff1660e01b8152600401602060405180830381865afa158015611a9a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611abe9190614335565b8111611b6e5760105460405163168a468560e11b8152600481018390526000916001600160a01b031690632d148d0a9060240161016060405180830381865afa158015611b0f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b339190614019565b9050600381602001516003811115611b4d57611b4d613d19565b14611b5b57611b5b82613648565b5080611b668161431c565b915050611a47565b507fa382c86dbb1fba726013556ec174337b8f9ddac70b97ddb00d2e79e8b565d4f5600354604051611ba291815260200190565b60405180910390a150565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b6002805403611bf75760405162461bcd60e51b81526004016108a890613f7c565b6002805580336001600160a01b03821614611c5757600b546001600160a01b03163314611c575760405162461bcd60e51b815260206004820152600e60248201526d24b73b30b634b21021b0b63632b960911b60448201526064016108a8565b6000805b87811015611fb6576010546000906001600160a01b0316632d148d0a8b8b85818110611c8957611c89614306565b905060200201356040518263ffffffff1660e01b8152600401611cae91815260200190565b61016060405180830381865afa158015611ccc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cf09190614019565b6010549091506000906001600160a01b0316630e6c893a8c8c86818110611d1957611d19614306565b90506020020135886040518363ffffffff1660e01b8152600401611d509291909182526001600160a01b0316602082015260400190565b606060405180830381865afa158015611d6d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d9191906140ff565b9050600282602001516003811115611dab57611dab613d19565b14611df85760405162461bcd60e51b815260206004820152601e60248201527f526f756e64206e6f7420656c696769626c6520666f722072657761726473000060448201526064016108a8565b6000826080015111611e435760405162461bcd60e51b8152602060048201526014602482015273139bc818995d1cc81a5b881d1a19481c9bdd5b9960621b60448201526064016108a8565b8161010001518260e0015103611ea857611e5c8261380d565b611ea85760405162461bcd60e51b815260206004820152601760248201527f4e6f7420656c696769626c6520666f7220726566756e6400000000000000000060448201526064016108a8565b611eb28282612255565b15611fa1576000611ec3838361383d565b601054845160405163720988c960e11b815260048101919091526001600160a01b038a811660248301526044820184905292935091169063e413119290606401600060405180830381600087803b158015611f1d57600080fd5b505af1158015611f31573d6000803e3d6000fd5b505050508085611f419190614192565b94508b8b85818110611f5557611f55614306565b90506020020135876001600160a01b03167f34fcbac0073d7c3d388e51312faf357774904998eeb8fca628b9e6f65ee1cbf783604051611f9791815260200190565b60405180910390a3505b50508080611fae9061431c565b915050611c5b565b50848015611fc45750600081115b156120ba5760006040518060800160405280600081526020016004546002611fec919061429a565b611ff69042614192565b8152644d4154494360d81b60208083019190915260409182018a90526011548251630c44410b60e41b815284516004820152918401516024830152918301516044820152606083015160648201526001600160a01b03878116608483015260a4820189905292935091169063c44410b090849060c40160006040518083038185885af115801561208a573d6000803e3d6000fd5b50505050506040513d6000823e601f3d908101601f191682016040526120b3919081019061434e565b50506120ca565b80156120ca576120ca8382612fb5565b50506001600255505050505050565b336120e5600082611bad565b6121015760405162461bcd60e51b81526004016108a890613fb3565b6001600160a01b0382163b6121585760405162461bcd60e51b815260206004820152601960248201527f53776170706572206973206e6f74206120636f6e74726163740000000000000060448201526064016108a8565b50601180546001600160a01b0319166001600160a01b0392909216919091179055565b6121d96040805161016081019091526000808252602082019081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b60105460035460405163168a468560e11b81526001600160a01b0390921691632d148d0a9161220e9160040190815260200190565b61016060405180830381865afa15801561222c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122509190614019565b905090565b805160009015158061226a5750602082015115155b801561227857506040820151155b801561173857508260e001518361010001511180156122975750815115155b806122b857508260e001518361010001511080156122b85750602082015115155b806117385750505060e0810151610100909101511490565b336122dc600082611bad565b6122f85760405162461bcd60e51b81526004016108a890613fb3565b6001600160a01b0382163b61234f5760405162461bcd60e51b815260206004820152601960248201527f4e6f7420426861766973682041646d696e6973747261746f720000000000000060448201526064016108a8565b50600e80546001600160a01b0319166001600160a01b0392909216919091179055565b3361237e600082611bad565b61239a5760405162461bcd60e51b81526004016108a890613fb3565b610f5b60008051602061450f833981519152836124d1565b336123be600082611bad565b6123da5760405162461bcd60e51b81526004016108a890613fb3565b6001600160a01b0382163b156124325760405162461bcd60e51b815260206004820152601d60248201527f4f70657261746f722063616e6e6f74206265206120636f6e747261637400000060448201526064016108a8565b6001600160a01b0382166124815760405162461bcd60e51b815260206004820152601660248201527543616e6e6f74206265207a65726f206164647265737360501b60448201526064016108a8565b61249960008051602061450f83398151915283610dd9565b6040516001600160a01b038316907fda12ee837e6978172aaf54b16145ffe08414fd8710092ef033c71b8eb6ec189a90600090a25050565b6000828152602081905260409020600101546124ec81612caa565b610dfe8383612f07565b6124fe612c62565b600280540361251f5760405162461bcd60e51b81526004016108a890613f7c565b6002805560105460405163168a468560e11b8152600481018490526000916001600160a01b031690632d148d0a9060240161016060405180830381865afa15801561256e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125929190614019565b90508061012001514211156125e15760405162461bcd60e51b81526020600482015260156024820152741c9bdd5b9908185b1c9958591e481cdd185c9d1959605a1b60448201526064016108a8565b6000816020015160038111156125f9576125f9613d19565b1480156126065750805115155b61264a5760405162461bcd60e51b815260206004820152601560248201527442657420697320746f6f206561726c792f6c61746560581b60448201526064016108a8565b60085434101561266c5760405162461bcd60e51b81526004016108a8906140b3565b60105460405163ec4773a760e01b815260048101859052346024820181905260006044830152916001600160a01b03169063ec4773a790606401600060405180830381600087803b1580156126c057600080fd5b505af11580156126d4573d6000803e3d6000fd5b5050601054604051630736449d60e11b8152600481018890526001600160a01b038781166024830152600094509091169150630e6c893a90604401606060405180830381865afa15801561272c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061275091906140ff565b805190915015801561276457506020810151155b156127d057601054604051634a966a1b60e01b81526001600160a01b0386811660048301526024820188905290911690634a966a1b90604401600060405180830381600087803b1580156127b757600080fd5b505af11580156127cb573d6000803e3d6000fd5b505050505b6010546040516331e1f08360e11b815260048101849052602481018790526001600160a01b03868116604483015260006064830152909116906363c3e10690608401600060405180830381600087803b15801561282c57600080fd5b505af1158015612840573d6000803e3d6000fd5b5050505084846001600160a01b03167f546f54506a25044de11c4fb0c44fbd0137d87d7e08dfd800944453931428a5ea34604051610dc591815260200190565b3361288c600082611bad565b6128a85760405162461bcd60e51b81526004016108a890613fb3565b6001600160a01b0382163b6128f15760405162461bcd60e51b815260206004820152600f60248201526e696e76616c6964206164647265737360881b60448201526064016108a8565b600b80546001600160a01b0319166001600160a01b0384169081179091556040517f98902aabfcbed99d0d9769f20db2c97ad70f69f67ca8811518d37b9e590e0e8890600090a25050565b612944612f6c565b33612950600082611bad565b61296c5760405162461bcd60e51b81526004016108a890613fb3565b6006805461ffff19169055601054604080516311a8f41360e01b815290516001600160a01b03909216916311a8f413916004808201926020929091908290030181865afa1580156129c1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129e59190614335565b6003556129f0613917565b7f0b0e422893e2219d69c6fba12911d3b270235e96e9753519998fc13013ebb2ae600354604051611ba291815260200190565b612a2b612f6c565b33612a4460008051602061450f83398151915282611bad565b612a605760405162461bcd60e51b81526004016108a89061415b565b816000108015612a735750620151808211155b612ad65760405162461bcd60e51b815260206004820152602e60248201527f526f756e642054696d652073686f756c64206265206265747765656e2031207360448201526d656320746f20333630302073656360901b60648201526084016108a8565b50600455565b600080805b84811015612c59576010546000906001600160a01b0316632d148d0a888885818110612b0f57612b0f614306565b905060200201356040518263ffffffff1660e01b8152600401612b3491815260200190565b61016060405180830381865afa158015612b52573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b769190614019565b6010549091506000906001600160a01b0316630e6c893a898986818110612b9f57612b9f614306565b90506020020135886040518363ffffffff1660e01b8152600401612bd69291909182526001600160a01b0316602082015260400190565b606060405180830381865afa158015612bf3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c1791906140ff565b9050612c238282612255565b612c2e575050612c47565b612c38828261383d565b612c429085614192565b935050505b80612c518161431c565b915050612ae1565b50949350505050565b60015460ff1615612ca85760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b60448201526064016108a8565b565b612cb48133613950565b50565b612cc18282611bad565b610f5b576000828152602081815260408083206001600160a01b03851684529091529020805460ff19166001179055612cf73390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60105460405163168a468560e11b8152600481018490526000916001600160a01b031690632d148d0a9060240161016060405180830381865afa158015612d86573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612daa9190614019565b805190915015612df35760405162461bcd60e51b8152602060048201526014602482015273526f756e6420616c72656164792065786973747360601b60448201526064016108a8565b4260045483612e029190613ff7565b1015612e505760405162461bcd60e51b815260206004820152601760248201527f526f756e642074696d6520697320746f6f2073686f727400000000000000000060448201526064016108a8565b8281526101208101829052600454612e689083614192565b6101408201526000602082015260105460405163ad0197db60e01b81526001600160a01b039091169063ad0197db90612ea5908490600401613d51565b600060405180830381600087803b158015612ebf57600080fd5b505af1158015612ed3573d6000803e3d6000fd5b50506040518592507f257b6e0c207001c05b4f0f88a5bc913e2c47513ab9989881a48ceea263b2a7219150600090a2505050565b612f118282611bad565b15610f5b576000828152602081815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60015460ff16612ca85760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b60448201526064016108a8565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114613002576040519150601f19603f3d011682016040523d82523d6000602084013e613007565b606091505b5050905080610dfe5760405162461bcd60e51b815260206004820152601f60248201527f5472616e7366657248656c7065723a205452414e534645525f4641494c45440060448201526064016108a8565b60105460405163168a468560e11b8152600481018490526000916001600160a01b031690632d148d0a9060240161016060405180830381865afa1580156130a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130c79190614019565b9050816000036130da57610dfe83613648565b6000816020015160038111156130f2576130f2613d19565b1461313f5760405162461bcd60e51b815260206004820152601760248201527f526f756e642073686f756c64206265206372656174656400000000000000000060448201526064016108a8565b4281610120015111156131945760405162461bcd60e51b815260206004820152601c60248201527f546f6f206561726c7920746f2073746172742074686520726f756e640000000060448201526064016108a8565b6010546040516352f3e91960e01b81526001600160a01b03909116906352f3e919906131cb908690600190879082906004016143f4565b600060405180830381600087803b1580156131e557600080fd5b505af11580156131f9573d6000803e3d6000fd5b50506040518592507f939f42374aa9bf1d8d8cd56d8a9110cb040cd8dfeae44080c6fcf2645e51b4529150600090a2505050565b60105460405163168a468560e11b8152600481018490526000916001600160a01b031690632d148d0a9060240161016060405180830381865afa158015613278573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061329c9190614019565b90506001816020015160038111156132b6576132b6613d19565b146133035760405162461bcd60e51b815260206004820152601860248201527f526f756e64206973206e6f74207374617274656420796574000000000000000060448201526064016108a8565b4281610140015111156133585760405162461bcd60e51b815260206004820152601a60248201527f546f6f206561726c7920746f20656e642074686520726f756e6400000000000060448201526064016108a8565b6010546040516352f3e91960e01b81526001600160a01b03909116906352f3e9199061339090869060029087906000906004016143f4565b600060405180830381600087803b1580156133aa57600080fd5b505af11580156133be573d6000803e3d6000fd5b50506040518592507f2c46d8d5cabadbc3b7c8644a09e45c97988bd5ee29b298d282a7ef8c1833d9129150600090a2505050565b60105460405163168a468560e11b8152600481018390526000916001600160a01b031690632d148d0a9060240161016060405180830381865afa15801561343d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134619190614019565b905060028160200151600381111561347b5761347b613d19565b146134bd5760405162461bcd60e51b8152602060048201526012602482015271149bdd5b99081a5cc81b9bdd08195b99195960721b60448201526064016108a8565b6000806000600a54600a6134d1919061428e565b60075485608001516134e3919061429a565b6134ed91906142b9565b91508360e00151846101000151111561353057836040015192508184608001516135179190613ff7565b90508260000361352b575050606082015160005b613577565b8360e00151846101000151101561357057836060015192508184608001516135589190613ff7565b90508260000361352b57505060408201516000613577565b5060009150815b81600960008282546135899190614192565b909155505060105460405163ddae3a7160e01b81526004810187905260248101839052604481018590526001600160a01b039091169063ddae3a7190606401600060405180830381600087803b1580156135e257600080fd5b505af11580156135f6573d6000803e3d6000fd5b50506009546040805187815260208101869052908101919091528792507f6dfdfcb09c8804d0058826cd2539f1acfbe3cb887c9be03d928035bce0f1a58d915060600160405180910390a25050505050565b60105460405163168a468560e11b8152600481018390526000916001600160a01b031690632d148d0a9060240161016060405180830381865afa158015613693573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136b79190614019565b90506003816020015160038111156136d1576136d1613d19565b0361372c5760405162461bcd60e51b815260206004820152602560248201527f43616e6e6f742063616e63656c20616c72656164792063616e63656c6c6564206044820152641c9bdd5b9960da1b60648201526084016108a8565b601054604051637e07ab0960e01b8152600481018490526001600160a01b0390911690637e07ab0990602401600060405180830381600087803b15801561377257600080fd5b505af1158015613786573d6000803e3d6000fd5b50506040518492507f1316afc2a7dc68d55247ceedbef28ffd97f61bafc159c949278f4b934d448c7b9150600090a25050565b6137c1612c62565b6001805460ff1916811790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258335b6040516001600160a01b03909116815260200160405180910390a1565b60008160a001516000148015613825575060c0820151155b801561088157505061010081015160e0909101511490565b60008260e00151836101000151036138ab576138588361380d565b156138a6576020820151825160009161387091614192565b9050600a54600a613881919061428e565b60075461388e908361429a565b61389891906142b9565b6138a29082613ff7565b9150505b610881565b8260e0015183610100015111156138e35760a083015160c084015183516138d2919061429a565b6138dc91906142b9565b9050610881565b8260e001518361010001511015610881578260a001518360c00151836020015161390d919061429a565b61173891906142b9565b61391f612f6c565b6001805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa336137f0565b61395a8282611bad565b610f5b57613972816001600160a01b031660146139b4565b61397d8360206139b4565b60405160200161398e92919061444f565b60408051601f198184030181529082905262461bcd60e51b82526108a8916004016144c4565b606060006139c383600261429a565b6139ce906002614192565b67ffffffffffffffff8111156139e6576139e6613dd4565b6040519080825280601f01601f191660200182016040528015613a10576020820181803683370190505b509050600360fc1b81600081518110613a2b57613a2b614306565b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110613a5a57613a5a614306565b60200101906001600160f81b031916908160001a9053506000613a7e84600261429a565b613a89906001614192565b90505b6001811115613b01576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110613abd57613abd614306565b1a60f81b828281518110613ad357613ad3614306565b60200101906001600160f81b031916908160001a90535060049490941c93613afa816144f7565b9050613a8c565b5083156117385760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016108a8565b600060208284031215613b6257600080fd5b81356001600160e01b03198116811461173857600080fd5b600060208284031215613b8c57600080fd5b5035919050565b6001600160a01b0381168114612cb457600080fd5b60008060408385031215613bbb57600080fd5b823591506020830135613bcd81613b93565b809150509250929050565b60008083601f840112613bea57600080fd5b50813567ffffffffffffffff811115613c0257600080fd5b6020830191508360208260051b8501011115613c1d57600080fd5b9250929050565b600080600060408486031215613c3957600080fd5b833567ffffffffffffffff811115613c5057600080fd5b613c5c86828701613bd8565b9094509250506020840135613c7081613b93565b809150509250925092565b60008060008060008060a08789031215613c9457600080fd5b863567ffffffffffffffff811115613cab57600080fd5b613cb789828a01613bd8565b9097509550506020870135935060408701358015158114613cd757600080fd5b9250606087013591506080870135613cee81613b93565b809150509295509295509295565b600060208284031215613d0e57600080fd5b813561173881613b93565b634e487b7160e01b600052602160045260246000fd5b60048110613d4d57634e487b7160e01b600052602160045260246000fd5b9052565b81518152602080830151610160830191613d6d90840182613d2f565b5060408301516040830152606083015160608301526080830151608083015260a083015160a083015260c083015160c083015260e083015160e083015261010080840151818401525061012080840151818401525061014080840151818401525092915050565b634e487b7160e01b600052604160045260246000fd5b604051610160810167ffffffffffffffff81118282101715613e0e57613e0e613dd4565b60405290565b604051601f8201601f1916810167ffffffffffffffff81118282101715613e3d57613e3d613dd4565b604052919050565b60048110612cb457600080fd5b8035613e5d81613e45565b919050565b600060608284031215613e7457600080fd5b6040516060810181811067ffffffffffffffff82111715613e9757613e97613dd4565b80604052508091508235815260208301356020820152604083013560408201525092915050565b6000808284036101c0811215613ed357600080fd5b61016080821215613ee357600080fd5b613eeb613dea565b915084358252613efd60208601613e52565b602083015260408501356040830152606085013560608301526080850135608083015260a085013560a083015260c085013560c083015260e085013560e0830152610100808601358184015250610120808601358184015250610140808601358184015250819350613f7186828701613e62565b925050509250929050565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b60208082526014908201527320b2323932b9b9903737ba1030b71030b236b4b760611b604082015260600190565b634e487b7160e01b600052601160045260246000fd5b60008282101561400957614009613fe1565b500390565b8051613e5d81613e45565b6000610160828403121561402c57600080fd5b614034613dea565b825181526140446020840161400e565b602082015260408301516040820152606083015160608201526080830151608082015260a083015160a082015260c083015160c082015260e083015160e08201526101008084015181830152506101208084015181830152506101408084015181830152508091505092915050565b6020808252602c908201527f42657420616d6f756e74206d7573742062652067726561746572207468616e2060408201526b1b5a5b90995d105b5bdd5b9d60a21b606082015260800190565b60006060828403121561411157600080fd5b6040516060810181811067ffffffffffffffff8211171561413457614134613dd4565b80604052508251815260208301516020820152604083015160408201528091505092915050565b60208082526017908201527f41646472657373206e6f7420616e206f70657261746f72000000000000000000604082015260600190565b600082198211156141a5576141a5613fe1565b500190565b600181815b808511156141e55781600019048211156141cb576141cb613fe1565b808516156141d857918102915b93841c93908002906141af565b509250929050565b6000826141fc57506001610881565b8161420957506000610881565b816001811461421f576002811461422957614245565b6001915050610881565b60ff84111561423a5761423a613fe1565b50506001821b610881565b5060208310610133831016604e8410600b8410161715614268575081810a610881565b61427283836141aa565b806000190482111561428657614286613fe1565b029392505050565b600061173883836141ed565b60008160001904831182151516156142b4576142b4613fe1565b500290565b6000826142d657634e487b7160e01b600052601260045260246000fd5b500490565b600080604083850312156142ee57600080fd5b82519150602083015160ff81168114613bcd57600080fd5b634e487b7160e01b600052603260045260246000fd5b60006001820161432e5761432e613fe1565b5060010190565b60006020828403121561434757600080fd5b5051919050565b6000602080838503121561436157600080fd5b825167ffffffffffffffff8082111561437957600080fd5b818501915085601f83011261438d57600080fd5b81518181111561439f5761439f613dd4565b8060051b91506143b0848301613e14565b81815291830184019184810190888411156143ca57600080fd5b938501935b838510156143e8578451825293850193908501906143cf565b98975050505050505050565b848152608081016144086020830186613d2f565b836040830152821515606083015295945050505050565b60005b8381101561443a578181015183820152602001614422565b83811115614449576000848401525b50505050565b7f416363657373436f6e74726f6c3a206163636f756e742000000000000000000081526000835161448781601785016020880161441f565b7001034b99036b4b9b9b4b733903937b6329607d1b60179184019182015283516144b881602884016020880161441f565b01602801949350505050565b60208152600082518060208401526144e381604085016020870161441f565b601f01601f19169190910160400192915050565b60008161450657614506613fe1565b50600019019056fe97667070c54ef182b0f5858b034beac1b6f3089aa2d3188bb1e8929f4fa9b929a2646970667358221220cf43000acf6fe28f1667f56420ed985e41609e3df565f9e79b6a34479777beae64736f6c634300080d0033000000000000000000000000000000000000000000000000016345785d8a00000000000000000000000000000000000000000000000000000000000000000019000000000000000000000000f957700b17443b34debcc4343a1d82834f803518000000000000000000000000637c0d4525a2b0e247093aad1b5ef91631b47e3c000000000000000000000000eaead47699aa7259966b63ef9e59b10ab0dc442c000000000000000000000000000000000000000000000000000000000000012c424e4200000000000000000000000000000000000000000000000000000000005553440000000000000000000000000000000000000000000000000000000000

Block Transaction Gas Used Reward
Age Block Fee Address BC Fee Address Voting Power Jailed Incoming
Block Uncle Number Difficulty Gas Used Reward
Loading
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.