Address Details
contract

0xf90c4F4028bE7E4d305BA1ad2011369eF3Fc54f0

Contract Name
Bonus
Creator
0x7d6740–c9cfce at 0x27c654–1a4659
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
8646353
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
2022-08-19T06:26:09.580083Z

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;

    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) view public returns(uint256){
        require(_msgSender() == starNFT.ownerOf(_tokenId), "not your token");
        return _getBonus(_tokenId);
        // require(_amount > 0, "no bonus");
        // bonusWithdrawn = bonusWithdrawn.add(_amount);
        // tokenWithdraw[_tokenId] = tokenWithdraw[_tokenId].add(_amount);
        // starToken.transfer(_msgSender(), _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":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract INFTLogic"}],"name":"NFTLogic","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"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":"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":"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

0x608060405234801561001057600080fd5b5061103e806100206000396000f3fe608060405234801561001057600080fd5b50600436106101215760003560e01c80639c3709ea116100ad578063d7e751ff11610071578063d7e751ff1461023c578063d9fc0e7f1461025c578063e7bd719114610265578063f2fde38b14610278578063f56e9c661461028b57600080fd5b80639c3709ea146101e7578063a32088d4146101f0578063b7ca51e814610203578063bcb4700514610216578063c9fd98231461022957600080fd5b80634aa66b28116100f45780634aa66b281461017d57806370dca97414610190578063715018a6146101bb5780637fdab94e146101c35780638da5cb5b146101d657600080fd5b8063085a4f15146101265780630f8a8a541461013b5780631794bb3c1461015757806337ef75c81461016a575b600080fd5b610139610134366004610dd6565b61029e565b005b610144606b5481565b6040519081526020015b60405180910390f35b610139610165366004610e04565b6104c5565b610139610178366004610e45565b61053e565b61014461018b366004610dd6565b6105d4565b6066546101a3906001600160a01b031681565b6040516001600160a01b03909116815260200161014e565b6101396105e5565b6068546101a3906001600160a01b031681565b6033546001600160a01b03166101a3565b61014460695481565b6101396101fe366004610e45565b61061b565b6065546101a3906001600160a01b031681565b6067546101a3906001600160a01b031681565b610144610237366004610dd6565b6106b2565b61014461024a366004610dd6565b606c6020526000908152604090205481565b610144606a5481565b610139610273366004610dd6565b61077a565b610139610286366004610e45565b6107e8565b610139610299366004610e45565b610883565b6068546001600160a01b0316336001600160a01b0316146102f65760405162461bcd60e51b815260206004820152600d60248201526c3737903832b936b4b9b9b4b7b760991b60448201526064015b60405180910390fd5b600081116103355760405162461bcd60e51b815260206004820152600c60248201526b30b6b7bab73a1032b93937b960a11b60448201526064016102ed565b6065546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa15801561037e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103a29190610e62565b905060006103eb606b546103e56127106103df6069546103d9606a546103d3606b548b61091990919063ffffffff16565b90610919565b9061092c565b90610938565b90610944565b90508083111561042c5760405162461bcd60e51b815260206004820152600c60248201526b30b6b7bab73a1032b93937b960a11b60448201526064016102ed565b606b546104399084610919565b606b556065546001600160a01b031663a9059cbb336040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602481018690526044016020604051808303816000875af115801561049b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104bf9190610e7b565b50505050565b600054610100900460ff16806104de575060005460ff16155b6104fa5760405162461bcd60e51b81526004016102ed90610e9d565b600054610100900460ff1615801561051c576000805461ffff19166101011790555b610527848484610950565b80156104bf576000805461ff001916905550505050565b6033546001600160a01b031633146105685760405162461bcd60e51b81526004016102ed90610eeb565b6001600160a01b0381166105b25760405162461bcd60e51b815260206004820152601160248201527027232a1030b2323932b9b99032b93937b960791b60448201526064016102ed565b606780546001600160a01b0319166001600160a01b0392909216919091179055565b60006105df826109c2565b92915050565b6033546001600160a01b0316331461060f5760405162461bcd60e51b81526004016102ed90610eeb565b6106196000610bd7565b565b6033546001600160a01b031633146106455760405162461bcd60e51b81526004016102ed90610eeb565b6001600160a01b0381166106905760405162461bcd60e51b81526020600482015260126024820152713637b1b59030b2323932b9b99032b93937b960711b60448201526064016102ed565b606880546001600160a01b0319166001600160a01b0392909216919091179055565b6066546040516331a9108f60e11b8152600481018390526000916001600160a01b031690636352211e90602401602060405180830381865afa1580156106fc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107209190610f20565b6001600160a01b0316336001600160a01b0316146107715760405162461bcd60e51b815260206004820152600e60248201526d3737ba103cb7bab9103a37b5b2b760911b60448201526064016102ed565b6105df826109c2565b6033546001600160a01b031633146107a45760405162461bcd60e51b81526004016102ed90610eeb565b61271081106107e35760405162461bcd60e51b815260206004820152600b60248201526a3930ba34b79032b93937b960a91b60448201526064016102ed565b606955565b6033546001600160a01b031633146108125760405162461bcd60e51b81526004016102ed90610eeb565b6001600160a01b0381166108775760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016102ed565b61088081610bd7565b50565b6033546001600160a01b031633146108ad5760405162461bcd60e51b81526004016102ed90610eeb565b6001600160a01b0381166108f75760405162461bcd60e51b815260206004820152601160248201527027232a1030b2323932b9b99032b93937b960791b60448201526064016102ed565b606680546001600160a01b0319166001600160a01b0392909216919091179055565b60006109258284610f53565b9392505050565b60006109258284610f6b565b60006109258284610f8a565b60006109258284610fac565b600054610100900460ff1680610969575060005460ff16155b6109855760405162461bcd60e51b81526004016102ed90610e9d565b600054610100900460ff161580156109a7576000805461ffff19166101011790555b6109af610c29565b6109b7610c94565b610527848484610cf4565b600080606760009054906101000a90046001600160a01b03166001600160a01b031663ab0d92dd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610a18573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a3c9190610e62565b606754604051634b893b5760e11b81526004810186905291925060009182916001600160a01b03169063971276ae90602401608060405180830381865afa158015610a8b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610aaf9190610fc3565b9350935050506000610adc846103df64e8d4a510006103d960646103df888a61092c90919063ffffffff16565b6065546040516370a0823160e01b81523060048201529192506000916001600160a01b03909116906370a0823190602401602060405180830381865afa158015610b2a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b4e9190610e62565b90506000610b9364e8d4a510006103df856103d96127106103df606954612710610b789190610fac565b6103d9606a546103d3606b548d61091990919063ffffffff16565b6000898152606c60205260409020549091508111610bb2576000610bcb565b6000888152606c6020526040902054610bcb9082610fac565b98975050505050505050565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600054610100900460ff1680610c42575060005460ff16155b610c5e5760405162461bcd60e51b81526004016102ed90610e9d565b600054610100900460ff16158015610c80576000805461ffff19166101011790555b8015610880576000805461ff001916905550565b600054610100900460ff1680610cad575060005460ff16155b610cc95760405162461bcd60e51b81526004016102ed90610e9d565b600054610100900460ff16158015610ceb576000805461ffff19166101011790555b610c8033610bd7565b600054610100900460ff1680610d0d575060005460ff16155b610d295760405162461bcd60e51b81526004016102ed90610e9d565b600054610100900460ff16158015610d4b576000805461ffff19166101011790555b6127108210610d8a5760405162461bcd60e51b815260206004820152600b60248201526a3930ba34b79032b93937b960a91b60448201526064016102ed565b606580546001600160a01b038087166001600160a01b0319928316179092556068805492861692909116919091179055606982905580156104bf576000805461ff001916905550505050565b600060208284031215610de857600080fd5b5035919050565b6001600160a01b038116811461088057600080fd5b600080600060608486031215610e1957600080fd5b8335610e2481610def565b92506020840135610e3481610def565b929592945050506040919091013590565b600060208284031215610e5757600080fd5b813561092581610def565b600060208284031215610e7457600080fd5b5051919050565b600060208284031215610e8d57600080fd5b8151801515811461092557600080fd5b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b600060208284031215610f3257600080fd5b815161092581610def565b634e487b7160e01b600052601160045260246000fd5b60008219821115610f6657610f66610f3d565b500190565b6000816000190483118215151615610f8557610f85610f3d565b500290565b600082610fa757634e487b7160e01b600052601260045260246000fd5b500490565b600082821015610fbe57610fbe610f3d565b500390565b60008060008060808587031215610fd957600080fd5b845160ff81168114610fea57600080fd5b6020860151604087015160609097015191989097509094509250505056fea2646970667358221220140063633582eca3d6af1e5bd33d40204eca2d92e957d171f04320457b28fcb564736f6c634300080a0033

Deployed ByteCode

0x608060405234801561001057600080fd5b50600436106101215760003560e01c80639c3709ea116100ad578063d7e751ff11610071578063d7e751ff1461023c578063d9fc0e7f1461025c578063e7bd719114610265578063f2fde38b14610278578063f56e9c661461028b57600080fd5b80639c3709ea146101e7578063a32088d4146101f0578063b7ca51e814610203578063bcb4700514610216578063c9fd98231461022957600080fd5b80634aa66b28116100f45780634aa66b281461017d57806370dca97414610190578063715018a6146101bb5780637fdab94e146101c35780638da5cb5b146101d657600080fd5b8063085a4f15146101265780630f8a8a541461013b5780631794bb3c1461015757806337ef75c81461016a575b600080fd5b610139610134366004610dd6565b61029e565b005b610144606b5481565b6040519081526020015b60405180910390f35b610139610165366004610e04565b6104c5565b610139610178366004610e45565b61053e565b61014461018b366004610dd6565b6105d4565b6066546101a3906001600160a01b031681565b6040516001600160a01b03909116815260200161014e565b6101396105e5565b6068546101a3906001600160a01b031681565b6033546001600160a01b03166101a3565b61014460695481565b6101396101fe366004610e45565b61061b565b6065546101a3906001600160a01b031681565b6067546101a3906001600160a01b031681565b610144610237366004610dd6565b6106b2565b61014461024a366004610dd6565b606c6020526000908152604090205481565b610144606a5481565b610139610273366004610dd6565b61077a565b610139610286366004610e45565b6107e8565b610139610299366004610e45565b610883565b6068546001600160a01b0316336001600160a01b0316146102f65760405162461bcd60e51b815260206004820152600d60248201526c3737903832b936b4b9b9b4b7b760991b60448201526064015b60405180910390fd5b600081116103355760405162461bcd60e51b815260206004820152600c60248201526b30b6b7bab73a1032b93937b960a11b60448201526064016102ed565b6065546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa15801561037e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103a29190610e62565b905060006103eb606b546103e56127106103df6069546103d9606a546103d3606b548b61091990919063ffffffff16565b90610919565b9061092c565b90610938565b90610944565b90508083111561042c5760405162461bcd60e51b815260206004820152600c60248201526b30b6b7bab73a1032b93937b960a11b60448201526064016102ed565b606b546104399084610919565b606b556065546001600160a01b031663a9059cbb336040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602481018690526044016020604051808303816000875af115801561049b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104bf9190610e7b565b50505050565b600054610100900460ff16806104de575060005460ff16155b6104fa5760405162461bcd60e51b81526004016102ed90610e9d565b600054610100900460ff1615801561051c576000805461ffff19166101011790555b610527848484610950565b80156104bf576000805461ff001916905550505050565b6033546001600160a01b031633146105685760405162461bcd60e51b81526004016102ed90610eeb565b6001600160a01b0381166105b25760405162461bcd60e51b815260206004820152601160248201527027232a1030b2323932b9b99032b93937b960791b60448201526064016102ed565b606780546001600160a01b0319166001600160a01b0392909216919091179055565b60006105df826109c2565b92915050565b6033546001600160a01b0316331461060f5760405162461bcd60e51b81526004016102ed90610eeb565b6106196000610bd7565b565b6033546001600160a01b031633146106455760405162461bcd60e51b81526004016102ed90610eeb565b6001600160a01b0381166106905760405162461bcd60e51b81526020600482015260126024820152713637b1b59030b2323932b9b99032b93937b960711b60448201526064016102ed565b606880546001600160a01b0319166001600160a01b0392909216919091179055565b6066546040516331a9108f60e11b8152600481018390526000916001600160a01b031690636352211e90602401602060405180830381865afa1580156106fc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107209190610f20565b6001600160a01b0316336001600160a01b0316146107715760405162461bcd60e51b815260206004820152600e60248201526d3737ba103cb7bab9103a37b5b2b760911b60448201526064016102ed565b6105df826109c2565b6033546001600160a01b031633146107a45760405162461bcd60e51b81526004016102ed90610eeb565b61271081106107e35760405162461bcd60e51b815260206004820152600b60248201526a3930ba34b79032b93937b960a91b60448201526064016102ed565b606955565b6033546001600160a01b031633146108125760405162461bcd60e51b81526004016102ed90610eeb565b6001600160a01b0381166108775760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016102ed565b61088081610bd7565b50565b6033546001600160a01b031633146108ad5760405162461bcd60e51b81526004016102ed90610eeb565b6001600160a01b0381166108f75760405162461bcd60e51b815260206004820152601160248201527027232a1030b2323932b9b99032b93937b960791b60448201526064016102ed565b606680546001600160a01b0319166001600160a01b0392909216919091179055565b60006109258284610f53565b9392505050565b60006109258284610f6b565b60006109258284610f8a565b60006109258284610fac565b600054610100900460ff1680610969575060005460ff16155b6109855760405162461bcd60e51b81526004016102ed90610e9d565b600054610100900460ff161580156109a7576000805461ffff19166101011790555b6109af610c29565b6109b7610c94565b610527848484610cf4565b600080606760009054906101000a90046001600160a01b03166001600160a01b031663ab0d92dd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610a18573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a3c9190610e62565b606754604051634b893b5760e11b81526004810186905291925060009182916001600160a01b03169063971276ae90602401608060405180830381865afa158015610a8b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610aaf9190610fc3565b9350935050506000610adc846103df64e8d4a510006103d960646103df888a61092c90919063ffffffff16565b6065546040516370a0823160e01b81523060048201529192506000916001600160a01b03909116906370a0823190602401602060405180830381865afa158015610b2a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b4e9190610e62565b90506000610b9364e8d4a510006103df856103d96127106103df606954612710610b789190610fac565b6103d9606a546103d3606b548d61091990919063ffffffff16565b6000898152606c60205260409020549091508111610bb2576000610bcb565b6000888152606c6020526040902054610bcb9082610fac565b98975050505050505050565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600054610100900460ff1680610c42575060005460ff16155b610c5e5760405162461bcd60e51b81526004016102ed90610e9d565b600054610100900460ff16158015610c80576000805461ffff19166101011790555b8015610880576000805461ff001916905550565b600054610100900460ff1680610cad575060005460ff16155b610cc95760405162461bcd60e51b81526004016102ed90610e9d565b600054610100900460ff16158015610ceb576000805461ffff19166101011790555b610c8033610bd7565b600054610100900460ff1680610d0d575060005460ff16155b610d295760405162461bcd60e51b81526004016102ed90610e9d565b600054610100900460ff16158015610d4b576000805461ffff19166101011790555b6127108210610d8a5760405162461bcd60e51b815260206004820152600b60248201526a3930ba34b79032b93937b960a91b60448201526064016102ed565b606580546001600160a01b038087166001600160a01b0319928316179092556068805492861692909116919091179055606982905580156104bf576000805461ff001916905550505050565b600060208284031215610de857600080fd5b5035919050565b6001600160a01b038116811461088057600080fd5b600080600060608486031215610e1957600080fd5b8335610e2481610def565b92506020840135610e3481610def565b929592945050506040919091013590565b600060208284031215610e5757600080fd5b813561092581610def565b600060208284031215610e7457600080fd5b5051919050565b600060208284031215610e8d57600080fd5b8151801515811461092557600080fd5b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b600060208284031215610f3257600080fd5b815161092581610def565b634e487b7160e01b600052601160045260246000fd5b60008219821115610f6657610f66610f3d565b500190565b6000816000190483118215151615610f8557610f85610f3d565b500290565b600082610fa757634e487b7160e01b600052601260045260246000fd5b500490565b600082821015610fbe57610fbe610f3d565b500390565b60008060008060808587031215610fd957600080fd5b845160ff81168114610fea57600080fd5b6020860151604087015160609097015191989097509094509250505056fea2646970667358221220140063633582eca3d6af1e5bd33d40204eca2d92e957d171f04320457b28fcb564736f6c634300080a0033