Contract 0xB5137C46618337f7155a5Daad3d5309672F6255c 1

 
 
Txn Hash Method
Block
From
To
Value [Txn Fee]
0x4829a13523cf01e64698129b7939533dfd154b71a55b2dbfa79d7158252167dcClaim Tickets121392252021-10-27 15:56:221 min ago0xc7b994806281fd94e85103207bb7ca278f5d6bec IN  0xb5137c46618337f7155a5daad3d5309672f6255c0 BNB0.001008495
0x8e9618be58adffcb0dc9601f2201856dd90b0e3dc04e711ef1cfc6cfef124656Buy Tickets121391892021-10-27 15:54:343 mins ago0xcd291a8b2af03c582891d7ce30dbe5b4d1e569ce IN  0xb5137c46618337f7155a5daad3d5309672f6255c0 BNB0.001599175
0x9ab733820259bf04a3ce8e701a6880f631fdc1d6c525ea4be8277586f999cc98Buy Tickets121391832021-10-27 15:54:163 mins ago0xe57f8963f3cc2c65941127af4618c41659bb5a29 IN  0xb5137c46618337f7155a5daad3d5309672f6255c0 BNB0.00072925
0x3a458a5cb462637ad92cfaa47981a95e0a5c5c334649a2d3f739c8713001c604Buy Tickets121391742021-10-27 15:53:494 mins ago0xe57f8963f3cc2c65941127af4618c41659bb5a29 IN  0xb5137c46618337f7155a5daad3d5309672f6255c0 BNB0.00123921
0x0b55f42fb1352ff147f6d4dc7f7ca8c89ec33f3cca153f5b42a87668e5f0caacBuy Tickets121391412021-10-27 15:52:105 mins ago0xcd291a8b2af03c582891d7ce30dbe5b4d1e569ce IN  0xb5137c46618337f7155a5daad3d5309672f6255c0 BNB0.0049364
0x103e27f65da09a3c48b44af1ebb4100cc37c41e711a4e806566bfabead913418Buy Tickets121391212021-10-27 15:51:106 mins ago0xb45567b4837c7f40e9c3539c23b4581df4ac2e2a IN  0xb5137c46618337f7155a5daad3d5309672f6255c0 BNB0.00102173
0xc82860060632b0d47daa613adad25319c99d8b62afe688af398feb6bdd4b07b3Buy Tickets121391182021-10-27 15:51:016 mins ago0x45bcfa68cca6fa26b25fe8a5766fae021ae8dfe1 IN  0xb5137c46618337f7155a5daad3d5309672f6255c0 BNB0.00602381
0x66b5ba67d5fa58237f9ce86e5fbf2aa3d8d3a085b041f70f73ec0eb83a53e2c3Claim Tickets121391152021-10-27 15:50:527 mins ago0x6a83860dd927ea7f462a83a9bb5afea1bdfe53f1 IN  0xb5137c46618337f7155a5daad3d5309672f6255c0 BNB0.00040977
0x58d309ae38cb2c90c9b6f660e6e0089cb0999525f914c77b514f0f531035acbdClaim Tickets121391062021-10-27 15:50:257 mins ago0xb45567b4837c7f40e9c3539c23b4581df4ac2e2a IN  0xb5137c46618337f7155a5daad3d5309672f6255c0 BNB0.000324255
0x5f3dea4d496f64bb0811d83f3445b74ee74899bb72f7fce159b245fe1635a991Claim Tickets121390842021-10-27 15:49:198 mins ago0x384fcd06a80bb8c606f5d9471e0e07745478a3de IN  0xb5137c46618337f7155a5daad3d5309672f6255c0 BNB0.000324255
0x633a76a32d5728291293f6d6ca8a23b27f808cd39e78a3aeefc77939d98c1e46Buy Tickets121390772021-10-27 15:48:589 mins ago0x9de0cf7d276b849137846229b583043e582b1a2e IN  0xb5137c46618337f7155a5daad3d5309672f6255c0 BNB0.003631505
0x05cc6e3f6a884b639dd154f865896152d1450364034cb9dd67ae27745e37b15aClaim Tickets121390462021-10-27 15:47:2510 mins ago0x9de0cf7d276b849137846229b583043e582b1a2e IN  0xb5137c46618337f7155a5daad3d5309672f6255c0 BNB0.000324315
0x176af22b00433defacc933062f5b71d59804a1e20cdff44b6daf45e6e6961c5dBuy Tickets121390412021-10-27 15:47:1010 mins ago0x8a49fcd633c1c99a13592e3bd9a9256e17d2f402 IN  0xb5137c46618337f7155a5daad3d5309672f6255c0 BNB0.00080425
0xd03e7eb941828271501762dd4b41ab431527714c30158452be46c6cd5153591bBuy Tickets121390322021-10-27 15:46:4311 mins ago0x97916f668a7680dea777878caca214e16d675a4f IN  0xb5137c46618337f7155a5daad3d5309672f6255c0 BNB0.001674175
0x1a197e73dde4e524bfb0964dc57b8615be63153e63a39c46e6d2fec2a4d6cc27Buy Tickets121390172021-10-27 15:45:5812 mins ago0x91308e9ddc857d2347e145595961248becb06f3a IN  0xb5137c46618337f7155a5daad3d5309672f6255c0 BNB0.00080425
0xf4438035075cd7b29e5f0bdcd62c0d5e6b4251e806e5d33513480ac8d5cffa72Buy Tickets121389552021-10-27 15:42:5215 mins ago0xaca425e1a7dfdf4455c69c30fcffecc4ac0b9f70 IN  0xb5137c46618337f7155a5daad3d5309672f6255c0 BNB0.001456705
0x60281aced8f4a6e44dd9353f838532d2493d2fb85d2d7aabbe84b9114822eb94Buy Tickets121389202021-10-27 15:41:0416 mins ago0x81d734d689acebc4563c42778f8cad26f3d63963 IN  0xb5137c46618337f7155a5daad3d5309672f6255c0 BNB0.00232662
0x69a1327f75d9146964a2a62f254ef04571a94d48b0884118aec5b18ad24ecd05Buy Tickets121388642021-10-27 15:38:1619 mins ago0x35dcb52afd85d55211c1ab58d86b06dc4c84c0d4 IN  0xb5137c46618337f7155a5daad3d5309672f6255c0 BNB0.00102173
0xc96c555deb587d7c5dda0ecf355c168a984a77ec7bdcba787199ce16b09ca819Claim Tickets121388362021-10-27 15:36:5221 mins ago0x35dcb52afd85d55211c1ab58d86b06dc4c84c0d4 IN  0xb5137c46618337f7155a5daad3d5309672f6255c0 BNB0.00048477
0x0c56a3e8fe8c731a66a98d5d5872e3f987f032ae8f5e1f23d04c31d0633c2884Buy Tickets121388322021-10-27 15:36:4021 mins ago0x8c7001716ba59cd13f7d8af159f5289cd547d349 IN  0xb5137c46618337f7155a5daad3d5309672f6255c0 BNB0.001456695
0x8c5c477e52d749c90d13374566724dde4be439b8ddb66154daa4af3ba1436e1bClaim Tickets121388232021-10-27 15:36:1321 mins ago0x8c7001716ba59cd13f7d8af159f5289cd547d349 IN  0xb5137c46618337f7155a5daad3d5309672f6255c0 BNB0.00040977
0xccd5847d6c88d1d30402df87870167a08fa7a9005f31f5687cffe6201d8ebb47Buy Tickets121387622021-10-27 15:33:0824 mins ago0xdc764ff9bd5eac924aec320b35fc64ea2f32a3c0 IN  0xb5137c46618337f7155a5daad3d5309672f6255c0 BNB0.00080432
0xa89ac84b1031e7271c3167760ac3913ddc86d402d4a6cf420a0ae3351ff9b808Claim Tickets121387582021-10-27 15:32:5525 mins ago0x9cd8f4011c108a9240c87c180601b5360462cd42 IN  0xb5137c46618337f7155a5daad3d5309672f6255c0 BNB0.00109419
0x4f8a90489fa52cde00dc12e5fec580834bf6cee213168e94e794b0c55f6e6804Claim Tickets121387422021-10-27 15:32:0325 mins ago0xb91697a455b04fd3dccf8f8558944f9c054121b8 IN  0xb5137c46618337f7155a5daad3d5309672f6255c0 BNB0.000324255
0xb47da42789b407f3396b87a2cab83c68916c11ef9e0a7a91eff0bc2f0cc24024Buy Tickets121387352021-10-27 15:31:3626 mins ago0xe51e894593edcbd44e69bde766ec95742ddd4f5b IN  0xb5137c46618337f7155a5daad3d5309672f6255c0 BNB0.00384906
[ Download CSV Export 
Parent Txn Hash Block From To Value
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
BiswapLottery

Compiler Version
v0.8.4+commit.c7e474f2

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 1 : Lottery.sol
/**
 *Submitted for verification at BscScan.com on 2021-07-02
*/


// File: @openzeppelin/contracts/utils/Context.sol

// SPDX-License-Identifier: MIT
//LBC-01
pragma solidity 0.8.4;

/*
 * @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) {
        this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
        return msg.data;
    }
}

// File: @openzeppelin/contracts/access/Ownable.sol
//LBC-01
pragma solidity 0.8.4;

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

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

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor() {
        address msgSender = _msgSender();
        _owner = msgSender;
        emit OwnershipTransferred(address(0), msgSender);
    }

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

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

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

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

// File: @openzeppelin/contracts/security/ReentrancyGuard.sol
//LBC-01
pragma solidity 0.8.4;

/**
 * @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 make 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: @openzeppelin/contracts/token/ERC20/IERC20.sol
//LBC-01
pragma solidity 0.8.4;

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

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

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

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

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

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

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

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

// File: @openzeppelin/contracts/utils/Address.sol
//LBC-01
pragma solidity 0.8.4;

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

        uint256 size;
        // solhint-disable-next-line no-inline-assembly
        assembly {
            size := extcodesize(account)
        }
        return size > 0;
    }

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

        // solhint-disable-next-line avoid-low-level-calls, avoid-call-value
        (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");

        // solhint-disable-next-line avoid-low-level-calls
        (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");

        // solhint-disable-next-line avoid-low-level-calls
        (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");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

    function _verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) private 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

                // solhint-disable-next-line no-inline-assembly
                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

// File: @openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol
//LBC-01
pragma solidity 0.8.4;

/**
 * @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'
        // solhint-disable-next-line max-line-length
        require(
            (value == 0) || (token.allowance(address(this), spender) == 0),
            "SafeERC20: approve from non-zero to non-zero allowance"
        );
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
    }

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

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

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

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

// File: contracts/interfaces/IRandomNumberGenerator.sol
//LBC-01
pragma solidity 0.8.4;

interface IRandomNumberGenerator {
    /**
     * Requests randomness from a user-provided seed
     */
    function getRandomNumber(uint256 _seed) external;

    /**
     * View latest lotteryId numbers
     */
    function viewLatestLotteryId() external view returns (uint256);

    /**
     * Views random result
     */
    function viewRandomResult() external view returns (uint32);
}

//Price Oracle interface
//LBC-01
pragma solidity 0.8.4;

interface IPriceOracle {
    struct Observation {
        uint timestamp;
        uint price0Cumulative;
        uint price1Cumulative;
    }
    function pairObservations(address pairAddress) external view returns(Observation memory);
    function update(address tokenA, address tokenB) external;
    function consult(address tokenIn, uint amountIn, address tokenOut) external view returns (uint);
}

// File: contracts/interfaces/IBiswapLottery.sol
//LBC-01
pragma solidity 0.8.4;

interface IBiswapLottery {
    /**
     * @notice Buy tickets for the current lottery
     * @param _lotteryId: lotteryId
     * @param _ticketNumbers: array of ticket numbers between 1,000,000 and 1,999,999
     * @dev Callable by users
     */
    function buyTickets(uint256 _lotteryId, uint32[] calldata _ticketNumbers) external;

    /**
     * @notice Claim a set of winning tickets for a lottery
     * @param _lotteryId: lottery id
     * @param _ticketIds: array of ticket ids
     * @param _brackets: array of brackets for the ticket ids
     * @dev Callable by users only, not contract!
     */
    function claimTickets(
        uint256 _lotteryId,
        uint256[] calldata _ticketIds,
        uint32[] calldata _brackets
    ) external;

    /**
     * @notice Close lottery
     * @param _lotteryId: lottery id
     * @dev Callable by operator
     */
    function closeLottery(uint256 _lotteryId) external;

    /**
     * @notice Draw the final number, calculate reward in BSW per group, and make lottery claimable
     * @param _lotteryId: lottery id
     * @param _autoInjection: reinjects funds into next lottery (vs. withdrawing all)
     * @param _bswPerBracket: distribution of winnings by bracket
     * @param _countTicketsPerBracket: total number of tickets in each bracket
     * @dev Callable by operator
     */
    function drawFinalNumberAndMakeLotteryClaimable(
        uint256 _lotteryId,
        uint[6] calldata _bswPerBracket,
        uint[6] calldata _countTicketsPerBracket,
        bool _autoInjection
    ) external;

    /**
     * @notice Inject funds
     * @param _lotteryId: lottery id
     * @param _amount: amount to inject in BSW token
     * @dev Callable by operator
     */
    function injectFunds(uint256 _lotteryId, uint256 _amount) external;

    /**
     * @notice Start the lottery
     * @dev Callable by operator
     * @param _endTime: endTime of the lottery
     * @param _priceTicketInUSDT: price of a ticket in BSW
     * @param _discountDivisor: the divisor to calculate the discount magnitude for bulks
     * @param _rewardsBreakdown: breakdown of rewards per bracket (must sum to 10,000)
     */
    function startLottery(
        uint256 _endTime,
        uint256 _priceTicketInUSDT,
        uint256 _discountDivisor,
        uint256[6] calldata _rewardsBreakdown
    ) external;

    /**
     * @notice View current lottery id
     */
    function viewCurrentLotteryId() external returns (uint256);

    function getCurrentTicketPriceInBSW(uint _lotteryId) external view returns(uint);
}

// File: contracts/BiswapLottery.sol
//LBC-01
pragma solidity 0.8.4;
pragma abicoder v2;

/** @title Biswap Lottery.
 * @notice It is a contract for a lottery system using
 * randomness provided externally.
 */
contract BiswapLottery is ReentrancyGuard, IBiswapLottery, Ownable {
    using SafeERC20 for IERC20;

    address public injectorAddress;
    address public operatorAddress;
    address public treasuryAddress;
    address public burningAddress;  //Send tokens from every deposit to burn
    address public competitionAndRefAddress; //Send tokens from every deposit to referrals and competitions
    address public usdtTokenAddress;
    address public bswTokenAddress;

    uint256 public currentLotteryId;
    uint256 public currentTicketId;

    uint256 public burningShare = 1300; //1300: 13%
    uint256 public competitionAndRefShare = 700; //700: 7%

    uint256 public maxNumberTicketsPerBuyOrClaim = 500; //TODO change in prod 100

    uint256 public maxPriceTicketInBSW = 50 ether;
    uint256 public minPriceTicketInBSW = 0.00000005 ether; //TODO change in prod 0.005 ether
    uint256 public maxDiffPriceUpdate = 1500; //Difference between old and new price given from oracle

    uint256 public pendingInjectionNextLottery;

    uint256 public constant MIN_DISCOUNT_DIVISOR = 500;
    uint256 public constant MIN_LENGTH_LOTTERY = /*4 hours - */ 1 minutes; // 4 hours //TODO change in prod 4 hours - 1 minutes
    uint256 public constant MAX_LENGTH_LOTTERY = 4 days + 5 minutes; // 4 days


    IERC20 public bswToken;
    IRandomNumberGenerator public randomGenerator;
    IPriceOracle public priceOracle;

    enum Status {
        Pending,
        Open,
        Close,
        Claimable
    }

    struct Lottery {
        Status status;
        uint256 startTime;
        uint256 endTime;
        uint256 priceTicketInBSW;
        uint256 priceTicketInUSDT;
        uint256 discountDivisor;    //Must be 10000 for discount 4,99% for 500 tickets
        uint256[6] rewardsBreakdown; // 0: 1 matching number // 5: 6 matching numbers
        uint256[6] bswPerBracket;
        uint256[6] countWinnersPerBracket;
        uint256 firstTicketId;
        uint256 firstTicketIdNextLottery;
        uint256 amountCollectedInBSW;
        uint256 amountInjectedInBSW;
        uint32 finalNumber;
    }

    struct Ticket {
        uint32 number;
        address owner;
    }

    // Mapping are cheaper than arrays
    mapping(uint256 => Lottery) private _lotteries;
    mapping(uint256 => Ticket) private _tickets;

    // Bracket calculator is used for verifying claims for ticket prizes
    //LBC-07

    // Keep track of user ticket ids for a given lotteryId
    mapping(address => mapping(uint256 => uint256[])) private _userTicketIdsPerLotteryId;

    modifier notContract() {
        require(!_isContract(msg.sender), "Contract not allowed");
        require(msg.sender == tx.origin, "Proxy contract not allowed");
        _;
    }

    modifier onlyOperator() {
        require(msg.sender == operatorAddress, "Not operator");
        _;
    }

    modifier onlyOwnerOrInjector() {
        require((msg.sender == owner()) || (msg.sender == injectorAddress), "Not owner or injector");
        _;
    }

    event AdminTokenRecovery(address token, uint256 amount);
    event LotteryClose(uint256 indexed lotteryId, uint256 firstTicketIdNextLottery);
    event LotteryInjection(uint256 indexed lotteryId, uint256 injectedAmount);
    event LotteryOpen(
        uint256 indexed lotteryId,
        uint256 startTime,
        uint256 endTime,
        uint256 priceTicketInUSDT,
        uint256 firstTicketId,
        uint256 injectedAmount
    );
    event LotteryNumberDrawn(uint256 indexed lotteryId, uint256 finalNumber, uint256 countWinningTickets);
    event NewManagingAddresses(
        address operator,
        address treasury,
        address injector,
        address burningAddress,
        address competitionAndRefAddress
    );
    event NewRandomGenerator(address indexed randomGenerator);
    event NewPriceOracle(address oracle);
    event TicketsPurchase(address indexed buyer, uint256 indexed lotteryId, uint256 numberTickets, uint256 amount);
    event TicketsClaim(address indexed claimer, uint256 amount, uint256 indexed lotteryId, uint256 numberTickets);

    /**
     * @notice Constructor
     * @dev RandomNumberGenerator must be deployed prior to this contract
     * @param _bswTokenAddress: address of the BSW token
     * @param _usdtTokenAddress: address of the USDT token
     * @param _randomGeneratorAddress: address of the RandomGenerator contract used to work with ChainLink VRF
     * @param _priceOracleAddress: address of oracle
     */
    constructor(
        address _bswTokenAddress,
        address _usdtTokenAddress,
        address _randomGeneratorAddress,
        address _priceOracleAddress
    ) {
        //LBC-03
        require(_bswTokenAddress != address(0), "_bswTokenAddress address cannot be 0");
        require(_usdtTokenAddress != address(0), "_usdtTokenAddress address cannot be 0");
        bswToken = IERC20(_bswTokenAddress);
        bswTokenAddress = _bswTokenAddress;
        usdtTokenAddress = _usdtTokenAddress;
        randomGenerator = IRandomNumberGenerator(_randomGeneratorAddress);
        priceOracle = IPriceOracle(_priceOracleAddress);

        //LBC-07
    }

    /**
     * @notice Buy tickets for the current lottery
     * @param _lotteryId: lotteryId
     * @param _ticketNumbers: array of ticket numbers between 1,000,000 and 1,999,999 TAKE CARE! NUMBERS IS INVERTED
     * @dev Callable by users
     */
    function buyTickets(uint256 _lotteryId, uint32[] calldata _ticketNumbers)
        external
        override
        notContract
        nonReentrant
    {
        require(_ticketNumbers.length != 0, "No ticket specified");
        require(_ticketNumbers.length <= maxNumberTicketsPerBuyOrClaim, "Too many tickets");

        require(_lotteries[_lotteryId].status == Status.Open, "Lottery is not open");
        require(block.timestamp < _lotteries[_lotteryId].endTime, "Lottery is over");

        // Update BSW price for _lotteryId
        _updateBSWPrice(_lotteryId);

        // Calculate number of BSW to this contract
        uint256 amountBSWToTransfer = _calculateTotalPriceForBulkTickets(
            _lotteries[_lotteryId].discountDivisor,
            _lotteries[_lotteryId].priceTicketInBSW,
            _ticketNumbers.length
        );

        // Transfer BSW tokens to this contract
        bswToken.safeTransferFrom(address(msg.sender), address(this), amountBSWToTransfer);

        // Increment the total amount collected for the lottery round
        _lotteries[_lotteryId].amountCollectedInBSW += amountBSWToTransfer;

        uint _currentTicketId = currentTicketId;
        for (uint256 i = 0; i < _ticketNumbers.length; i++) {
            uint32 thisTicketNumber = _ticketNumbers[i];
            uint thisCurrentTicketId = _currentTicketId++;
            require((thisTicketNumber >= 1000000) && (thisTicketNumber <= 1999999), "Outside range");

            _userTicketIdsPerLotteryId[msg.sender][_lotteryId].push(thisCurrentTicketId);
            _tickets[thisCurrentTicketId] = Ticket({number: thisTicketNumber, owner: msg.sender});
        }
        // Increase lottery ticket number
        currentTicketId += _ticketNumbers.length;

        emit TicketsPurchase(msg.sender, _lotteryId, _ticketNumbers.length, amountBSWToTransfer);
    }

    /**
     * @notice Claim a set of winning tickets for a lottery
     * @param _lotteryId: lottery id
     * @param _ticketIds: array of ticket ids
     * @param _brackets: array of brackets for the ticket ids
     * @dev Callable by users only, not contract!
     */
    function claimTickets(
        uint256 _lotteryId,
        uint256[] calldata _ticketIds,
        uint32[] calldata _brackets
    )
        external
        override
        notContract
        nonReentrant
    {
        require(_ticketIds.length == _brackets.length, "Not same length");
        require(_ticketIds.length != 0, "Length must be >0");
        require(_ticketIds.length <= maxNumberTicketsPerBuyOrClaim, "Too many tickets");
        require(_lotteries[_lotteryId].status == Status.Claimable, "Lottery not claimable");

        // Initializes the rewardInBSWToTransfer
        uint256 rewardInBSWToTransfer;

        for (uint256 i = 0; i < _ticketIds.length; i++) {
            require(_brackets[i] < 6, "Bracket out of range"); // Must be between 0 and 5

            uint256 thisTicketId = _ticketIds[i];

            require(_lotteries[_lotteryId].firstTicketIdNextLottery > thisTicketId, "TicketId too high");
            require(_lotteries[_lotteryId].firstTicketId <= thisTicketId, "TicketId too low");
            require(msg.sender == _tickets[thisTicketId].owner, "Not the owner");

            // Update the lottery ticket owner to 0x address
            _tickets[thisTicketId].owner = address(0);

            uint256 rewardForTicketId = _calculateRewardsForTicketId(_lotteryId, thisTicketId, _brackets[i]);

            // Check user is claiming the correct bracket
            require(rewardForTicketId != 0, "No prize for this bracket");

            if (_brackets[i] != 5) {
                require(
                    _calculateRewardsForTicketId(_lotteryId, thisTicketId, _brackets[i] + 1) == 0,
                    "Bracket must be higher"
                );
            }

            // Increment the reward to transfer
            rewardInBSWToTransfer += rewardForTicketId;
        }

        // Transfer money to msg.sender
        bswToken.safeTransfer(msg.sender, rewardInBSWToTransfer);

        emit TicketsClaim(msg.sender, rewardInBSWToTransfer, _lotteryId, _ticketIds.length);
    }

    function getCurrentTicketPriceInBSW(uint _lotteryId) override external view returns(uint){
        return priceOracle.consult(
            usdtTokenAddress,
            _lotteries[_lotteryId].priceTicketInUSDT,
            bswTokenAddress
        );
    }

    /**
     * @notice Close lottery
     * @param _lotteryId: lottery id
     * @dev Callable by operator
     */
    function closeLottery(uint256 _lotteryId) external override onlyOperator nonReentrant {
        require(_lotteries[_lotteryId].status == Status.Open, "Lottery not open");
        require(block.timestamp > _lotteries[_lotteryId].endTime, "Lottery not over");
        _lotteries[_lotteryId].firstTicketIdNextLottery = currentTicketId;

        _lotteries[_lotteryId].status = Status.Close;

        // Request a random number from the generator based on a seed
        randomGenerator.getRandomNumber(uint256(keccak256(abi.encodePacked(_lotteryId, currentTicketId))));

        emit LotteryClose(_lotteryId, currentTicketId);
    }

    /**
     * @notice Draw the final number, calculate reward in BSW per group, and make lottery claimable
     * @param _lotteryId: lottery id
     * @param _autoInjection: reinjects funds into next lottery (vs. withdrawing all)
     * @param _bswPerBracket: distribution of winnings by bracket
     * @param _countTicketsPerBracket: total number of tickets in each bracket
     * @dev Callable by operator
     */
    function drawFinalNumberAndMakeLotteryClaimable(
        uint256 _lotteryId,
        uint[6] calldata _bswPerBracket,
        uint[6] calldata _countTicketsPerBracket,
        bool _autoInjection
    )
        external
        override
        onlyOperator
        nonReentrant
    {
        require(_lotteries[_lotteryId].status == Status.Close, "Lottery not close");
        require(_lotteryId == randomGenerator.viewLatestLotteryId(), "Numbers not drawn");
        require(_bswPerBracket.length == 6, 'Wrong bswPerBracket array size!');
        require(_countTicketsPerBracket.length == 6, 'Wrong countTicketsPerBracket array size!');

        //Withdraw burn, referrals and competitions pool

        uint amountToDistribute = _withdrawBurnAndCompetition(_lotteryId) + pendingInjectionNextLottery;
        pendingInjectionNextLottery = 0;

        // Calculate the finalNumber based on the randomResult generated by ChainLink's fallback
        uint32 finalNumber = randomGenerator.viewRandomResult();
        uint ticketsCountPerBrackets = 0;
        uint bswSumPerBrackets = 0;
        for (uint i = 0; i < 6; i++){
            uint winningPoolPerBracket = _bswPerBracket[i] * _countTicketsPerBracket[i];
            ticketsCountPerBrackets += _countTicketsPerBracket[i];
            //LBC-06
            if(_countTicketsPerBracket[i] > 0){
                require(
                    winningPoolPerBracket <= (_lotteries[_lotteryId].rewardsBreakdown[i] * amountToDistribute) / 10000,
                    'Wrong amount on bracket'
                );
            }
            bswSumPerBrackets += winningPoolPerBracket;
        }
        require(bswSumPerBrackets <= amountToDistribute, 'Wrong brackets Total amount');

        _lotteries[_lotteryId].bswPerBracket = _bswPerBracket;
        _lotteries[_lotteryId].countWinnersPerBracket = _countTicketsPerBracket;

        // Update internal statuses for lottery
        _lotteries[_lotteryId].finalNumber = finalNumber;
        _lotteries[_lotteryId].status = Status.Claimable;

        // Transfer not winning BSW to treasury address if _autoInjection is false
        if (_autoInjection) {
            pendingInjectionNextLottery = amountToDistribute - bswSumPerBrackets;
        } else {
            bswToken.safeTransfer(treasuryAddress, amountToDistribute - bswSumPerBrackets);
        }

        emit LotteryNumberDrawn(currentLotteryId, finalNumber, ticketsCountPerBrackets);
    }

    /**
     * @notice Change the random generator
     * @dev The calls to functions are used to verify the new generator implements them properly.
     * It is necessary to wait for the VRF response before starting a round.
     * Callable only by the contract owner
     * @param _randomGeneratorAddress: address of the random generator
     */
    function changeRandomGenerator(address _randomGeneratorAddress) external onlyOwner {
        require(_lotteries[currentLotteryId].status == Status.Claimable, "Lottery not in claimable");

        // Request a random number from the generator based on a seed
        IRandomNumberGenerator(_randomGeneratorAddress).getRandomNumber(
            uint256(keccak256(abi.encodePacked(currentLotteryId, currentTicketId)))
        );

        // Calculate the finalNumber based on the randomResult generated by ChainLink's fallback
        IRandomNumberGenerator(_randomGeneratorAddress).viewRandomResult();

        randomGenerator = IRandomNumberGenerator(_randomGeneratorAddress);

        emit NewRandomGenerator(_randomGeneratorAddress);
    }

    /**
     * @notice Change price oracle
     * @param _priceOracleAddress: address for new price oracle contract
     * @dev Callable only by owner address
     */
    function changeOracle(address _priceOracleAddress) external onlyOwner {
        require(_lotteries[currentLotteryId].status == Status.Claimable, "Lottery not in claimable");
        priceOracle = IPriceOracle(_priceOracleAddress);

        emit NewPriceOracle(_priceOracleAddress);
    }

    /**
     * @notice Inject funds
     * @param _lotteryId: lottery id
     * @param _amount: amount to inject in BSW token
     * @dev Callable by owner or injector address
     */
    function injectFunds(uint256 _lotteryId, uint256 _amount) external override onlyOwnerOrInjector {
        require(_lotteries[_lotteryId].status == Status.Open, "Lottery not open");
        //LBC-02
        _lotteries[_lotteryId].amountCollectedInBSW += _amount;
        bswToken.safeTransferFrom(address(msg.sender), address(this), _amount);

        emit LotteryInjection(_lotteryId, _amount);
    }

    /**
     * @notice Start the lottery
     * @dev Callable by operator
     * @param _endTime: endTime of the lottery
     * @param _priceTicketInUSDT: price of a ticket in USDT
     * @param _discountDivisor: the divisor to calculate the discount magnitude for bulks
     * @param _rewardsBreakdown: breakdown of rewards per bracket (must sum to 10,000)
     */
    function startLottery(
        uint256 _endTime,
        uint256 _priceTicketInUSDT,
        uint256 _discountDivisor,
        uint256[6] calldata _rewardsBreakdown
    ) external override onlyOperator {
        require(
            (currentLotteryId == 0) || (_lotteries[currentLotteryId].status == Status.Claimable),
            "Not time to start lottery"
        );

        require(
            ((_endTime - block.timestamp) > MIN_LENGTH_LOTTERY) && ((_endTime - block.timestamp) < MAX_LENGTH_LOTTERY),
            "Lottery length outside of range"
        );

        //Calculation price in BSW
        uint256 _priceTicketInBSW = _getPriceInBSW(_priceTicketInUSDT);

        require(
            (_priceTicketInBSW >= minPriceTicketInBSW) && (_priceTicketInBSW <= maxPriceTicketInBSW),
            "Price ticket in BSW Outside of limits"
        );

        require(_discountDivisor >= MIN_DISCOUNT_DIVISOR, "Discount divisor too low");

        require(
            (_rewardsBreakdown[0] +
            _rewardsBreakdown[1] +
            _rewardsBreakdown[2] +
            _rewardsBreakdown[3] +
            _rewardsBreakdown[4] +
            _rewardsBreakdown[5]) == 10000,
            "Rewards must equal 10000"
        );

        currentLotteryId++;
        _lotteries[currentLotteryId] = Lottery({
            status: Status.Open,
            startTime: block.timestamp,
            endTime: _endTime,
            priceTicketInBSW: _priceTicketInBSW,
            priceTicketInUSDT: _priceTicketInUSDT,
            discountDivisor: _discountDivisor,
            rewardsBreakdown: _rewardsBreakdown,
            bswPerBracket: [uint256(0), uint256(0), uint256(0), uint256(0), uint256(0), uint256(0)],
            countWinnersPerBracket: [uint256(0), uint256(0), uint256(0), uint256(0), uint256(0), uint256(0)],
            firstTicketId: currentTicketId,
            firstTicketIdNextLottery: currentTicketId,
            amountCollectedInBSW: 0,
            amountInjectedInBSW: pendingInjectionNextLottery,
            finalNumber: 0
        });

        emit LotteryOpen(
            currentLotteryId,
            block.timestamp,
            _endTime,
            _priceTicketInUSDT,
            currentTicketId,
            pendingInjectionNextLottery
        );
    }

    /**
     * @notice It allows the admin to recover wrong tokens sent to the contract
     * @param _tokenAddress: the address of the token to withdraw
     * @param _tokenAmount: the number of token amount to withdraw
     * @dev Only callable by owner.
     */
    function recoverWrongTokens(address _tokenAddress, uint256 _tokenAmount) external onlyOwner {
        require(_tokenAddress != address(bswTokenAddress), "Cannot be BSW token");

        IERC20(_tokenAddress).safeTransfer(address(msg.sender), _tokenAmount);

        emit AdminTokenRecovery(_tokenAddress, _tokenAmount);
    }

    /**
     * @notice Set BSW price ticket upper/lower limit
     * @dev Only callable by owner
     * @param _minPriceTicketInBSW: minimum price of a ticket in BSW
     * @param _maxPriceTicketInBSW: maximum price of a ticket in BSW
     */
    function setMinAndMaxTicketPriceInBSW(uint256 _minPriceTicketInBSW, uint256 _maxPriceTicketInBSW)
        external
        onlyOwner
    {
        require(_minPriceTicketInBSW <= _maxPriceTicketInBSW, "minPrice must be < maxPrice");

        minPriceTicketInBSW = _minPriceTicketInBSW;
        maxPriceTicketInBSW = _maxPriceTicketInBSW;
    }

    /**
     * @notice Set max number of tickets
     * @dev Only callable by owner
     */
    function setMaxNumberTicketsPerBuy(uint256 _maxNumberTicketsPerBuy) external onlyOwner {
        require(_maxNumberTicketsPerBuy != 0, "Must be > 0");
        //LBC-04
        require(_maxNumberTicketsPerBuy <= MIN_DISCOUNT_DIVISOR, "Must be less than MIN_DISCOUNT_DIVISOR");
        maxNumberTicketsPerBuyOrClaim = _maxNumberTicketsPerBuy;
    }

    /**
     * @notice Set burning and competitions shares
     * @dev Only callable by owner
     */
    function setBurningAndCompetitionShare(uint256 _burningShare, uint256 _competitionAndRefShare) external onlyOwner {
        require(_burningShare != 0 && _competitionAndRefShare != 0, "Must be > 0");
        require(_lotteries[currentLotteryId].status == Status.Claimable, "Lottery not in claimable");
        burningShare = _burningShare;
        competitionAndRefShare = _competitionAndRefShare;
    }

    /**
     * @notice Set max difference between old and new price when update from oracle
     * @dev Only callable by owner
     */
    function setMaxDiffPriceUpdate(uint256 _maxDiffPriceUpdate) external onlyOwner {
        require(_maxDiffPriceUpdate != 0, "Must be > 0");
        maxDiffPriceUpdate = _maxDiffPriceUpdate;
    }

    /**
     * @notice Set operator, treasury, and injector addresses
     * @dev Only callable by owner
     * @param _operatorAddress: address of the operator
     * @param _treasuryAddress: address of the treasury
     * @param _injectorAddress: address of the injector
     * @param _burningAddress: address to collect burn tokens
     * @param _competitionAndRefAddress: address to distribute competitions and referrals shares
     */
    function setManagingAddresses(
        address _operatorAddress,
        address _treasuryAddress,
        address _injectorAddress,
        address _burningAddress,
        address _competitionAndRefAddress
    ) external onlyOwner {
        require(_operatorAddress != address(0), "Cannot be zero address");
        require(_treasuryAddress != address(0), "Cannot be zero address");
        require(_injectorAddress != address(0), "Cannot be zero address");
        require(_burningAddress != address(0), "Cannot be zero address");
        require(_competitionAndRefAddress != address(0), "Cannot be zero address");

        operatorAddress = _operatorAddress;
        treasuryAddress = _treasuryAddress;
        injectorAddress = _injectorAddress;
        burningAddress = _burningAddress;
        competitionAndRefAddress = _competitionAndRefAddress;

        emit NewManagingAddresses(
            _operatorAddress,
            _treasuryAddress,
            _injectorAddress,
            _burningAddress,
            _competitionAndRefAddress
        );
    }

    /**
     * @notice Calculate price of a set of tickets
     * @param _discountDivisor: divisor for the discount
     * @param _priceTicket price of a ticket (in BSW)
     * @param _numberTickets number of tickets to buy
     */
    function calculateTotalPriceForBulkTickets(
        uint256 _discountDivisor,
        uint256 _priceTicket,
        uint256 _numberTickets
    ) external pure returns (uint256) {
        require(_discountDivisor >= MIN_DISCOUNT_DIVISOR, "discountDivisor must be >= MIN_DISCOUNT_DIVISOR");
        require(_numberTickets != 0, "Number of tickets must be > 0");
        //LBC-08
        require(_numberTickets < _discountDivisor + 1, "numberTickets must be < discountDivisor + 1");

        return _calculateTotalPriceForBulkTickets(_discountDivisor, _priceTicket, _numberTickets);
    }

    /**
     * @notice View current lottery id
     */
    function viewCurrentLotteryId() external view override returns (uint256) {
        return currentLotteryId;
    }

    /**
     * @notice View lottery information
     * @param _lotteryId: lottery id
     */
    function viewLottery(uint256 _lotteryId) external view returns (Lottery memory) {
        return _lotteries[_lotteryId];
    }

    /**
     * @notice View ticker statuses and numbers for an array of ticket ids
     * @param _ticketIds: array of _ticketId
     */
    function viewNumbersAndStatusesForTicketIds(uint256[] calldata _ticketIds)
        external
        view
        returns (uint32[] memory, bool[] memory)
    {
        uint256 length = _ticketIds.length;
        uint32[] memory ticketNumbers = new uint32[](length);
        bool[] memory ticketStatuses = new bool[](length);

        for (uint256 i = 0; i < length; i++) {
            ticketNumbers[i] = _tickets[_ticketIds[i]].number;
            if (_tickets[_ticketIds[i]].owner == address(0)) {
                ticketStatuses[i] = true;
            } else {
                ticketStatuses[i] = false;
            }
        }

        return (ticketNumbers, ticketStatuses);
    }

    /**
     * @notice View rewards for a given ticket, providing a bracket, and lottery id
     * @dev Computations are mostly offchain. This is used to verify a ticket!
     * @param _lotteryId: lottery id
     * @param _ticketId: ticket id
     * @param _bracket: bracket for the ticketId to verify the claim and calculate rewards
     */
    function viewRewardsForTicketId(
        uint256 _lotteryId,
        uint256 _ticketId,
        uint32 _bracket
    ) external view returns (uint256) {
        // Check lottery is in claimable status
        if (_lotteries[_lotteryId].status != Status.Claimable) {
            return 0;
            }

        // Check ticketId is within range
        //LBC-09
        if (
            (_lotteries[_lotteryId].firstTicketIdNextLottery < _ticketId) ||
            (_lotteries[_lotteryId].firstTicketId >= _ticketId)
        ){
            return 0;
        }
        return _calculateRewardsForTicketId(_lotteryId, _ticketId, _bracket);
    }

    /**
     * @notice View user ticket ids, numbers, and statuses of user for a given lottery
     * @param _user: user address
     * @param _lotteryId: lottery id
     * @param _cursor: cursor to start where to retrieve the tickets
     * @param _size: the number of tickets to retrieve
     */
    function viewUserInfoForLotteryId(
        address _user,
        uint256 _lotteryId,
        uint256 _cursor,
        uint256 _size
    ) external view returns (
        uint256[] memory,
        uint32[] memory,
        bool[] memory,
        uint256
    ){
        uint256 length = _size;
        uint256 numberTicketsBoughtAtLotteryId = _userTicketIdsPerLotteryId[_user][_lotteryId].length;

        if (length > (numberTicketsBoughtAtLotteryId - _cursor)) {
            length = numberTicketsBoughtAtLotteryId - _cursor;
        }

        uint256[] memory lotteryTicketIds = new uint256[](length);
        uint32[] memory ticketNumbers = new uint32[](length);
        bool[] memory ticketStatuses = new bool[](length);

        for (uint256 i = 0; i < length; i++) {
            lotteryTicketIds[i] = _userTicketIdsPerLotteryId[_user][_lotteryId][i + _cursor];
            ticketNumbers[i] = _tickets[lotteryTicketIds[i]].number;

            // True = ticket claimed
            if (_tickets[lotteryTicketIds[i]].owner == address(0)) {
                ticketStatuses[i] = true;
            } else {
                // ticket not claimed (includes the ones that cannot be claimed)
                ticketStatuses[i] = false;
            }
        }
        return (lotteryTicketIds, ticketNumbers, ticketStatuses, _cursor + length);
    }

    /**
     * @notice Withdraw burn, referrals and competitions pool
     * @param _lotteryId: lottery Id
     * @dev Return collected amount without withdrawal burn ref and comp sum
     */
    function _withdrawBurnAndCompetition(uint _lotteryId) internal returns(uint){
        require(_lotteries[_lotteryId].status == Status.Close, "Lottery not close");

        uint collectedAmount = _lotteries[_lotteryId].amountCollectedInBSW;
        uint burnSum = (collectedAmount * burningShare) / 10000 ;
        uint competitionAndRefSum = (collectedAmount * competitionAndRefShare) / 10000 ;
        bswToken.safeTransfer(burningAddress, burnSum);
        bswToken.safeTransfer(competitionAndRefAddress, competitionAndRefSum);
        return (collectedAmount - burnSum - competitionAndRefSum);
    }

    /**
     * @notice Update BSW price for lotteryID
     */
    function _updateBSWPrice(uint256 _lotteryId) private {
        uint oldPriceInBSW = _lotteries[_lotteryId].priceTicketInBSW;
        uint newPriceInBSW = priceOracle.consult(usdtTokenAddress, _lotteries[_lotteryId].priceTicketInUSDT, bswTokenAddress);

        require(_chekPriceDifference(newPriceInBSW, oldPriceInBSW, maxDiffPriceUpdate), 'Oracle give invalid price');
        _lotteries[_lotteryId].priceTicketInBSW = newPriceInBSW;
    }

    /**
     * @notice Check difference between old and new prices
     */
    function _chekPriceDifference(uint256 _newPrice, uint256 _oldPrice, uint _maxDiff) internal pure returns(bool diff){
        require(_newPrice > 0 && _oldPrice > 0, 'Wrong prices given');
        if(_newPrice > _oldPrice){
            diff = (((_newPrice * 10000) / _oldPrice) - 10000) <= _maxDiff;
        } else {
            diff = (((_oldPrice * 10000) / _newPrice) - 10000) <= _maxDiff;
        }
    }

    /**
     * @notice Get current exchange rate BSW/USDT from oracle
     */
    function _getPriceInBSW(uint256 _priceInUSDT) internal view returns(uint256) {
        return priceOracle.consult(usdtTokenAddress, _priceInUSDT, bswTokenAddress);
    }

    /**
     * @notice Calculate rewards for a given ticket
     * @param _lotteryId: lottery id
     * @param _ticketId: ticket id
     * @param _bracket: bracket for the ticketId to verify the claim and calculate rewards
     */
    function _calculateRewardsForTicketId(
        uint256 _lotteryId,
        uint256 _ticketId,
        uint32 _bracket
    ) internal view returns (uint256) {
        // Retrieve the winning number combination
        //LBC-10
        uint32 winningTicketNumber = _lotteries[_lotteryId].finalNumber;

        // Retrieve the user number combination from the ticketId
        uint32 userNumber= _tickets[_ticketId].number;

        // Apply transformation to verify the claim provided by the user is true
        //LBC-07
        uint32 transformedWinningNumber = (winningTicketNumber % (uint32(10)**(_bracket + 1)));
        //LBC-07
        uint32 transformedUserNumber = (userNumber % (uint32(10)**(_bracket + 1)));

        // Confirm that the two transformed numbers are the same, if not throw
        if (transformedWinningNumber == transformedUserNumber) {
            return _lotteries[_lotteryId].bswPerBracket[_bracket];
        } else {
            return 0;
        }
    }

    /**
     * @notice Calculate final price for bulk of tickets
     * @param _discountDivisor: divisor for the discount (the smaller it is, the greater the discount is)
     * @param _priceTicket: price of a ticket
     * @param _numberTickets: number of tickets purchased
     */
    function _calculateTotalPriceForBulkTickets(
        uint256 _discountDivisor,
        uint256 _priceTicket,
        uint256 _numberTickets
    ) internal pure returns (uint256) {
        return (_priceTicket * _numberTickets * (_discountDivisor + 1 - _numberTickets)) / _discountDivisor;
    }

    /**
     * @notice Check if an address is a contract
     */
    function _isContract(address _addr) internal view returns (bool) {
        uint256 size;
        assembly {
            size := extcodesize(_addr)
        }
        return size > 0;
    }
}

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"_bswTokenAddress","type":"address"},{"internalType":"address","name":"_usdtTokenAddress","type":"address"},{"internalType":"address","name":"_randomGeneratorAddress","type":"address"},{"internalType":"address","name":"_priceOracleAddress","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"AdminTokenRecovery","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"lotteryId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"firstTicketIdNextLottery","type":"uint256"}],"name":"LotteryClose","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"lotteryId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"injectedAmount","type":"uint256"}],"name":"LotteryInjection","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"lotteryId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"finalNumber","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"countWinningTickets","type":"uint256"}],"name":"LotteryNumberDrawn","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"lotteryId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"startTime","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"endTime","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"priceTicketInUSDT","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"firstTicketId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"injectedAmount","type":"uint256"}],"name":"LotteryOpen","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"address","name":"treasury","type":"address"},{"indexed":false,"internalType":"address","name":"injector","type":"address"},{"indexed":false,"internalType":"address","name":"burningAddress","type":"address"},{"indexed":false,"internalType":"address","name":"competitionAndRefAddress","type":"address"}],"name":"NewManagingAddresses","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oracle","type":"address"}],"name":"NewPriceOracle","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"randomGenerator","type":"address"}],"name":"NewRandomGenerator","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"claimer","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"lotteryId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"numberTickets","type":"uint256"}],"name":"TicketsClaim","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"buyer","type":"address"},{"indexed":true,"internalType":"uint256","name":"lotteryId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"numberTickets","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"TicketsPurchase","type":"event"},{"inputs":[],"name":"MAX_LENGTH_LOTTERY","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MIN_DISCOUNT_DIVISOR","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MIN_LENGTH_LOTTERY","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"bswToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"bswTokenAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"burningAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"burningShare","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_lotteryId","type":"uint256"},{"internalType":"uint32[]","name":"_ticketNumbers","type":"uint32[]"}],"name":"buyTickets","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_discountDivisor","type":"uint256"},{"internalType":"uint256","name":"_priceTicket","type":"uint256"},{"internalType":"uint256","name":"_numberTickets","type":"uint256"}],"name":"calculateTotalPriceForBulkTickets","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"_priceOracleAddress","type":"address"}],"name":"changeOracle","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_randomGeneratorAddress","type":"address"}],"name":"changeRandomGenerator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_lotteryId","type":"uint256"},{"internalType":"uint256[]","name":"_ticketIds","type":"uint256[]"},{"internalType":"uint32[]","name":"_brackets","type":"uint32[]"}],"name":"claimTickets","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_lotteryId","type":"uint256"}],"name":"closeLottery","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"competitionAndRefAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"competitionAndRefShare","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"currentLotteryId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"currentTicketId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_lotteryId","type":"uint256"},{"internalType":"uint256[6]","name":"_bswPerBracket","type":"uint256[6]"},{"internalType":"uint256[6]","name":"_countTicketsPerBracket","type":"uint256[6]"},{"internalType":"bool","name":"_autoInjection","type":"bool"}],"name":"drawFinalNumberAndMakeLotteryClaimable","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_lotteryId","type":"uint256"}],"name":"getCurrentTicketPriceInBSW","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_lotteryId","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"injectFunds","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"injectorAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxDiffPriceUpdate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxNumberTicketsPerBuyOrClaim","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxPriceTicketInBSW","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minPriceTicketInBSW","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"operatorAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingInjectionNextLottery","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"priceOracle","outputs":[{"internalType":"contract IPriceOracle","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"randomGenerator","outputs":[{"internalType":"contract IRandomNumberGenerator","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_tokenAddress","type":"address"},{"internalType":"uint256","name":"_tokenAmount","type":"uint256"}],"name":"recoverWrongTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_burningShare","type":"uint256"},{"internalType":"uint256","name":"_competitionAndRefShare","type":"uint256"}],"name":"setBurningAndCompetitionShare","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_operatorAddress","type":"address"},{"internalType":"address","name":"_treasuryAddress","type":"address"},{"internalType":"address","name":"_injectorAddress","type":"address"},{"internalType":"address","name":"_burningAddress","type":"address"},{"internalType":"address","name":"_competitionAndRefAddress","type":"address"}],"name":"setManagingAddresses","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_maxDiffPriceUpdate","type":"uint256"}],"name":"setMaxDiffPriceUpdate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_maxNumberTicketsPerBuy","type":"uint256"}],"name":"setMaxNumberTicketsPerBuy","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_minPriceTicketInBSW","type":"uint256"},{"internalType":"uint256","name":"_maxPriceTicketInBSW","type":"uint256"}],"name":"setMinAndMaxTicketPriceInBSW","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_endTime","type":"uint256"},{"internalType":"uint256","name":"_priceTicketInUSDT","type":"uint256"},{"internalType":"uint256","name":"_discountDivisor","type":"uint256"},{"internalType":"uint256[6]","name":"_rewardsBreakdown","type":"uint256[6]"}],"name":"startLottery","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"treasuryAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"usdtTokenAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"viewCurrentLotteryId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_lotteryId","type":"uint256"}],"name":"viewLottery","outputs":[{"components":[{"internalType":"enum BiswapLottery.Status","name":"status","type":"uint8"},{"internalType":"uint256","name":"startTime","type":"uint256"},{"internalType":"uint256","name":"endTime","type":"uint256"},{"internalType":"uint256","name":"priceTicketInBSW","type":"uint256"},{"internalType":"uint256","name":"priceTicketInUSDT","type":"uint256"},{"internalType":"uint256","name":"discountDivisor","type":"uint256"},{"internalType":"uint256[6]","name":"rewardsBreakdown","type":"uint256[6]"},{"internalType":"uint256[6]","name":"bswPerBracket","type":"uint256[6]"},{"internalType":"uint256[6]","name":"countWinnersPerBracket","type":"uint256[6]"},{"internalType":"uint256","name":"firstTicketId","type":"uint256"},{"internalType":"uint256","name":"firstTicketIdNextLottery","type":"uint256"},{"internalType":"uint256","name":"amountCollectedInBSW","type":"uint256"},{"internalType":"uint256","name":"amountInjectedInBSW","type":"uint256"},{"internalType":"uint32","name":"finalNumber","type":"uint32"}],"internalType":"struct BiswapLottery.Lottery","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_ticketIds","type":"uint256[]"}],"name":"viewNumbersAndStatusesForTicketIds","outputs":[{"internalType":"uint32[]","name":"","type":"uint32[]"},{"internalType":"bool[]","name":"","type":"bool[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_lotteryId","type":"uint256"},{"internalType":"uint256","name":"_ticketId","type":"uint256"},{"internalType":"uint32","name":"_bracket","type":"uint32"}],"name":"viewRewardsForTicketId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint256","name":"_lotteryId","type":"uint256"},{"internalType":"uint256","name":"_cursor","type":"uint256"},{"internalType":"uint256","name":"_size","type":"uint256"}],"name":"viewUserInfoForLotteryId","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"uint32[]","name":"","type":"uint32[]"},{"internalType":"bool[]","name":"","type":"bool[]"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]

6080604052610514600b556102bc600c556101f4600d556802b5e3af16b1880000600e55640ba43b7400600f556105dc6010553480156200003f57600080fd5b506040516200439b3803806200439b8339810160408190526200006291620001f4565b6001600081815581546001600160a01b031916339081179092556040518291907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a3506001600160a01b038416620001105760405162461bcd60e51b8152602060048201526024808201527f5f627377546f6b656e4164647265737320616464726573732063616e6e6f74206044820152630626520360e41b60648201526084015b60405180910390fd5b6001600160a01b038316620001765760405162461bcd60e51b815260206004820152602560248201527f5f75736474546f6b656e4164647265737320616464726573732063616e6e6f74604482015264020626520360dc1b606482015260840162000107565b601280546001600160a01b039586166001600160a01b03199182168117909255600880548216909217909155600780549486169482169490941790935560138054928516928416929092179091556014805491909316911617905562000250565b80516001600160a01b0381168114620001ef57600080fd5b919050565b600080600080608085870312156200020a578384fd5b6200021585620001d7565b93506200022560208601620001d7565b92506200023560408601620001d7565b91506200024560608601620001d7565b905092959194509250565b61413b80620002606000396000f3fe608060405234801561001057600080fd5b506004361061028a5760003560e01c80636be4097c1161015c5780639d8ca531116100ce578063db19da0d11610087578063db19da0d14610562578063dcbad90d1461056c578063e0db83f61461057f578063e2c1b0a014610592578063f2fde38b146105a5578063f88a4877146105b857600080fd5b80639d8ca531146104f0578063ac6ac2c614610503578063ad34a3ae14610516578063c4937ab914610529578063c5f956af1461053c578063c914914f1461054f57600080fd5b806388303dbd1161012057806388303dbd146104725780638da5cb5b146104855780638fc3539a1461049657806398359fa1146104b75780639c384653146104ca5780639d741e5d146104dd57600080fd5b80636be4097c1461043d578063715018a6146104465780637abc3c5b1461044e5780637cb583bd1461046157806380a061601461046a57600080fd5b80632e530cae11610200578063471aeab4116101b9578063471aeab4146103d557806347c421b5146103e857806348112396146103fb5780635f62a9581461040e578063686465b8146104215780636b8737881461042a57600080fd5b80632e530cae1461037757806336007bae1461038a5780633705da0f146103935780633bf186d0146103a65780633f138d4b146103b9578063455498b2146103cc57600080fd5b806312a9769d1161025257806312a9769d1461030a5780631fe86c6b146103135780631ff4770e1461031c57806323a237e2146103315780632423807a146103445780632630c12f1461036457600080fd5b80630431bb621461028f57806305531eeb146102ab578063062cf079146102ce57806307fb5a9c146102d7578063127effb2146102df575b600080fd5b610298600c5481565b6040519081526020015b60405180910390f35b6102be6102b936600461383d565b6105c1565b6040516102a29493929190613be2565b610298600e5481565b610298603c81565b6003546102f2906001600160a01b031681565b6040516001600160a01b0390911681526020016102a2565b61029860115481565b610298600d5481565b61032f61032a366004613a14565b610939565b005b61029861033f3660046138d1565b6109f4565b6103576103523660046138d1565b610aa4565b6040516102a29190613dcc565b6014546102f2906001600160a01b031681565b610298610385366004613aa0565b610c29565b610298600b5481565b61032f6103a13660046138d1565b610cbd565b6012546102f2906001600160a01b031681565b61032f6103c7366004613814565b610d09565b610298600f5481565b61032f6103e3366004613a14565b610de1565b61032f6103f6366004613796565b610f37565b6005546102f2906001600160a01b031681565b6006546102f2906001600160a01b031681565b610298600a5481565b61032f6104383660046138d1565b611008565b61029860095481565b61032f6110b5565b61032f61045c3660046137b0565b611129565b6102986101f481565b600954610298565b61032f6104803660046139ca565b6112c2565b6001546001600160a01b03166102f2565b6104a96104a4366004613875565b6116e3565b6040516102a2929190613c56565b61032f6104c5366004613796565b6118ff565b6002546102f2906001600160a01b031681565b6007546102f2906001600160a01b031681565b61032f6104fe3660046138d1565b611acb565b6008546102f2906001600160a01b031681565b61032f610524366004613a60565b611cdb565b610298610537366004613a35565b6121c3565b6004546102f2906001600160a01b031681565b61032f61055d366004613953565b6122f4565b6102986205472c81565b6013546102f2906001600160a01b031681565b61032f61058d366004613901565b6128b1565b61032f6105a0366004613a14565b612dc2565b61032f6105b3366004613796565b612e47565b61029860105481565b6001600160a01b0384166000908152601760209081526040808320868452909152812054606091829182919085906105f98882614035565b82111561060d5761060a8882614035565b91505b60008267ffffffffffffffff81111561063657634e487b7160e01b600052604160045260246000fd5b60405190808252806020026020018201604052801561065f578160200160208202803683370190505b50905060008367ffffffffffffffff81111561068b57634e487b7160e01b600052604160045260246000fd5b6040519080825280602002602001820160405280156106b4578160200160208202803683370190505b50905060008467ffffffffffffffff8111156106e057634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015610709578160200160208202803683370190505b50905060005b8581101561091357601760008f6001600160a01b03166001600160a01b0316815260200190815260200160002060008e81526020019081526020016000208c826107599190613e94565b8154811061077757634e487b7160e01b600052603260045260246000fd5b90600052602060002001548482815181106107a257634e487b7160e01b600052603260045260246000fd5b602002602001018181525050601660008583815181106107d257634e487b7160e01b600052603260045260246000fd5b6020026020010151815260200190815260200160002060000160009054906101000a900463ffffffff1683828151811061081c57634e487b7160e01b600052603260045260246000fd5b602002602001019063ffffffff16908163ffffffff168152505060006001600160a01b03166016600086848151811061086557634e487b7160e01b600052603260045260246000fd5b60209081029190910181015182528101919091526040016000205464010000000090046001600160a01b031614156108ce5760018282815181106108b957634e487b7160e01b600052603260045260246000fd5b91151560209283029190910190910152610901565b60008282815181106108f057634e487b7160e01b600052603260045260246000fd5b911515602092830291909101909101525b8061090b81614078565b91505061070f565b50828282610921888f613e94565b98509850985098505050505050945094509450949050565b6001546001600160a01b0316331461096c5760405162461bcd60e51b815260040161096390613cde565b60405180910390fd5b811580159061097a57508015155b6109965760405162461bcd60e51b815260040161096390613d13565b600360095460009081526015602052604090205460ff1660038111156109cc57634e487b7160e01b600052602160045260246000fd5b146109e95760405162461bcd60e51b815260040161096390613d38565b600b91909155600c55565b6014546007546000838152601560205260408082206004908101546008549251632321bc7960e21b81526001600160a01b03958616928101929092526024820152908316604482015290929190911690638c86f1e4906064015b60206040518083038186803b158015610a6657600080fd5b505afa158015610a7a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a9e91906138e9565b92915050565b610aac6135ff565b6000828152601560205260409081902081516101c081019092528054829060ff166003811115610aec57634e487b7160e01b600052602160045260246000fd5b6003811115610b0b57634e487b7160e01b600052602160045260246000fd5b81526001820154602082015260028201546040808301919091526003830154606083015260048301546080830152600583015460a0830152805160c080820192839052909201919060068085019182845b815481526020019060010190808311610b5c5750505091835250506040805160c081019182905260209092019190600c84019060069082845b815481526020019060010190808311610b955750505091835250506040805160c081019182905260209092019190601284019060069082845b815481526020019060010190808311610bce5750505091835250506018820154602082015260198201546040820152601a8201546060820152601b8201546080820152601c9091015463ffffffff1660a09091015292915050565b6000600360008581526015602052604090205460ff166003811115610c5e57634e487b7160e01b600052602160045260246000fd5b14610c6b57506000610cb6565b600084815260156020526040902060190154831180610c9b57506000848152601560205260409020601801548311155b15610ca857506000610cb6565b610cb3848484612f32565b90505b9392505050565b6001546001600160a01b03163314610ce75760405162461bcd60e51b815260040161096390613cde565b80610d045760405162461bcd60e51b815260040161096390613d13565b601055565b6001546001600160a01b03163314610d335760405162461bcd60e51b815260040161096390613cde565b6008546001600160a01b0383811691161415610d875760405162461bcd60e51b815260206004820152601360248201527221b0b73737ba103132902129ab903a37b5b2b760691b6044820152606401610963565b610d9b6001600160a01b0383163383613007565b604080516001600160a01b0384168152602081018390527f74545154aac348a3eac92596bd1971957ca94795f4e954ec5f613b55fab78129910160405180910390a15050565b6001546001600160a01b0316331480610e0457506002546001600160a01b031633145b610e485760405162461bcd60e51b81526020600482015260156024820152742737ba1037bbb732b91037b91034b73532b1ba37b960591b6044820152606401610963565b600160008381526015602052604090205460ff166003811115610e7b57634e487b7160e01b600052602160045260246000fd5b14610ebb5760405162461bcd60e51b815260206004820152601060248201526f2637ba3a32b93c903737ba1037b832b760811b6044820152606401610963565b6000828152601560205260408120601a018054839290610edc908490613e94565b9091555050601254610ef9906001600160a01b031633308461306f565b817f1bbd659dd628a25f7ff2eabb69c74a56939c539728282275c1c9c1a2d3e3404982604051610f2b91815260200190565b60405180910390a25050565b6001546001600160a01b03163314610f615760405162461bcd60e51b815260040161096390613cde565b600360095460009081526015602052604090205460ff166003811115610f9757634e487b7160e01b600052602160045260246000fd5b14610fb45760405162461bcd60e51b815260040161096390613d38565b601480546001600160a01b0319166001600160a01b0383169081179091556040519081527ff261845a790fe29bbd6631e2ca4a5bdc83e6eed7c3271d9590d97287e00e91239060200160405180910390a150565b6001546001600160a01b031633146110325760405162461bcd60e51b815260040161096390613cde565b8061104f5760405162461bcd60e51b815260040161096390613d13565b6101f48111156110b05760405162461bcd60e51b815260206004820152602660248201527f4d757374206265206c657373207468616e204d494e5f444953434f554e545f4460448201526524ab24a9a7a960d11b6064820152608401610963565b600d55565b6001546001600160a01b031633146110df5760405162461bcd60e51b815260040161096390613cde565b6001546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600180546001600160a01b0319169055565b6001546001600160a01b031633146111535760405162461bcd60e51b815260040161096390613cde565b6001600160a01b0385166111795760405162461bcd60e51b815260040161096390613cae565b6001600160a01b03841661119f5760405162461bcd60e51b815260040161096390613cae565b6001600160a01b0383166111c55760405162461bcd60e51b815260040161096390613cae565b6001600160a01b0382166111eb5760405162461bcd60e51b815260040161096390613cae565b6001600160a01b0381166112115760405162461bcd60e51b815260040161096390613cae565b600380546001600160a01b038781166001600160a01b031992831681179093556004805488831690841681179091556002805488841690851681179091556005805488851690861681179091556006805494881694909516841790945560408051958652602086019290925290840152606083019190915260808201527f07fd8bbbe49d28f465fba29126fb478bcf6cd4016edd4a27f21dd31ce5f45bca9060a00160405180910390a15050505050565b333b156113085760405162461bcd60e51b815260206004820152601460248201527310dbdb9d1c9858dd081b9bdd08185b1b1bddd95960621b6044820152606401610963565b3332146113575760405162461bcd60e51b815260206004820152601a60248201527f50726f787920636f6e7472616374206e6f7420616c6c6f7765640000000000006044820152606401610963565b6002600054141561137a5760405162461bcd60e51b815260040161096390613d6f565b6002600055806113c25760405162461bcd60e51b8152602060048201526013602482015272139bc81d1a58dad95d081cdc1958da599a5959606a1b6044820152606401610963565b600d548111156114075760405162461bcd60e51b815260206004820152601060248201526f546f6f206d616e79207469636b65747360801b6044820152606401610963565b600160008481526015602052604090205460ff16600381111561143a57634e487b7160e01b600052602160045260246000fd5b1461147d5760405162461bcd60e51b81526020600482015260136024820152722637ba3a32b93c9034b9903737ba1037b832b760691b6044820152606401610963565b60008381526015602052604090206002015442106114cf5760405162461bcd60e51b815260206004820152600f60248201526e2637ba3a32b93c9034b99037bb32b960891b6044820152606401610963565b6114d8836130ad565b600083815260156020526040812060058101546003909101546114fc9190846131cd565b601254909150611517906001600160a01b031633308461306f565b6000848152601560205260408120601a018054839290611538908490613e94565b9091555050600a5460005b8381101561167f57600085858381811061156d57634e487b7160e01b600052603260045260246000fd5b90506020020160208101906115829190613ad8565b905060008361159081614078565b94509050620f42408263ffffffff16101580156115b65750621e847f8263ffffffff1611155b6115f25760405162461bcd60e51b815260206004820152600d60248201526c4f7574736964652072616e676560981b6044820152606401610963565b3360008181526017602090815260408083208c845282528083208054600181018255908452828420018590558051808201825263ffffffff9687168152808301948552948352601690915290209151825491516001600160a01b0316640100000000026001600160c01b03199092169316929092179190911790558061167781614078565b915050611543565b5083839050600a60008282546116959190613e94565b90915550506040805184815260208101849052869133917f99571045378024016a70e79972e0743cf15946f0c755d29ed219357ad60aa0aa910160405180910390a350506001600055505050565b6060808260008167ffffffffffffffff81111561171057634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015611739578160200160208202803683370190505b50905060008267ffffffffffffffff81111561176557634e487b7160e01b600052604160045260246000fd5b60405190808252806020026020018201604052801561178e578160200160208202803683370190505b50905060005b838110156118f057601660008989848181106117c057634e487b7160e01b600052603260045260246000fd5b90506020020135815260200190815260200160002060000160009054906101000a900463ffffffff1683828151811061180957634e487b7160e01b600052603260045260246000fd5b63ffffffff9092166020928302919091019091015260006016818a8a8581811061184357634e487b7160e01b600052603260045260246000fd5b602090810292909201358352508101919091526040016000205464010000000090046001600160a01b031614156118ab57600182828151811061189657634e487b7160e01b600052603260045260246000fd5b911515602092830291909101909101526118de565b60008282815181106118cd57634e487b7160e01b600052603260045260246000fd5b911515602092830291909101909101525b806118e881614078565b915050611794565b509093509150505b9250929050565b6001546001600160a01b031633146119295760405162461bcd60e51b815260040161096390613cde565b600360095460009081526015602052604090205460ff16600381111561195f57634e487b7160e01b600052602160045260246000fd5b1461197c5760405162461bcd60e51b815260040161096390613d38565b806001600160a01b031663b37217a4600954600a546040516020016119ab929190918252602082015260400190565b60408051808303601f1901815290829052805160209091012060e083901b6001600160e01b03191682526004820152602401600060405180830381600087803b1580156119f757600080fd5b505af1158015611a0b573d6000803e3d6000fd5b50505050806001600160a01b031663a1c4f55a6040518163ffffffff1660e01b815260040160206040518083038186803b158015611a4857600080fd5b505afa158015611a5c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a809190613af4565b50601380546001600160a01b0319166001600160a01b0383169081179091556040517f383f8cb39dfa7c3fb901a460dd449ea924868f0a92ff03da64740fffa5f1de6290600090a250565b6003546001600160a01b03163314611af55760405162461bcd60e51b815260040161096390613da6565b60026000541415611b185760405162461bcd60e51b815260040161096390613d6f565b6002600055600160008281526015602052604090205460ff166003811115611b5057634e487b7160e01b600052602160045260246000fd5b14611b905760405162461bcd60e51b815260206004820152601060248201526f2637ba3a32b93c903737ba1037b832b760811b6044820152606401610963565b6000818152601560205260409020600201544211611be35760405162461bcd60e51b815260206004820152601060248201526f2637ba3a32b93c903737ba1037bb32b960811b6044820152606401610963565b600a80546000838152601560209081526040918290206019810193909355825460ff191660021790925560135492548151928301859052908201526001600160a01b039091169063b37217a49060600160408051808303601f1901815290829052805160209091012060e083901b6001600160e01b03191682526004820152602401600060405180830381600087803b158015611c7f57600080fd5b505af1158015611c93573d6000803e3d6000fd5b50505050807f3728e75294796694d59d2ffced9c394279baf7b9ebd2702db43f5f04bac67929600a54604051611ccb91815260200190565b60405180910390a2506001600055565b6003546001600160a01b03163314611d055760405162461bcd60e51b815260040161096390613da6565b6009541580611d475750600360095460009081526015602052604090205460ff166003811115611d4557634e487b7160e01b600052602160045260246000fd5b145b611d935760405162461bcd60e51b815260206004820152601960248201527f4e6f742074696d6520746f207374617274206c6f7474657279000000000000006044820152606401610963565b603c611d9f4286614035565b118015611db757506205472c611db54286614035565b105b611e035760405162461bcd60e51b815260206004820152601f60248201527f4c6f7474657279206c656e677468206f757473696465206f662072616e6765006044820152606401610963565b6000611e0e84613204565b9050600f548110158015611e245750600e548111155b611e7e5760405162461bcd60e51b815260206004820152602560248201527f5072696365207469636b657420696e20425357204f757473696465206f66206c604482015264696d69747360d81b6064820152608401610963565b6101f4831015611ed05760405162461bcd60e51b815260206004820152601860248201527f446973636f756e742064697669736f7220746f6f206c6f7700000000000000006044820152606401610963565b60a0820135608083013560608401356040850135611ef360208701358735613e94565b611efd9190613e94565b611f079190613e94565b611f119190613e94565b611f1b9190613e94565b61271014611f6b5760405162461bcd60e51b815260206004820152601860248201527f52657761726473206d75737420657175616c20313030303000000000000000006044820152606401610963565b60098054906000611f7b83614078565b9091555050604080516101c081019091528060018152602001428152602001868152602001828152602001858152602001848152602001836006806020026040519081016040528092919082600660200280828437600092018290525092845250506040805160c0808201835283825260208281018590528284018590526060808401869052608080850187905260a0808601889052838901959095528551808501875287815280840188905280870188905280830188905280820188905280860188905286890152600a549188018290528701529185018490526011549085015260e0909301829052600954825260159092522081518154829060ff1916600183600381111561209c57634e487b7160e01b600052602160045260246000fd5b02179055506020820151600182015560408201516002820155606082015160038201556080820151600482015560a0820151600582015560c08201516120e89060068084019190613687565b5060e08201516120fe90600c8301906006613687565b506101008201516121159060128301906006613687565b5061012082015160188201556101408201516019820155610160820151601a820155610180820151601b8201556101a090910151601c909101805463ffffffff191663ffffffff909216919091179055600954600a5460115460408051428152602081018a9052908101889052606081019290925260808201527f367e70f8c0e0c0a6504d92172bda155c02022d532fc85b5d66a9c49e31c8bc779060a00160405180910390a25050505050565b60006101f484101561222f5760405162461bcd60e51b815260206004820152602f60248201527f646973636f756e7444697669736f72206d757374206265203e3d204d494e5f4460448201526e24a9a1a7aaa72a2fa224ab24a9a7a960891b6064820152608401610963565b8161227c5760405162461bcd60e51b815260206004820152601d60248201527f4e756d626572206f66207469636b657473206d757374206265203e20300000006044820152606401610963565b612287846001613e94565b82106122e95760405162461bcd60e51b815260206004820152602b60248201527f6e756d6265725469636b657473206d757374206265203c20646973636f756e7460448201526a44697669736f72202b203160a81b6064820152608401610963565b610cb38484846131cd565b333b1561233a5760405162461bcd60e51b815260206004820152601460248201527310dbdb9d1c9858dd081b9bdd08185b1b1bddd95960621b6044820152606401610963565b3332146123895760405162461bcd60e51b815260206004820152601a60248201527f50726f787920636f6e7472616374206e6f7420616c6c6f7765640000000000006044820152606401610963565b600260005414156123ac5760405162461bcd60e51b815260040161096390613d6f565b60026000558281146123f25760405162461bcd60e51b815260206004820152600f60248201526e09cdee840e6c2daca40d8cadccee8d608b1b6044820152606401610963565b826124335760405162461bcd60e51b815260206004820152601160248201527004c656e677468206d757374206265203e3607c1b6044820152606401610963565b600d548311156124785760405162461bcd60e51b815260206004820152601060248201526f546f6f206d616e79207469636b65747360801b6044820152606401610963565b600360008681526015602052604090205460ff1660038111156124ab57634e487b7160e01b600052602160045260246000fd5b146124f05760405162461bcd60e51b81526020600482015260156024820152744c6f7474657279206e6f7420636c61696d61626c6560581b6044820152606401610963565b6000805b8481101561284f57600684848381811061251e57634e487b7160e01b600052603260045260246000fd5b90506020020160208101906125339190613ad8565b63ffffffff161061257d5760405162461bcd60e51b8152602060048201526014602482015273427261636b6574206f7574206f662072616e676560601b6044820152606401610963565b600086868381811061259f57634e487b7160e01b600052603260045260246000fd5b90506020020135905080601560008a815260200190815260200160002060190154116126015760405162461bcd60e51b81526020600482015260116024820152700a8d2c6d6cae892c840e8dede40d0d2ced607b1b6044820152606401610963565b6000888152601560205260409020601801548110156126555760405162461bcd60e51b815260206004820152601060248201526f5469636b6574496420746f6f206c6f7760801b6044820152606401610963565b60008181526016602052604090205464010000000090046001600160a01b031633146126b35760405162461bcd60e51b815260206004820152600d60248201526c2737ba103a34329037bbb732b960991b6044820152606401610963565b60008181526016602052604081208054640100000000600160c01b031916905561271289838888878181106126f857634e487b7160e01b600052603260045260246000fd5b905060200201602081019061270d9190613ad8565b612f32565b9050806127615760405162461bcd60e51b815260206004820152601960248201527f4e6f207072697a6520666f72207468697320627261636b6574000000000000006044820152606401610963565b85858481811061278157634e487b7160e01b600052603260045260246000fd5b90506020020160208101906127969190613ad8565b63ffffffff1660051461282e576127e889838888878181106127c857634e487b7160e01b600052603260045260246000fd5b90506020020160208101906127dd9190613ad8565b61270d906001613eac565b1561282e5760405162461bcd60e51b8152602060048201526016602482015275213930b1b5b2ba1036bab9ba103132903434b3b432b960511b6044820152606401610963565b6128388185613e94565b93505050808061284790614078565b9150506124f4565b50601254612867906001600160a01b03163383613007565b6040805182815260208101869052879133917f0f5fca62da8fb5d95525b49e5eaa7b20bc6bd9e2f6b64b493442d1c0bd6ef486910160405180910390a35050600160005550505050565b6003546001600160a01b031633146128db5760405162461bcd60e51b815260040161096390613da6565b600260005414156128fe5760405162461bcd60e51b815260040161096390613d6f565b600260008181558581526015602052604090205460ff16600381111561293457634e487b7160e01b600052602160045260246000fd5b146129755760405162461bcd60e51b81526020600482015260116024820152704c6f7474657279206e6f7420636c6f736560781b6044820152606401610963565b601360009054906101000a90046001600160a01b03166001600160a01b031663fbe5d9176040518163ffffffff1660e01b815260040160206040518083038186803b1580156129c357600080fd5b505afa1580156129d7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129fb91906138e9565b8414612a3d5760405162461bcd60e51b8152602060048201526011602482015270273ab6b132b939903737ba10323930bbb760791b6044820152606401610963565b6000601154612a4b8661324f565b612a559190613e94565b905060006011819055506000601360009054906101000a90046001600160a01b03166001600160a01b031663a1c4f55a6040518163ffffffff1660e01b815260040160206040518083038186803b158015612aaf57600080fd5b505afa158015612ac3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ae79190613af4565b905060008060005b6006811015612c6d576000878260068110612b1a57634e487b7160e01b600052603260045260246000fd5b6020020135898360068110612b3f57634e487b7160e01b600052603260045260246000fd5b6020020135612b4e9190614016565b9050878260068110612b7057634e487b7160e01b600052603260045260246000fd5b602002013584612b809190613e94565b93506000888360068110612ba457634e487b7160e01b600052603260045260246000fd5b60200201351115612c4d5761271086601560008d81526020019081526020016000206006018460068110612be857634e487b7160e01b600052603260045260246000fd5b0154612bf49190614016565b612bfe9190613ed4565b811115612c4d5760405162461bcd60e51b815260206004820152601760248201527f57726f6e6720616d6f756e74206f6e20627261636b65740000000000000000006044820152606401610963565b612c578184613e94565b9250508080612c6590614078565b915050612aef565b5083811115612cbe5760405162461bcd60e51b815260206004820152601b60248201527f57726f6e6720627261636b65747320546f74616c20616d6f756e7400000000006044820152606401610963565b6000888152601560205260409020612cdb90600c018860066136c5565b506000888152601560205260409020612cf9906012018760066136c5565b506000888152601560205260409020601c8101805463ffffffff861663ffffffff19909116179055805460ff191660031790558415612d4457612d3c8185614035565b601155612d71565b600454612d71906001600160a01b0316612d5e8387614035565b6012546001600160a01b03169190613007565b6009546040805163ffffffff86168152602081018590527f98e31a6607b8b15b4d5b91de54f4c09ffe4c4cf162aa532c70b5213754e2e703910160405180910390a250506001600055505050505050565b6001546001600160a01b03163314612dec5760405162461bcd60e51b815260040161096390613cde565b80821115612e3c5760405162461bcd60e51b815260206004820152601b60248201527f6d696e5072696365206d757374206265203c206d6178507269636500000000006044820152606401610963565b600f91909155600e55565b6001546001600160a01b03163314612e715760405162461bcd60e51b815260040161096390613cde565b6001600160a01b038116612ed65760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610963565b6001546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600180546001600160a01b0319166001600160a01b0392909216919091179055565b6000838152601560209081526040808320601c0154858452601690925282205463ffffffff918216911682612f68856001613eac565b612f7390600a613f2d565b612f7d9084614093565b90506000612f8c866001613eac565b612f9790600a613f2d565b612fa19084614093565b90508063ffffffff168263ffffffff161415612ffa576000888152601560205260409020600c0163ffffffff871660068110612fed57634e487b7160e01b600052603260045260246000fd5b0154945050505050610cb6565b6000945050505050610cb6565b6040516001600160a01b03831660248201526044810182905261306a90849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261336f565b505050565b6040516001600160a01b03808516602483015283166044820152606481018290526130a79085906323b872dd60e01b90608401613033565b50505050565b60008181526015602052604080822060038101546014546007546004938401546008549551632321bc7960e21b81526001600160a01b0392831695810195909552602485015293841660448401529093921690638c86f1e49060640160206040518083038186803b15801561312157600080fd5b505afa158015613135573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061315991906138e9565b90506131688183601054613441565b6131b45760405162461bcd60e51b815260206004820152601960248201527f4f7261636c65206769766520696e76616c6964207072696365000000000000006044820152606401610963565b6000928352601560205260409092206003019190915550565b600083826131dc826001613e94565b6131e69190614035565b6131f08486614016565b6131fa9190614016565b610cb39190613ed4565b601454600754600854604051632321bc7960e21b81526001600160a01b0392831660048201526024810185905290821660448201526000929190911690638c86f1e490606401610a4e565b6000600260008381526015602052604090205460ff16600381111561328457634e487b7160e01b600052602160045260246000fd5b146132c55760405162461bcd60e51b81526020600482015260116024820152704c6f7474657279206e6f7420636c6f736560781b6044820152606401610963565b6000828152601560205260408120601a0154600b54909190612710906132eb9084614016565b6132f59190613ed4565b90506000612710600c548461330a9190614016565b6133149190613ed4565b600554601254919250613334916001600160a01b03908116911684613007565b600654601254613351916001600160a01b03918216911683613007565b8061335c8385614035565b6133669190614035565b95945050505050565b60006133c4826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166134f49092919063ffffffff16565b80519091501561306a57808060200190518101906133e291906138b5565b61306a5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610963565b600080841180156134525750600083115b6134935760405162461bcd60e51b81526020600482015260126024820152712bb937b73390383934b1b2b99033b4bb32b760711b6044820152606401610963565b828411156134c75781612710846134aa8783614016565b6134b49190613ed4565b6134be9190614035565b11159050610cb6565b81612710856134d68683614016565b6134e09190613ed4565b6134ea9190614035565b1115949350505050565b6060610cb3848460008585843b61354d5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610963565b600080866001600160a01b031685876040516135699190613bc6565b60006040518083038185875af1925050503d80600081146135a6576040519150601f19603f3d011682016040523d82523d6000602084013e6135ab565b606091505b50915091506135bb8282866135c6565b979650505050505050565b606083156135d5575081610cb6565b8251156135e55782518084602001fd5b8160405162461bcd60e51b81526004016109639190613c7b565b604080516101c081019091528060008152602001600081526020016000815260200160008152602001600081526020016000815260200161363e6136f3565b815260200161364b6136f3565b81526020016136586136f3565b815260200160008152602001600081526020016000815260200160008152602001600063ffffffff1681525090565b82600681019282156136b5579160200282015b828111156136b557825182559160200191906001019061369a565b506136c1929150613711565b5090565b82600681019282156136b5579160200282015b828111156136b55782358255916020019190600101906136d8565b6040518060c001604052806006906020820280368337509192915050565b5b808211156136c15760008155600101613712565b80356001600160a01b038116811461373d57600080fd5b919050565b8060c08101831015610a9e57600080fd5b60008083601f840112613764578182fd5b50813567ffffffffffffffff81111561377b578182fd5b6020830191508360208260051b85010111156118f857600080fd5b6000602082840312156137a7578081fd5b610cb682613726565b600080600080600060a086880312156137c7578081fd5b6137d086613726565b94506137de60208701613726565b93506137ec60408701613726565b92506137fa60608701613726565b915061380860808701613726565b90509295509295909350565b60008060408385031215613826578182fd5b61382f83613726565b946020939093013593505050565b60008060008060808587031215613852578384fd5b61385b85613726565b966020860135965060408601359560600135945092505050565b60008060208385031215613887578182fd5b823567ffffffffffffffff81111561389d578283fd5b6138a985828601613753565b90969095509350505050565b6000602082840312156138c6578081fd5b8151610cb6816140e2565b6000602082840312156138e2578081fd5b5035919050565b6000602082840312156138fa578081fd5b5051919050565b6000806000806101c08587031215613917578384fd5b843593506139288660208701613742565b92506139378660e08701613742565b91506101a0850135613948816140e2565b939692955090935050565b60008060008060006060868803121561396a578081fd5b85359450602086013567ffffffffffffffff80821115613988578283fd5b61399489838a01613753565b909650945060408801359150808211156139ac578283fd5b506139b988828901613753565b969995985093965092949392505050565b6000806000604084860312156139de578283fd5b83359250602084013567ffffffffffffffff8111156139fb578283fd5b613a0786828701613753565b9497909650939450505050565b60008060408385031215613a26578081fd5b50508035926020909101359150565b600080600060608486031215613a49578081fd5b505081359360208301359350604090920135919050565b6000806000806101208587031215613a76578182fd5b843593506020850135925060408501359150613a958660608701613742565b905092959194509250565b600080600060608486031215613ab4578081fd5b83359250602084013591506040840135613acd816140f3565b809150509250925092565b600060208284031215613ae9578081fd5b8135610cb6816140f3565b600060208284031215613b05578081fd5b8151610cb6816140f3565b6000815180845260208085019450808401835b83811015613b41578151151587529582019590820190600101613b23565b509495945050505050565b8060005b60068110156130a7578151845260209384019390910190600101613b50565b6000815180845260208085019450808401835b83811015613b4157815163ffffffff1687529582019590820190600101613b82565b60048110613bc257634e487b7160e01b600052602160045260246000fd5b9052565b60008251613bd881846020870161404c565b9190910192915050565b6080808252855190820181905260009060209060a0840190828901845b82811015613c1b57815184529284019290840190600101613bff565b50505083810382850152613c2f8188613b6f565b9150508281036040840152613c448186613b10565b91505082606083015295945050505050565b604081526000613c696040830185613b6f565b82810360208401526133668185613b10565b6020815260008251806020840152613c9a81604085016020870161404c565b601f01601f19169190910160400192915050565b60208082526016908201527543616e6e6f74206265207a65726f206164647265737360501b604082015260600190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252600b908201526a04d757374206265203e20360ac1b604082015260600190565b60208082526018908201527f4c6f7474657279206e6f7420696e20636c61696d61626c650000000000000000604082015260600190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b6020808252600c908201526b2737ba1037b832b930ba37b960a11b604082015260600190565b60006103a082019050613de0828451613ba4565b6020830151602083015260408301516040830152606083015160608301526080830151608083015260a083015160a083015260c0830151613e2460c0840182613b4c565b5060e0830151610180613e3981850183613b4c565b6101008501519150613e4f610240850183613b4c565b610120850151610300850152610140850151610320850152610160850151610340850152840151610360840152506101a09092015163ffffffff166103809091015290565b60008219821115613ea757613ea76140b6565b500190565b600063ffffffff808316818516808303821115613ecb57613ecb6140b6565b01949350505050565b600082613ee357613ee36140cc565b500490565b600181815b80851115613f25578163ffffffff04821115613f0b57613f0b6140b6565b80851615613f1857918102915b93841c9390800290613eed565b509250929050565b600063ffffffff613f42818516828516613f4a565b949350505050565b600082613f5957506001610a9e565b81613f6657506000610a9e565b8160018114613f7c5760028114613f8657613fb7565b6001915050610a9e565b60ff841115613f9757613f976140b6565b6001841b915063ffffffff821115613fb157613fb16140b6565b50610a9e565b5060208310610133831016604e8410600b8410161715613fee575081810a63ffffffff811115613fe957613fe96140b6565b610a9e565b613ff88383613ee8565b8063ffffffff0482111561400e5761400e6140b6565b029392505050565b6000816000190483118215151615614030576140306140b6565b500290565b600082821015614047576140476140b6565b500390565b60005b8381101561406757818101518382015260200161404f565b838111156130a75750506000910152565b600060001982141561408c5761408c6140b6565b5060010190565b600063ffffffff808416806140aa576140aa6140cc565b92169190910692915050565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b80151581146140f057600080fd5b50565b63ffffffff811681146140f057600080fdfea2646970667358221220c61dd9e8778a3ab1c32216a919e2f7398729bf6b7a4873071c6643cbda8628d164736f6c63430008040033000000000000000000000000965f527d9159dce6288a2219db51fc6eef120dd100000000000000000000000055d398326f99059ff775485246999027b3197955000000000000000000000000c2f107f58e342e31a9959e77b8b3528ce696c6240000000000000000000000002f48cde4cfd0fb4f5c873291d5cf2dc9e61f2db0

Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)

000000000000000000000000965f527d9159dce6288a2219db51fc6eef120dd100000000000000000000000055d398326f99059ff775485246999027b3197955000000000000000000000000c2f107f58e342e31a9959e77b8b3528ce696c6240000000000000000000000002f48cde4cfd0fb4f5c873291d5cf2dc9e61f2db0

-----Decoded View---------------
Arg [0] : _bswTokenAddress (address): 0x965f527d9159dce6288a2219db51fc6eef120dd1
Arg [1] : _usdtTokenAddress (address): 0x55d398326f99059ff775485246999027b3197955
Arg [2] : _randomGeneratorAddress (address): 0xc2f107f58e342e31a9959e77b8b3528ce696c624
Arg [3] : _priceOracleAddress (address): 0x2f48cde4cfd0fb4f5c873291d5cf2dc9e61f2db0

-----Encoded View---------------
4 Constructor Arguments found :
Arg [0] : 000000000000000000000000965f527d9159dce6288a2219db51fc6eef120dd1
Arg [1] : 00000000000000000000000055d398326f99059ff775485246999027b3197955
Arg [2] : 000000000000000000000000c2f107f58e342e31a9959e77b8b3528ce696c624
Arg [3] : 0000000000000000000000002f48cde4cfd0fb4f5c873291d5cf2dc9e61f2db0


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.