Address Details
contract

0xe0657Afca5888aDdD3c0DB4527B27da5114dd2bc

Contract Name
Bonus
Creator
0x7d6740–c9cfce at 0x361660–7398c6
Balance
0 CELO ( )
Locked CELO Balance
0.00 CELO
Voting CELO Balance
0.00 CELO
Pending Unlocked Gold
0.00 CELO
Tokens
Fetching tokens...
Transactions
0 Transactions
Transfers
0 Transfers
Gas Used
Fetching gas used...
Last Balance Update
8684778
This contract has been verified via Sourcify. View contract in Sourcify repository
Contract name:
Bonus




Optimization enabled
true
Compiler version
v0.8.10+commit.fc410830




Optimization runs
200
EVM Version
london




Verified at
2023-02-01T16:35:23.660310Z

contracts/Bonus.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/math/SafeMathUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol";

interface INFTLogic {
    function starMeta(uint256 _tokenId) view external returns (uint8, uint256, uint256, uint256);
    function totalPrice() view external returns (uint256);
}

contract Bonus is ContextUpgradeable, OwnableUpgradeable {

    using SafeMathUpgradeable for uint256;
    IERC20Upgradeable public starToken;
    IERC721Upgradeable public starNFT;
    INFTLogic public NFTLogic;

    address public lockAddr;
    uint256 public lockRatio;
    uint256 public bonusWithdrawn;
    uint256 public lockWithdrawn;

    mapping(uint256 => uint256) public tokenWithdraw;

    event Test(address indexed user, uint256 amount);

    function initialize(address _starToken, address _lock, uint256 _lockRatio) public initializer {
        __bonus_init(_starToken, _lock, _lockRatio);
    }

    function __bonus_init(address _starToken, address _lock, uint256 _lockRatio) internal initializer {
        __Context_init_unchained();
        __Ownable_init_unchained();
        __bonus_init_unchained(_starToken, _lock, _lockRatio);
    }

    function __bonus_init_unchained(address _starToken, address _lock, uint256 _lockRatio) internal initializer {
        require(_lockRatio < 10000, 'ratio error');
        starToken = IERC20Upgradeable(_starToken);
        lockAddr = _lock;
        lockRatio = _lockRatio;
    }

    function setLockRatio(uint256 _newRatio) onlyOwner public {
        require(_newRatio < 10000, 'ratio error');
        lockRatio = _newRatio;
    }

    function lockWithdraw(uint256 _amount) onlyLockUser public {
        require(_amount > 0, "amount error");
        uint256 _balance = starToken.balanceOf(address(this));
        uint256 _availLock = _balance.add(lockWithdrawn).add(bonusWithdrawn).mul(lockRatio).div(10000).sub(lockWithdrawn);
        require(_amount <= _availLock, 'amount error');
        lockWithdrawn = lockWithdrawn.add(_amount);
        starToken.transfer(_msgSender(), _amount);
    }

    function bonusWithdraw(uint256 _tokenId) public{
        // require(_msgSender() == starNFT.ownerOf(_tokenId), "not your token");
        uint256 _amount =  _getBonus(_tokenId);
        require(_amount > 0, "no bonus");
        bonusWithdrawn = bonusWithdrawn.add(_amount);
        tokenWithdraw[_tokenId] = tokenWithdraw[_tokenId].add(_amount);
        starToken.transfer(_msgSender(), _amount);
    }

    function setTokenWithdraw(uint256 _tokenId,uint256 _amount) external{
        tokenWithdraw[_tokenId] = tokenWithdraw[_tokenId].add(_amount);
    }

    function setBonusWithdrawn(uint256 _amount) external{
        bonusWithdrawn = bonusWithdrawn.add(_amount);
    }

    function getBonus(uint256 _tokenId) view external returns (uint256) {
        return _getBonus(_tokenId);
    }

    function _getBonus(uint256 _tokenId) view internal returns (uint256) {
        uint256 _totalPrice = NFTLogic.totalPrice();
        (, , uint256 _price, uint256 _multi) = NFTLogic.starMeta(_tokenId);
        uint256 _ratio = _price.mul(_multi).div(100).mul(1e12).div(_totalPrice);
        uint256 _balance = starToken.balanceOf(address(this));
        
        uint256 _availBonus = _balance.add(lockWithdrawn).add(bonusWithdrawn).mul(10000 - lockRatio).div(10000).mul(_ratio).div(1e12);
        return _availBonus > tokenWithdraw[_tokenId] ? _availBonus - tokenWithdraw[_tokenId] : 0;
    }

    function setLock(address _addr) onlyOwner public {
        require(address(0) != _addr, 'lock address error');
        lockAddr = _addr;
    }

    function setNFT(address _addr) onlyOwner public {
        require(address(0) != _addr, 'NFT address error');
        starNFT = IERC721Upgradeable(_addr);
    }

    function setNFTLogic(address _addr) onlyOwner public {
        require(address(0) != _addr, 'NFT address error');
        NFTLogic = INFTLogic(_addr);
    }

    modifier onlyLockUser() {
        require(_msgSender() == lockAddr, 'no permission');
        _;
    }
}
        

/_openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.0 (access/Ownable.sol)

pragma solidity ^0.8.0;

import "../utils/ContextUpgradeable.sol";
import "../proxy/utils/Initializable.sol";

/**
 * @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 OwnableUpgradeable is Initializable, ContextUpgradeable {
    address private _owner;

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

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    function __Ownable_init() internal initializer {
        __Context_init_unchained();
        __Ownable_init_unchained();
    }

    function __Ownable_init_unchained() internal initializer {
        _transferOwnership(_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 {
        _transferOwnership(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");
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
    uint256[49] private __gap;
}
          

/_openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.0 (proxy/utils/Initializable.sol)

pragma solidity ^0.8.0;

/**
 * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
 * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an
 * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
 * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
 *
 * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
 * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
 *
 * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
 * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
 *
 * [CAUTION]
 * ====
 * Avoid leaving a contract uninitialized.
 *
 * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
 * contract, which may impact the proxy. To initialize the implementation contract, you can either invoke the
 * initializer manually, or you can include a constructor to automatically mark it as initialized when it is deployed:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * /// @custom:oz-upgrades-unsafe-allow constructor
 * constructor() initializer {}
 * ```
 * ====
 */
abstract contract Initializable {
    /**
     * @dev Indicates that the contract has been initialized.
     */
    bool private _initialized;

    /**
     * @dev Indicates that the contract is in the process of being initialized.
     */
    bool private _initializing;

    /**
     * @dev Modifier to protect an initializer function from being invoked twice.
     */
    modifier initializer() {
        require(_initializing || !_initialized, "Initializable: contract is already initialized");

        bool isTopLevelCall = !_initializing;
        if (isTopLevelCall) {
            _initializing = true;
            _initialized = true;
        }

        _;

        if (isTopLevelCall) {
            _initializing = false;
        }
    }
}
          

/_openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol

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

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20Upgradeable {
    /**
     * @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);
}
          

/_openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol

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

pragma solidity ^0.8.0;

import "../../utils/introspection/IERC165Upgradeable.sol";

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

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

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

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

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

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

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

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

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

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

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

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

/_openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol

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

pragma solidity ^0.8.0;
import "../proxy/utils/Initializable.sol";

/**
 * @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 ContextUpgradeable is Initializable {
    function __Context_init() internal initializer {
        __Context_init_unchained();
    }

    function __Context_init_unchained() internal initializer {
    }
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
    uint256[50] private __gap;
}
          

/_openzeppelin/contracts-upgradeable/utils/introspection/IERC165Upgradeable.sol

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

pragma solidity ^0.8.0;

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

/_openzeppelin/contracts-upgradeable/utils/math/SafeMathUpgradeable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.0 (utils/math/SafeMath.sol)

pragma solidity ^0.8.0;

// CAUTION
// This version of SafeMath should only be used with Solidity 0.8 or later,
// because it relies on the compiler's built in overflow checks.

/**
 * @dev Wrappers over Solidity's arithmetic operations.
 *
 * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler
 * now has built in overflow checking.
 */
library SafeMathUpgradeable {
    /**
     * @dev Returns the addition of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            uint256 c = a + b;
            if (c < a) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the substraction of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b > a) return (false, 0);
            return (true, a - b);
        }
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
            // benefit is lost if 'b' is also tested.
            // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
            if (a == 0) return (true, 0);
            uint256 c = a * b;
            if (c / a != b) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the division of two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a / b);
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a % b);
        }
    }

    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        return a + b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return a - b;
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        return a * b;
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator.
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return a / b;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return a % b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {trySub}.
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        unchecked {
            require(b <= a, errorMessage);
            return a - b;
        }
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        unchecked {
            require(b > 0, errorMessage);
            return a / b;
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting with custom message when dividing by zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryMod}.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        unchecked {
            require(b > 0, errorMessage);
            return a % b;
        }
    }
}
          

Contract ABI

[{"type":"event","name":"OwnershipTransferred","inputs":[{"type":"address","name":"previousOwner","internalType":"address","indexed":true},{"type":"address","name":"newOwner","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"Test","inputs":[{"type":"address","name":"user","internalType":"address","indexed":true},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract INFTLogic"}],"name":"NFTLogic","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"bonusWithdraw","inputs":[{"type":"uint256","name":"_tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"bonusWithdrawn","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getBonus","inputs":[{"type":"uint256","name":"_tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"initialize","inputs":[{"type":"address","name":"_starToken","internalType":"address"},{"type":"address","name":"_lock","internalType":"address"},{"type":"uint256","name":"_lockRatio","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"lockAddr","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"lockRatio","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"lockWithdraw","inputs":[{"type":"uint256","name":"_amount","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"lockWithdrawn","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"owner","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceOwnership","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setBonusWithdrawn","inputs":[{"type":"uint256","name":"_amount","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setLock","inputs":[{"type":"address","name":"_addr","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setLockRatio","inputs":[{"type":"uint256","name":"_newRatio","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setNFT","inputs":[{"type":"address","name":"_addr","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setNFTLogic","inputs":[{"type":"address","name":"_addr","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setTokenWithdraw","inputs":[{"type":"uint256","name":"_tokenId","internalType":"uint256"},{"type":"uint256","name":"_amount","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract IERC721Upgradeable"}],"name":"starNFT","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract IERC20Upgradeable"}],"name":"starToken","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"tokenWithdraw","inputs":[{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferOwnership","inputs":[{"type":"address","name":"newOwner","internalType":"address"}]}]
              

Contract Creation Code

0x608060405234801561001057600080fd5b50611101806100206000396000f3fe608060405234801561001057600080fd5b50600436106101375760003560e01c806395a0af47116100b8578063c9fd98231161007c578063c9fd982314610265578063d7e751ff14610278578063d9fc0e7f14610298578063e7bd7191146102a1578063f2fde38b146102b4578063f56e9c66146102c757600080fd5b806395a0af47146102105780639c3709ea14610223578063a32088d41461022c578063b7ca51e81461023f578063bcb470051461025257600080fd5b806357fe507a116100ff57806357fe507a146101a657806370dca974146101b9578063715018a6146101e45780637fdab94e146101ec5780638da5cb5b146101ff57600080fd5b8063085a4f151461013c5780630f8a8a54146101515780631794bb3c1461016d57806337ef75c8146101805780634aa66b2814610193575b600080fd5b61014f61014a366004610e94565b6102da565b005b61015a606b5481565b6040519081526020015b60405180910390f35b61014f61017b366004610ec9565b610501565b61014f61018e366004610f05565b61057a565b61015a6101a1366004610e94565b610610565b61014f6101b4366004610f20565b610621565b6066546101cc906001600160a01b031681565b6040516001600160a01b039091168152602001610164565b61014f610650565b6068546101cc906001600160a01b031681565b6033546001600160a01b03166101cc565b61014f61021e366004610e94565b610686565b61015a60695481565b61014f61023a366004610f05565b610699565b6065546101cc906001600160a01b031681565b6067546101cc906001600160a01b031681565b61014f610273366004610e94565b610730565b61015a610286366004610e94565b606c6020526000908152604090205481565b61015a606a5481565b61014f6102af366004610e94565b610838565b61014f6102c2366004610f05565b6108a6565b61014f6102d5366004610f05565b610941565b6068546001600160a01b0316336001600160a01b0316146103325760405162461bcd60e51b815260206004820152600d60248201526c3737903832b936b4b9b9b4b7b760991b60448201526064015b60405180910390fd5b600081116103715760405162461bcd60e51b815260206004820152600c60248201526b30b6b7bab73a1032b93937b960a11b6044820152606401610329565b6065546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa1580156103ba573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103de9190610f42565b90506000610427606b5461042161271061041b606954610415606a5461040f606b548b6109d790919063ffffffff16565b906109d7565b906109ea565b906109f6565b90610a02565b9050808311156104685760405162461bcd60e51b815260206004820152600c60248201526b30b6b7bab73a1032b93937b960a11b6044820152606401610329565b606b5461047590846109d7565b606b556065546001600160a01b031663a9059cbb336040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602481018690526044016020604051808303816000875af11580156104d7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104fb9190610f5b565b50505050565b600054610100900460ff168061051a575060005460ff16155b6105365760405162461bcd60e51b815260040161032990610f7d565b600054610100900460ff16158015610558576000805461ffff19166101011790555b610563848484610a0e565b80156104fb576000805461ff001916905550505050565b6033546001600160a01b031633146105a45760405162461bcd60e51b815260040161032990610fcb565b6001600160a01b0381166105ee5760405162461bcd60e51b815260206004820152601160248201527027232a1030b2323932b9b99032b93937b960791b6044820152606401610329565b606780546001600160a01b0319166001600160a01b0392909216919091179055565b600061061b82610a80565b92915050565b6000828152606c602052604090205461063a90826109d7565b6000928352606c60205260409092209190915550565b6033546001600160a01b0316331461067a5760405162461bcd60e51b815260040161032990610fcb565b6106846000610c95565b565b606a5461069390826109d7565b606a5550565b6033546001600160a01b031633146106c35760405162461bcd60e51b815260040161032990610fcb565b6001600160a01b03811661070e5760405162461bcd60e51b81526020600482015260126024820152713637b1b59030b2323932b9b99032b93937b960711b6044820152606401610329565b606880546001600160a01b0319166001600160a01b0392909216919091179055565b600061073b82610a80565b9050600081116107785760405162461bcd60e51b81526020600482015260086024820152676e6f20626f6e757360c01b6044820152606401610329565b606a5461078590826109d7565b606a556000828152606c60205260409020546107a190826109d7565b6000838152606c60205260409020556065546001600160a01b031663a9059cbb336040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602481018490526044016020604051808303816000875af115801561080f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108339190610f5b565b505050565b6033546001600160a01b031633146108625760405162461bcd60e51b815260040161032990610fcb565b61271081106108a15760405162461bcd60e51b815260206004820152600b60248201526a3930ba34b79032b93937b960a91b6044820152606401610329565b606955565b6033546001600160a01b031633146108d05760405162461bcd60e51b815260040161032990610fcb565b6001600160a01b0381166109355760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610329565b61093e81610c95565b50565b6033546001600160a01b0316331461096b5760405162461bcd60e51b815260040161032990610fcb565b6001600160a01b0381166109b55760405162461bcd60e51b815260206004820152601160248201527027232a1030b2323932b9b99032b93937b960791b6044820152606401610329565b606680546001600160a01b0319166001600160a01b0392909216919091179055565b60006109e38284611016565b9392505050565b60006109e3828461102e565b60006109e3828461104d565b60006109e3828461106f565b600054610100900460ff1680610a27575060005460ff16155b610a435760405162461bcd60e51b815260040161032990610f7d565b600054610100900460ff16158015610a65576000805461ffff19166101011790555b610a6d610ce7565b610a75610d52565b610563848484610db2565b600080606760009054906101000a90046001600160a01b03166001600160a01b031663ab0d92dd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610ad6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610afa9190610f42565b606754604051634b893b5760e11b81526004810186905291925060009182916001600160a01b03169063971276ae90602401608060405180830381865afa158015610b49573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b6d9190611086565b9350935050506000610b9a8461041b64e8d4a51000610415606461041b888a6109ea90919063ffffffff16565b6065546040516370a0823160e01b81523060048201529192506000916001600160a01b03909116906370a0823190602401602060405180830381865afa158015610be8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c0c9190610f42565b90506000610c5164e8d4a5100061041b8561041561271061041b606954612710610c36919061106f565b610415606a5461040f606b548d6109d790919063ffffffff16565b6000898152606c60205260409020549091508111610c70576000610c89565b6000888152606c6020526040902054610c89908261106f565b98975050505050505050565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600054610100900460ff1680610d00575060005460ff16155b610d1c5760405162461bcd60e51b815260040161032990610f7d565b600054610100900460ff16158015610d3e576000805461ffff19166101011790555b801561093e576000805461ff001916905550565b600054610100900460ff1680610d6b575060005460ff16155b610d875760405162461bcd60e51b815260040161032990610f7d565b600054610100900460ff16158015610da9576000805461ffff19166101011790555b610d3e33610c95565b600054610100900460ff1680610dcb575060005460ff16155b610de75760405162461bcd60e51b815260040161032990610f7d565b600054610100900460ff16158015610e09576000805461ffff19166101011790555b6127108210610e485760405162461bcd60e51b815260206004820152600b60248201526a3930ba34b79032b93937b960a91b6044820152606401610329565b606580546001600160a01b038087166001600160a01b0319928316179092556068805492861692909116919091179055606982905580156104fb576000805461ff001916905550505050565b600060208284031215610ea657600080fd5b5035919050565b80356001600160a01b0381168114610ec457600080fd5b919050565b600080600060608486031215610ede57600080fd5b610ee784610ead565b9250610ef560208501610ead565b9150604084013590509250925092565b600060208284031215610f1757600080fd5b6109e382610ead565b60008060408385031215610f3357600080fd5b50508035926020909101359150565b600060208284031215610f5457600080fd5b5051919050565b600060208284031215610f6d57600080fd5b815180151581146109e357600080fd5b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b634e487b7160e01b600052601160045260246000fd5b6000821982111561102957611029611000565b500190565b600081600019048311821515161561104857611048611000565b500290565b60008261106a57634e487b7160e01b600052601260045260246000fd5b500490565b60008282101561108157611081611000565b500390565b6000806000806080858703121561109c57600080fd5b845160ff811681146110ad57600080fd5b6020860151604087015160609097015191989097509094509250505056fea2646970667358221220bd661d0a0b2d3ac5de2b142a4c2e76bb67cc237f26d805e7d1a149127e8de50964736f6c634300080a0033

Deployed ByteCode

0x608060405234801561001057600080fd5b50600436106101375760003560e01c806395a0af47116100b8578063c9fd98231161007c578063c9fd982314610265578063d7e751ff14610278578063d9fc0e7f14610298578063e7bd7191146102a1578063f2fde38b146102b4578063f56e9c66146102c757600080fd5b806395a0af47146102105780639c3709ea14610223578063a32088d41461022c578063b7ca51e81461023f578063bcb470051461025257600080fd5b806357fe507a116100ff57806357fe507a146101a657806370dca974146101b9578063715018a6146101e45780637fdab94e146101ec5780638da5cb5b146101ff57600080fd5b8063085a4f151461013c5780630f8a8a54146101515780631794bb3c1461016d57806337ef75c8146101805780634aa66b2814610193575b600080fd5b61014f61014a366004610e94565b6102da565b005b61015a606b5481565b6040519081526020015b60405180910390f35b61014f61017b366004610ec9565b610501565b61014f61018e366004610f05565b61057a565b61015a6101a1366004610e94565b610610565b61014f6101b4366004610f20565b610621565b6066546101cc906001600160a01b031681565b6040516001600160a01b039091168152602001610164565b61014f610650565b6068546101cc906001600160a01b031681565b6033546001600160a01b03166101cc565b61014f61021e366004610e94565b610686565b61015a60695481565b61014f61023a366004610f05565b610699565b6065546101cc906001600160a01b031681565b6067546101cc906001600160a01b031681565b61014f610273366004610e94565b610730565b61015a610286366004610e94565b606c6020526000908152604090205481565b61015a606a5481565b61014f6102af366004610e94565b610838565b61014f6102c2366004610f05565b6108a6565b61014f6102d5366004610f05565b610941565b6068546001600160a01b0316336001600160a01b0316146103325760405162461bcd60e51b815260206004820152600d60248201526c3737903832b936b4b9b9b4b7b760991b60448201526064015b60405180910390fd5b600081116103715760405162461bcd60e51b815260206004820152600c60248201526b30b6b7bab73a1032b93937b960a11b6044820152606401610329565b6065546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa1580156103ba573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103de9190610f42565b90506000610427606b5461042161271061041b606954610415606a5461040f606b548b6109d790919063ffffffff16565b906109d7565b906109ea565b906109f6565b90610a02565b9050808311156104685760405162461bcd60e51b815260206004820152600c60248201526b30b6b7bab73a1032b93937b960a11b6044820152606401610329565b606b5461047590846109d7565b606b556065546001600160a01b031663a9059cbb336040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602481018690526044016020604051808303816000875af11580156104d7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104fb9190610f5b565b50505050565b600054610100900460ff168061051a575060005460ff16155b6105365760405162461bcd60e51b815260040161032990610f7d565b600054610100900460ff16158015610558576000805461ffff19166101011790555b610563848484610a0e565b80156104fb576000805461ff001916905550505050565b6033546001600160a01b031633146105a45760405162461bcd60e51b815260040161032990610fcb565b6001600160a01b0381166105ee5760405162461bcd60e51b815260206004820152601160248201527027232a1030b2323932b9b99032b93937b960791b6044820152606401610329565b606780546001600160a01b0319166001600160a01b0392909216919091179055565b600061061b82610a80565b92915050565b6000828152606c602052604090205461063a90826109d7565b6000928352606c60205260409092209190915550565b6033546001600160a01b0316331461067a5760405162461bcd60e51b815260040161032990610fcb565b6106846000610c95565b565b606a5461069390826109d7565b606a5550565b6033546001600160a01b031633146106c35760405162461bcd60e51b815260040161032990610fcb565b6001600160a01b03811661070e5760405162461bcd60e51b81526020600482015260126024820152713637b1b59030b2323932b9b99032b93937b960711b6044820152606401610329565b606880546001600160a01b0319166001600160a01b0392909216919091179055565b600061073b82610a80565b9050600081116107785760405162461bcd60e51b81526020600482015260086024820152676e6f20626f6e757360c01b6044820152606401610329565b606a5461078590826109d7565b606a556000828152606c60205260409020546107a190826109d7565b6000838152606c60205260409020556065546001600160a01b031663a9059cbb336040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602481018490526044016020604051808303816000875af115801561080f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108339190610f5b565b505050565b6033546001600160a01b031633146108625760405162461bcd60e51b815260040161032990610fcb565b61271081106108a15760405162461bcd60e51b815260206004820152600b60248201526a3930ba34b79032b93937b960a91b6044820152606401610329565b606955565b6033546001600160a01b031633146108d05760405162461bcd60e51b815260040161032990610fcb565b6001600160a01b0381166109355760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610329565b61093e81610c95565b50565b6033546001600160a01b0316331461096b5760405162461bcd60e51b815260040161032990610fcb565b6001600160a01b0381166109b55760405162461bcd60e51b815260206004820152601160248201527027232a1030b2323932b9b99032b93937b960791b6044820152606401610329565b606680546001600160a01b0319166001600160a01b0392909216919091179055565b60006109e38284611016565b9392505050565b60006109e3828461102e565b60006109e3828461104d565b60006109e3828461106f565b600054610100900460ff1680610a27575060005460ff16155b610a435760405162461bcd60e51b815260040161032990610f7d565b600054610100900460ff16158015610a65576000805461ffff19166101011790555b610a6d610ce7565b610a75610d52565b610563848484610db2565b600080606760009054906101000a90046001600160a01b03166001600160a01b031663ab0d92dd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610ad6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610afa9190610f42565b606754604051634b893b5760e11b81526004810186905291925060009182916001600160a01b03169063971276ae90602401608060405180830381865afa158015610b49573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b6d9190611086565b9350935050506000610b9a8461041b64e8d4a51000610415606461041b888a6109ea90919063ffffffff16565b6065546040516370a0823160e01b81523060048201529192506000916001600160a01b03909116906370a0823190602401602060405180830381865afa158015610be8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c0c9190610f42565b90506000610c5164e8d4a5100061041b8561041561271061041b606954612710610c36919061106f565b610415606a5461040f606b548d6109d790919063ffffffff16565b6000898152606c60205260409020549091508111610c70576000610c89565b6000888152606c6020526040902054610c89908261106f565b98975050505050505050565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600054610100900460ff1680610d00575060005460ff16155b610d1c5760405162461bcd60e51b815260040161032990610f7d565b600054610100900460ff16158015610d3e576000805461ffff19166101011790555b801561093e576000805461ff001916905550565b600054610100900460ff1680610d6b575060005460ff16155b610d875760405162461bcd60e51b815260040161032990610f7d565b600054610100900460ff16158015610da9576000805461ffff19166101011790555b610d3e33610c95565b600054610100900460ff1680610dcb575060005460ff16155b610de75760405162461bcd60e51b815260040161032990610f7d565b600054610100900460ff16158015610e09576000805461ffff19166101011790555b6127108210610e485760405162461bcd60e51b815260206004820152600b60248201526a3930ba34b79032b93937b960a91b6044820152606401610329565b606580546001600160a01b038087166001600160a01b0319928316179092556068805492861692909116919091179055606982905580156104fb576000805461ff001916905550505050565b600060208284031215610ea657600080fd5b5035919050565b80356001600160a01b0381168114610ec457600080fd5b919050565b600080600060608486031215610ede57600080fd5b610ee784610ead565b9250610ef560208501610ead565b9150604084013590509250925092565b600060208284031215610f1757600080fd5b6109e382610ead565b60008060408385031215610f3357600080fd5b50508035926020909101359150565b600060208284031215610f5457600080fd5b5051919050565b600060208284031215610f6d57600080fd5b815180151581146109e357600080fd5b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b634e487b7160e01b600052601160045260246000fd5b6000821982111561102957611029611000565b500190565b600081600019048311821515161561104857611048611000565b500290565b60008261106a57634e487b7160e01b600052601260045260246000fd5b500490565b60008282101561108157611081611000565b500390565b6000806000806080858703121561109c57600080fd5b845160ff811681146110ad57600080fd5b6020860151604087015160609097015191989097509094509250505056fea2646970667358221220bd661d0a0b2d3ac5de2b142a4c2e76bb67cc237f26d805e7d1a149127e8de50964736f6c634300080a0033