Overview
S Balance
0 S
S Value
$0.00More Info
Private Name Tags
ContractCreator
Latest 1 from a total of 1 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Initialize | 2322568 | 22 days ago | IN | 0 S | 0.00007522 |
Loading...
Loading
Contract Name:
NaviClubStaking
Compiler Version
v0.8.16+commit.07a7930e
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity ^0.8.16; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "./EpochRewardDistributor.sol"; import "@openzeppelin/contracts/token/ERC721/IERC721.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; import "./INaviClubNFT.sol"; import "./IEpochRewardDistributor.sol"; contract NaviClubStaking is IERC721Receiver, Ownable, ReentrancyGuard { using SafeERC20 for IERC20; struct Memberseat { uint256 lastSnapshotIndex; uint256 rewardEarned; } struct BoardroomSnapshot { uint256 time; uint256 rewardReceived; uint256 rewardPerShare; } /* ========== STATE VARIABLES ========== */ bool public isInitialized; uint256 public totalPower; uint256 public totalSupply; uint256 public totalRewardDistributed; mapping(address => uint256) public balances; mapping(address => uint256[]) public depositedNFT; mapping(uint256 => address) public stakerOfNFT; // epoch uint256 public lastEpochTime; uint256 public epoch = 0; uint256 public epochLength = 0; // reward uint256 public epochReward; address public nft; address public reward; // USDC address public distributor; mapping(address => Memberseat) public members; BoardroomSnapshot[] public boardroomHistory; mapping(address => bool) public keeper; /* ========== EVENTS ========== */ event Staked(address indexed user, uint256 tokenId, uint256 weight); event Withdrawn(address indexed user, uint256 tokenId, uint256 weight); event EmergencyWithdraw( address indexed user, uint256 tokenId ); event RewardPaid(address indexed user, uint256 earned); event RewardTaxed(address indexed user, uint256 taxed); event RewardAdded(address indexed user, uint256 amount); event OnERC721Received( address operator, address from, uint256 tokenId, bytes data ); /* ========== Modifiers =============== */ modifier checkEpoch() { uint256 _nextEpochPoint = nextEpochPoint(); require(block.timestamp >= _nextEpochPoint, "!opened"); _; lastEpochTime = _nextEpochPoint; epoch += 1; } modifier onlyKeeper() { require(keeper[msg.sender], "!keeper"); _; } modifier memberExists() { require(balances[msg.sender] > 0, "The member does not exist"); _; } modifier updateReward(address member) { if (member != address(0)) { _updateReward(member); } _; } function _updateReward(address member) internal { Memberseat memory seat = members[member]; seat.rewardEarned = earned(member); seat.lastSnapshotIndex = latestSnapshotIndex(); members[member] = seat; } /* ========== GOVERNANCE ========== */ constructor( address _nft, address _reward, uint256 _startTime, uint256 _epochLength, uint256 _epochReward ) { reward = _reward; nft = _nft; BoardroomSnapshot memory genesisSnapshot = BoardroomSnapshot({ time : block.number, rewardReceived : 0, rewardPerShare : 0 }); boardroomHistory.push(genesisSnapshot); epochLength = _epochLength; lastEpochTime = _startTime - epochLength; epochReward = _epochReward; keeper[msg.sender] = true; } function initialize( address _distributor ) external onlyOwner { require(!isInitialized, "RewardTracker: already initialized"); isInitialized = true; distributor = _distributor; } function setNextEpochPoint(uint256 _nextEpochPoint) external onlyKeeper { require( _nextEpochPoint >= block.timestamp, "nextEpochPoint could not be the past" ); lastEpochTime = _nextEpochPoint - epochLength; } function setEpochReward(uint256 _epochReward) external onlyKeeper { epochReward = _epochReward; } function setKeeper(address _address, bool _on) external onlyOwner { keeper[_address] = _on; } function nextEpochPoint() public view returns (uint256) { return lastEpochTime + epochLength; } function latestSnapshotIndex() public view returns (uint256) { return boardroomHistory.length - 1; } function getLatestSnapshot() internal view returns (BoardroomSnapshot memory){ return boardroomHistory[latestSnapshotIndex()]; } function getLastSnapshotIndexOf(address member) public view returns (uint256) { return members[member].lastSnapshotIndex; } function getLastSnapshotOf(address member) internal view returns (BoardroomSnapshot memory){ return boardroomHistory[getLastSnapshotIndexOf(member)]; } function rewardPerShare() public view returns (uint256) { return getLatestSnapshot().rewardPerShare; } function balanceOf(address _account) public view returns (uint256) { uint256[] memory tokenIds = depositedNFT[_account]; return tokenIds.length; } function earned(address member) public view returns (uint256) { uint256 latestRPS = getLatestSnapshot().rewardPerShare; uint256 storedRPS = getLastSnapshotOf(member).rewardPerShare; return (balances[member] * (latestRPS - storedRPS)) / 1e18 + members[member].rewardEarned; } function _stake(address _account, uint256 _tokenId) internal virtual { uint256 _power = uint256(INaviClubNFT(nft).getTokenPower(_tokenId)); require(_power > 0, "invalid power"); totalPower += _power; totalSupply += 1; balances[_account] += _power; depositedNFT[_account].push(_tokenId); stakerOfNFT[_tokenId] = _account; IERC721(nft).safeTransferFrom(_account, address(this), _tokenId); emit Staked(_account, _tokenId, _power); } function tokenOfOwnerByIndex(address _account, uint256 index) external view returns (uint256){ return depositedNFT[_account][index]; } function _removeUserCard(address _account, uint256 _tokenId) internal returns (bool){ uint256[] storage tokenIds = depositedNFT[_account]; uint256 _numCards = tokenIds.length; for (uint256 i = 0; i < _numCards; i++) { if (tokenIds[i] == _tokenId) { if (i < _numCards - 1) { tokenIds[i] = tokenIds[_numCards - 1]; } delete tokenIds[_numCards - 1]; tokenIds.pop(); return true; } } return false; } function _withdraw(address _account, uint256 _tokenId) internal virtual { uint256 _power = uint256(INaviClubNFT(nft).getTokenPower(_tokenId)); totalPower -= _power; totalSupply -= 1; balances[msg.sender] -= _power; stakerOfNFT[_tokenId] = address(0); require( _removeUserCard(_account, _tokenId), "Can not remove tokenId" ); IERC721(nft).safeTransferFrom(address(this), _account, _tokenId); emit Withdrawn(_account, _tokenId, _power); } function stake(uint256[] memory _tokenIds) external nonReentrant updateReward(msg.sender) { if (members[msg.sender].rewardEarned > 0) { claimReward(); } for (uint256 i = 0; i < _tokenIds.length; i++) { _stake(msg.sender, _tokenIds[i]); } } function withdraw(uint256[] memory _tokenIds) external nonReentrant memberExists updateReward(msg.sender) { if (members[msg.sender].rewardEarned > 0) { claimReward(); } for (uint256 i = 0; i < _tokenIds.length; i++) { _withdraw(msg.sender, _tokenIds[i]); } } function claimReward() public updateReward(msg.sender) { uint256 _earned = members[msg.sender].rewardEarned; if (_earned > 0) { members[msg.sender].rewardEarned = 0; _safeRewardTransfer(msg.sender, _earned); emit RewardPaid(msg.sender, _earned); } } function _safeRewardTransfer(address _to, uint256 _amount) internal returns (uint256) { IERC20 _reward = IERC20(reward); uint256 _rewardBal = _reward.balanceOf(address(this)); if (_rewardBal > 0) { if (_amount > _rewardBal) { _reward.safeTransfer(_to, _rewardBal); return _rewardBal; } else { _reward.safeTransfer(_to, _amount); return _amount; } } return 0; } function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external override returns (bytes4) { emit OnERC721Received(operator, from, tokenId, data); return this.onERC721Received.selector; } function allocateReward() external { allocateRewardManually(epochReward); } function allocateRewardManually(uint256 _rewardAmount) public nonReentrant checkEpoch onlyKeeper { uint256 _amount = totalPower == 0 ? 0 : _rewardAmount; epochReward = _amount; // Create & add new snapshot uint256 prevRPS = getLatestSnapshot().rewardPerShare; uint256 nextRPS = _amount == 0 ? 0 : prevRPS + ((_amount * 1e18) / totalPower); BoardroomSnapshot memory newSnapshot = BoardroomSnapshot({ time : block.number, rewardReceived : _amount, rewardPerShare : nextRPS }); boardroomHistory.push(newSnapshot); IEpochRewardDistributor(distributor).distribute(reward, _amount); totalRewardDistributed += _amount; emit RewardAdded(msg.sender, _amount); } /** * @dev Withdraw stuck ERC20 tokens from the contract. * @param _token Address of the ERC20 token. * @param _to Address to send the tokens to. * @param _amount Amount of tokens to withdraw. */ function rescueERC20(address _token, address _to, uint256 _amount) external onlyOwner { require(_to != address(0), "Invalid recipient address"); require(IERC20(_token).transfer(_to, _amount), "Transfer failed"); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.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 Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { _checkOwner(); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { require(owner() == _msgSender(), "Ownable: caller is not the owner"); } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby disabling 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); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol) pragma solidity ^0.8.0; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor() { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { _nonReentrantBefore(); _; _nonReentrantAfter(); } function _nonReentrantBefore() private { // On the first call to nonReentrant, _status will be _NOT_ENTERED require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; } function _nonReentrantAfter() private { // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } /** * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a * `nonReentrant` function in the call stack. */ function _reentrancyGuardEntered() internal view returns (bool) { return _status == _ENTERED; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 amount) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/extensions/IERC20Permit.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. */ interface IERC20Permit { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; import "../extensions/IERC20Permit.sol"; import "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; /** * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } /** * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful. */ function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } /** * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 oldAllowance = token.allowance(address(this), spender); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value)); } /** * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value)); } } /** * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval * to be set to zero before setting it to a non-zero value, such as USDT. */ function forceApprove(IERC20 token, address spender, uint256 value) internal { bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value); if (!_callOptionalReturnBool(token, approvalCall)) { _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0)); _callOptionalReturn(token, approvalCall); } } /** * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`. * Revert on invalid signature. */ function safePermit( IERC20Permit token, address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) internal { uint256 nonceBefore = token.nonces(owner); token.permit(owner, spender, value, deadline, v, r, s); uint256 nonceAfter = token.nonces(owner); require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed"); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). * * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead. */ function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false // and not revert is the subcall reverts. (bool success, bytes memory returndata) = address(token).call(data); return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC721/ERC721.sol) pragma solidity ^0.8.0; import "./IERC721.sol"; import "./IERC721Receiver.sol"; import "./extensions/IERC721Metadata.sol"; import "../../utils/Address.sol"; import "../../utils/Context.sol"; import "../../utils/Strings.sol"; import "../../utils/introspection/ERC165.sol"; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: address zero is not a valid owner"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _ownerOf(tokenId); require(owner != address(0), "ERC721: invalid token ID"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { _requireMinted(tokenId); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overridden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not token owner or approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { _requireMinted(tokenId); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom(address from, address to, uint256 tokenId) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner or approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom(address from, address to, uint256 tokenId) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner or approved"); _safeTransfer(from, to, tokenId, data); } /** * @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. * * `data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer(address from, address to, uint256 tokenId, bytes memory data) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns the owner of the `tokenId`. Does NOT revert if token doesn't exist */ function _ownerOf(uint256 tokenId) internal view virtual returns (address) { return _owners[tokenId]; } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _ownerOf(tokenId) != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { address owner = ERC721.ownerOf(tokenId); return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint(address to, uint256 tokenId, bytes memory data) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId, 1); // Check that tokenId was not minted by `_beforeTokenTransfer` hook require(!_exists(tokenId), "ERC721: token already minted"); unchecked { // Will not overflow unless all 2**256 token ids are minted to the same owner. // Given that tokens are minted one by one, it is impossible in practice that // this ever happens. Might change if we allow batch minting. // The ERC fails to describe this case. _balances[to] += 1; } _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); _afterTokenTransfer(address(0), to, tokenId, 1); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * This is an internal function that does not check if the sender is authorized to operate on the token. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId, 1); // Update ownership in case tokenId was transferred by `_beforeTokenTransfer` hook owner = ERC721.ownerOf(tokenId); // Clear approvals delete _tokenApprovals[tokenId]; unchecked { // Cannot overflow, as that would require more tokens to be burned/transferred // out than the owner initially received through minting and transferring in. _balances[owner] -= 1; } delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); _afterTokenTransfer(owner, address(0), tokenId, 1); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer(address from, address to, uint256 tokenId) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId, 1); // Check that tokenId was not transferred by `_beforeTokenTransfer` hook require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner"); // Clear approvals from the previous owner delete _tokenApprovals[tokenId]; unchecked { // `_balances[from]` cannot overflow for the same reason as described in `_burn`: // `from`'s balance is the number of token held, which is at least one before the current // transfer. // `_balances[to]` could overflow in the conditions described in `_mint`. That would require // all 2**256 token ids to be minted, which in practice is impossible. _balances[from] -= 1; _balances[to] += 1; } _owners[tokenId] = to; emit Transfer(from, to, tokenId); _afterTokenTransfer(from, to, tokenId, 1); } /** * @dev Approve `to` to operate on `tokenId` * * Emits an {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits an {ApprovalForAll} event. */ function _setApprovalForAll(address owner, address operator, bool approved) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Reverts if the `tokenId` has not been minted yet. */ function _requireMinted(uint256 tokenId) internal view virtual { require(_exists(tokenId), "ERC721: invalid token ID"); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { /// @solidity memory-safe-assembly assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting and burning. If {ERC721Consecutive} is * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s tokens will be transferred to `to`. * - When `from` is zero, the tokens will be minted for `to`. * - When `to` is zero, ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * - `batchSize` is non-zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 firstTokenId, uint256 batchSize) internal virtual {} /** * @dev Hook that is called after any token transfer. This includes minting and burning. If {ERC721Consecutive} is * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s tokens were transferred to `to`. * - When `from` is zero, the tokens were minted for `to`. * - When `to` is zero, ``from``'s tokens were burned. * - `from` and `to` are never both zero. * - `batchSize` is non-zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer(address from, address to, uint256 firstTokenId, uint256 batchSize) internal virtual {} /** * @dev Unsafe write access to the balances, used by extensions that "mint" tokens using an {ownerOf} override. * * WARNING: Anyone calling this MUST ensure that the balances remain consistent with the ownership. The invariant * being that for any address `a` the value returned by `balanceOf(a)` must be equal to the number of tokens such * that `ownerOf(tokenId)` is `a`. */ // solhint-disable-next-line func-name-mixedcase function __unsafe_increaseBalance(address account, uint256 amount) internal { _balances[account] += amount; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @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`. * * 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; /** * @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 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: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721 * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must * understand this adds an external call which potentially creates a reentrancy vulnerability. * * 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 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 the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @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); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/extensions/ERC721Enumerable.sol) pragma solidity ^0.8.0; import "../ERC721.sol"; import "./IERC721Enumerable.sol"; /** * @dev This implements an optional extension of {ERC721} defined in the EIP that adds * enumerability of all the token ids in the contract as well as all token ids owned by each * account. */ abstract contract ERC721Enumerable is ERC721, IERC721Enumerable { // Mapping from owner to list of owned token IDs mapping(address => mapping(uint256 => uint256)) private _ownedTokens; // Mapping from token ID to index of the owner tokens list mapping(uint256 => uint256) private _ownedTokensIndex; // Array with all token ids, used for enumeration uint256[] private _allTokens; // Mapping from token id to position in the allTokens array mapping(uint256 => uint256) private _allTokensIndex; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) { return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds"); return _ownedTokens[owner][index]; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _allTokens.length; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds"); return _allTokens[index]; } /** * @dev See {ERC721-_beforeTokenTransfer}. */ function _beforeTokenTransfer( address from, address to, uint256 firstTokenId, uint256 batchSize ) internal virtual override { super._beforeTokenTransfer(from, to, firstTokenId, batchSize); if (batchSize > 1) { // Will only trigger during construction. Batch transferring (minting) is not available afterwards. revert("ERC721Enumerable: consecutive transfers not supported"); } uint256 tokenId = firstTokenId; if (from == address(0)) { _addTokenToAllTokensEnumeration(tokenId); } else if (from != to) { _removeTokenFromOwnerEnumeration(from, tokenId); } if (to == address(0)) { _removeTokenFromAllTokensEnumeration(tokenId); } else if (to != from) { _addTokenToOwnerEnumeration(to, tokenId); } } /** * @dev Private function to add a token to this extension's ownership-tracking data structures. * @param to address representing the new owner of the given token ID * @param tokenId uint256 ID of the token to be added to the tokens list of the given address */ function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private { uint256 length = ERC721.balanceOf(to); _ownedTokens[to][length] = tokenId; _ownedTokensIndex[tokenId] = length; } /** * @dev Private function to add a token to this extension's token tracking data structures. * @param tokenId uint256 ID of the token to be added to the tokens list */ function _addTokenToAllTokensEnumeration(uint256 tokenId) private { _allTokensIndex[tokenId] = _allTokens.length; _allTokens.push(tokenId); } /** * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for * gas optimizations e.g. when performing a transfer operation (avoiding double writes). * This has O(1) time complexity, but alters the order of the _ownedTokens array. * @param from address representing the previous owner of the given token ID * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private { // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = ERC721.balanceOf(from) - 1; uint256 tokenIndex = _ownedTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary if (tokenIndex != lastTokenIndex) { uint256 lastTokenId = _ownedTokens[from][lastTokenIndex]; _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index } // This also deletes the contents at the last position of the array delete _ownedTokensIndex[tokenId]; delete _ownedTokens[from][lastTokenIndex]; } /** * @dev Private function to remove a token from this extension's token tracking data structures. * This has O(1) time complexity, but alters the order of the _allTokens array. * @param tokenId uint256 ID of the token to be removed from the tokens list */ function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 tokenIndex = _allTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding // an 'if' statement (like in _removeTokenFromOwnerEnumeration) uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index // This also deletes the contents at the last position of the array delete _allTokensIndex[tokenId]; _allTokens.pop(); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol) pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * * Furthermore, `isContract` will also return true if the target contract within * the same transaction is already scheduled for destruction by `SELFDESTRUCT`, * which only has an effect at the end of a transaction. * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol) pragma solidity ^0.8.0; import "./math/Math.sol"; import "./math/SignedMath.sol"; /** * @dev String operations. */ library Strings { bytes16 private constant _SYMBOLS = "0123456789abcdef"; uint8 private constant _ADDRESS_LENGTH = 20; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { unchecked { uint256 length = Math.log10(value) + 1; string memory buffer = new string(length); uint256 ptr; /// @solidity memory-safe-assembly assembly { ptr := add(buffer, add(32, length)) } while (true) { ptr--; /// @solidity memory-safe-assembly assembly { mstore8(ptr, byte(mod(value, 10), _SYMBOLS)) } value /= 10; if (value == 0) break; } return buffer; } } /** * @dev Converts a `int256` to its ASCII `string` decimal representation. */ function toString(int256 value) internal pure returns (string memory) { return string(abi.encodePacked(value < 0 ? "-" : "", toString(SignedMath.abs(value)))); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { unchecked { return toHexString(value, Math.log256(value) + 1); } } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } /** * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation. */ function toHexString(address addr) internal pure returns (string memory) { return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH); } /** * @dev Returns true if the two strings are equal. */ function equal(string memory a, string memory b) internal pure returns (bool) { return keccak256(bytes(a)) == keccak256(bytes(b)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol) pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { enum Rounding { Down, // Toward negative infinity Up, // Toward infinity Zero // Toward zero } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds up instead * of rounding down. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) * with further edits by Uniswap Labs also under MIT license. */ function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod0 := mul(x, y) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { // Solidity will revert if denominator == 0, unlike the div opcode on its own. // The surrounding unchecked block does not change this fact. // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic. return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. require(denominator > prod1, "Math: mulDiv overflow"); /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1. // See https://cs.stackexchange.com/q/138556/92363. // Does not overflow because the denominator cannot be zero at this stage in the function. uint256 twos = denominator & (~denominator + 1); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works // in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`. // // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)` // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))` // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)` // // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1 << (log2(a) >> 1); // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = sqrt(a); return result + (rounding == Rounding.Up && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2, rounded down, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 128; } if (value >> 64 > 0) { value >>= 64; result += 64; } if (value >> 32 > 0) { value >>= 32; result += 32; } if (value >> 16 > 0) { value >>= 16; result += 16; } if (value >> 8 > 0) { value >>= 8; result += 8; } if (value >> 4 > 0) { value >>= 4; result += 4; } if (value >> 2 > 0) { value >>= 2; result += 2; } if (value >> 1 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 2, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log2(value); return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10, rounded down, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >= 10 ** 64) { value /= 10 ** 64; result += 64; } if (value >= 10 ** 32) { value /= 10 ** 32; result += 32; } if (value >= 10 ** 16) { value /= 10 ** 16; result += 16; } if (value >= 10 ** 8) { value /= 10 ** 8; result += 8; } if (value >= 10 ** 4) { value /= 10 ** 4; result += 4; } if (value >= 10 ** 2) { value /= 10 ** 2; result += 2; } if (value >= 10 ** 1) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0); } } /** * @dev Return the log in base 256, rounded down, of a positive value. * Returns 0 if given 0. * * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string. */ function log256(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 16; } if (value >> 64 > 0) { value >>= 64; result += 8; } if (value >> 32 > 0) { value >>= 32; result += 4; } if (value >> 16 > 0) { value >>= 16; result += 2; } if (value >> 8 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 256, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol) pragma solidity ^0.8.0; /** * @dev Standard signed math utilities missing in the Solidity language. */ library SignedMath { /** * @dev Returns the largest of two signed numbers. */ function max(int256 a, int256 b) internal pure returns (int256) { return a > b ? a : b; } /** * @dev Returns the smallest of two signed numbers. */ function min(int256 a, int256 b) internal pure returns (int256) { return a < b ? a : b; } /** * @dev Returns the average of two signed numbers without overflow. * The result is rounded towards zero. */ function average(int256 a, int256 b) internal pure returns (int256) { // Formula from the book "Hacker's Delight" int256 x = (a & b) + ((a ^ b) >> 1); return x + (int256(uint256(x) >> 255) & (a ^ b)); } /** * @dev Returns the absolute unsigned value of a signed value. */ function abs(int256 n) internal pure returns (uint256) { unchecked { // must be unchecked in order to support `n = type(int256).min` return uint256(n >= 0 ? n : -n); } } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.16; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "./IEpochRewardDistributor.sol"; contract EpochRewardDistributor is Ownable, IEpochRewardDistributor { using SafeERC20 for IERC20; address public rewardTracker; event Distribute(uint256 amount); constructor(address _rewardTracker) public { rewardTracker = _rewardTracker; } function distribute(address rewardToken, uint256 amount) external override returns (uint256) { require(msg.sender == rewardTracker, "RewardFund: invalid msg.sender"); IERC20(rewardToken).safeTransfer(msg.sender, amount); emit Distribute(amount); return amount; } // to help users who accidentally send their tokens to this contract function withdrawToken(address _token, address _account, uint256 _amount) external onlyOwner { IERC20(_token).safeTransfer(_account, _amount); } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.16; interface IEpochRewardDistributor { function distribute(address rewardToken, uint256 amount) external returns (uint256); }
// SPDX-License-Identifier: MIT pragma solidity 0.8.16; import "@openzeppelin/contracts/token/ERC721/IERC721.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; interface INaviClubNFT is IERC721, IERC721Enumerable { function getTokenPower(uint256 tokenId) external view returns (uint256); }
{ "evmVersion": "london", "libraries": {}, "metadata": { "bytecodeHash": "ipfs", "useLiteralContent": true }, "optimizer": { "enabled": true, "runs": 200 }, "remappings": [], "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } } }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"_nft","type":"address"},{"internalType":"address","name":"_reward","type":"address"},{"internalType":"uint256","name":"_startTime","type":"uint256"},{"internalType":"uint256","name":"_epochLength","type":"uint256"},{"internalType":"uint256","name":"_epochReward","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"EmergencyWithdraw","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"data","type":"bytes"}],"name":"OnERC721Received","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"RewardAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"earned","type":"uint256"}],"name":"RewardPaid","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"taxed","type":"uint256"}],"name":"RewardTaxed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"weight","type":"uint256"}],"name":"Staked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"weight","type":"uint256"}],"name":"Withdrawn","type":"event"},{"inputs":[],"name":"allocateReward","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_rewardAmount","type":"uint256"}],"name":"allocateRewardManually","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"balances","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"boardroomHistory","outputs":[{"internalType":"uint256","name":"time","type":"uint256"},{"internalType":"uint256","name":"rewardReceived","type":"uint256"},{"internalType":"uint256","name":"rewardPerShare","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claimReward","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"depositedNFT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"distributor","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"member","type":"address"}],"name":"earned","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"epoch","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"epochLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"epochReward","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"member","type":"address"}],"name":"getLastSnapshotIndexOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_distributor","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"isInitialized","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"keeper","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastEpochTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"latestSnapshotIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"members","outputs":[{"internalType":"uint256","name":"lastSnapshotIndex","type":"uint256"},{"internalType":"uint256","name":"rewardEarned","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nextEpochPoint","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nft","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"address","name":"from","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"onERC721Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"rescueERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"reward","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardPerShare","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_epochReward","type":"uint256"}],"name":"setEpochReward","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"},{"internalType":"bool","name":"_on","type":"bool"}],"name":"setKeeper","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_nextEpochPoint","type":"uint256"}],"name":"setNextEpochPoint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_tokenIds","type":"uint256[]"}],"name":"stake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"stakerOfNFT","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenOfOwnerByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalPower","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalRewardDistributed","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_tokenIds","type":"uint256[]"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
60806040526000600a556000600b553480156200001b57600080fd5b5060405162002081380380620020818339810160408190526200003e91620001ce565b620000493362000161565b6001808055600e80546001600160a01b038088166001600160a01b031992831617909255600d80549289169290911691909117905560408051606081018252438152600060208201818152928201818152601180549586018155909152815160039094027f31ecc21a745e3968a04e9570e4425bc18fa8019c68028196b546d1669c200c6881019490945591517f31ecc21a745e3968a04e9570e4425bc18fa8019c68028196b546d1669c200c6984015590517f31ecc21a745e3968a04e9570e4425bc18fa8019c68028196b546d1669c200c6a90920191909155600b83905562000135838562000221565b60095550600c555050336000908152601260205260409020805460ff1916600117905550620002499050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b80516001600160a01b0381168114620001c957600080fd5b919050565b600080600080600060a08688031215620001e757600080fd5b620001f286620001b1565b94506200020260208701620001b1565b6040870151606088015160809098015196999198509695945092505050565b818103818111156200024357634e487b7160e01b600052601160045260246000fd5b92915050565b611e2880620002596000396000f3fe608060405234801561001057600080fd5b50600436106102315760003560e01c8063715018a611610130578063bfe10928116100b8578063db3ad22c1161007c578063db3ad22c146104f6578063e8cf8608146104ff578063ec9bccd314610522578063f2fde38b14610535578063fdc3a7621461054857600080fd5b8063bfe1092814610487578063c4d66de81461049a578063c58e3843146104ad578063c5967c26146104db578063d1b9e853146104e357600080fd5b8063983d95ce116100ff578063983d95ce14610433578063ab9bebde14610446578063b2118a8d14610459578063b88a802f1461046c578063ba79f6b01461047457600080fd5b8063715018a61461040857806389c614b8146104105780638da5cb5b14610419578063900cf0cf1461042a57600080fd5b80632f745c59116101be578063446a2ec811610182578063446a2ec8146103a857806347ccca02146103b057806357d775f8146103c357806370a08231146103cc578063714b4658146103df57600080fd5b80632f745c591461033e57806330188ee814610351578063372a45981461035a578063392e53cd146103835780633f9e3f04146103a057600080fd5b80631604e416116102055780631604e416146102d957806318160ddd146102e2578063228cb733146102eb57806327e235e3146103165780632abd4dee1461033657600080fd5b80628cc2621461023657806308ae4b0c1461025c5780630fbf0a9314610298578063150b7a02146102ad575b600080fd5b6102496102443660046119bd565b61055b565b6040519081526020015b60405180910390f35b61028361026a3660046119bd565b6010602052600090815260409020805460019091015482565b60408051928352602083019190915201610253565b6102ab6102a63660046119f5565b6105ee565b005b6102c06102bb366004611ab3565b610675565b6040516001600160e01b03199091168152602001610253565b610249600c5481565b61024960045481565b600e546102fe906001600160a01b031681565b6040516001600160a01b039091168152602001610253565b6102496103243660046119bd565b60066020526000908152604090205481565b6102ab6106c8565b61024961034c366004611b4e565b6106d5565b61024960055481565b6102fe610368366004611b78565b6008602052600090815260409020546001600160a01b031681565b6002546103909060ff1681565b6040519015158152602001610253565b610249610713565b61024961072a565b600d546102fe906001600160a01b031681565b610249600b5481565b6102496103da3660046119bd565b61073d565b6102496103ed3660046119bd565b6001600160a01b031660009081526010602052604090205490565b6102ab6107a8565b61024960095481565b6000546001600160a01b03166102fe565b610249600a5481565b6102ab6104413660046119f5565b6107ba565b610249610454366004611b4e565b610894565b6102ab610467366004611b91565b6108c5565b6102ab6109d9565b6102ab610482366004611b78565b610a5a565b600f546102fe906001600160a01b031681565b6102ab6104a83660046119bd565b610a8e565b6104c06104bb366004611b78565b610b24565b60408051938452602084019290925290820152606001610253565b610249610b57565b6102ab6104f1366004611bdb565b610b69565b61024960035481565b61039061050d3660046119bd565b60126020526000908152604090205460ff1681565b6102ab610530366004611b78565b610b9c565b6102ab6105433660046119bd565b610e15565b6102ab610556366004611b78565b610e8b565b600080610566610f29565b604001519050600061057784610fa3565b6040908101516001600160a01b038616600090815260106020529190912060010154909150670de0b6b3a76400006105af8385611c28565b6001600160a01b0387166000908152600660205260409020546105d29190611c3b565b6105dc9190611c5a565b6105e69190611c7c565b949350505050565b6105f6611036565b338015610606576106068161108f565b3360009081526010602052604090206001015415610626576106266109d9565b60005b8251811015610667576106553384838151811061064857610648611c8f565b6020026020010151611102565b8061065f81611ca5565b915050610629565b505061067260018055565b50565b60007f15e63df890c010799d5a5fbe20c68fa6097dfd0d0203223676f1517927e5065486868686866040516106ae959493929190611cbe565b60405180910390a150630a85bd0160e11b95945050505050565b6106d3600c54610b9c565b565b6001600160a01b03821660009081526007602052604081208054839081106106ff576106ff611c8f565b906000526020600020015490505b92915050565b60115460009061072590600190611c28565b905090565b6000610734610f29565b60400151905090565b6001600160a01b03811660009081526007602090815260408083208054825181850281018501909352808352849383018282801561079a57602002820191906000526020600020905b815481526020019060010190808311610786575b505092519695505050505050565b6107b0611307565b6106d36000611361565b6107c2611036565b336000908152600660205260409020546108235760405162461bcd60e51b815260206004820152601960248201527f546865206d656d62657220646f6573206e6f742065786973740000000000000060448201526064015b60405180910390fd5b338015610833576108338161108f565b3360009081526010602052604090206001015415610853576108536109d9565b60005b8251811015610667576108823384838151811061087557610875611c8f565b60200260200101516113b1565b8061088c81611ca5565b915050610856565b600760205281600052604060002081815481106108b057600080fd5b90600052602060002001600091509150505481565b6108cd611307565b6001600160a01b0382166109235760405162461bcd60e51b815260206004820152601960248201527f496e76616c696420726563697069656e74206164647265737300000000000000604482015260640161081a565b60405163a9059cbb60e01b81526001600160a01b0383811660048301526024820183905284169063a9059cbb906044016020604051808303816000875af1158015610972573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109969190611d12565b6109d45760405162461bcd60e51b815260206004820152600f60248201526e151c985b9cd9995c8819985a5b1959608a1b604482015260640161081a565b505050565b3380156109e9576109e98161108f565b336000908152601060205260409020600101548015610a565733600081815260106020526040812060010155610a1f908261158e565b5060405181815233907fe2403640ba68fed3a2f88b7557551d1993f84b99bb10ff833f0cf8db0c5e04869060200160405180910390a25b5050565b3360009081526012602052604090205460ff16610a895760405162461bcd60e51b815260040161081a90611d2f565b600c55565b610a96611307565b60025460ff1615610af45760405162461bcd60e51b815260206004820152602260248201527f526577617264547261636b65723a20616c726561647920696e697469616c697a604482015261195960f21b606482015260840161081a565b6002805460ff19166001179055600f80546001600160a01b039092166001600160a01b0319909216919091179055565b60118181548110610b3457600080fd5b600091825260209091206003909102018054600182015460029092015490925083565b6000600b546009546107259190611c7c565b610b71611307565b6001600160a01b03919091166000908152601260205260409020805460ff1916911515919091179055565b610ba4611036565b6000610bae610b57565b905080421015610bea5760405162461bcd60e51b8152602060048201526007602482015266085bdc195b995960ca1b604482015260640161081a565b3360009081526012602052604090205460ff16610c195760405162461bcd60e51b815260040161081a90611d2f565b6000600354600014610c2b5782610c2e565b60005b600c81905590506000610c3f610f29565b60400151905060008215610c7b57600354610c6284670de0b6b3a7640000611c3b565b610c6c9190611c5a565b610c769083611c7c565b610c7e565b60005b60408051606081018252438152602081018681528183018481526011805460018101825560009190915283517f31ecc21a745e3968a04e9570e4425bc18fa8019c68028196b546d1669c200c6860039092029182015591517f31ecc21a745e3968a04e9570e4425bc18fa8019c68028196b546d1669c200c69830155517f31ecc21a745e3968a04e9570e4425bc18fa8019c68028196b546d1669c200c6a90910155600f54600e549251631f72642160e31b81526001600160a01b03938416600482015260248101889052939450909291169063fb932108906044016020604051808303816000875af1158015610d79573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d9d9190611d50565b508360056000828254610db09190611c7c565b909155505060405184815233907fac24935fd910bc682b5ccb1a07b718cadf8cf2f6d1404c4f3ddc3662dae40e299060200160405180910390a250505050806009819055506001600a6000828254610e089190611c7c565b9091555050600180555050565b610e1d611307565b6001600160a01b038116610e825760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161081a565b61067281611361565b3360009081526012602052604090205460ff16610eba5760405162461bcd60e51b815260040161081a90611d2f565b42811015610f165760405162461bcd60e51b8152602060048201526024808201527f6e65787445706f6368506f696e7420636f756c64206e6f7420626520746865206044820152631c185cdd60e21b606482015260840161081a565b600b54610f239082611c28565b60095550565b610f4d60405180606001604052806000815260200160008152602001600081525090565b6011610f57610713565b81548110610f6757610f67611c8f565b90600052602060002090600302016040518060600160405290816000820154815260200160018201548152602001600282015481525050905090565b610fc760405180606001604052806000815260200160008152602001600081525090565b6011610fe8836001600160a01b031660009081526010602052604090205490565b81548110610ff857610ff8611c8f565b906000526020600020906003020160405180606001604052908160008201548152602001600182015481526020016002820154815250509050919050565b6002600154036110885760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640161081a565b6002600155565b6001600160a01b03811660009081526010602090815260409182902082518084019093528054835260010154908201526110c88261055b565b60208201526110d5610713565b81526001600160a01b03909116600090815260106020908152604090912082518155910151600190910155565b600d546040516343e2ec1960e11b8152600481018390526000916001600160a01b0316906387c5d83290602401602060405180830381865afa15801561114c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111709190611d50565b9050600081116111b25760405162461bcd60e51b815260206004820152600d60248201526c34b73b30b634b2103837bbb2b960991b604482015260640161081a565b80600360008282546111c49190611c7c565b925050819055506001600460008282546111de9190611c7c565b90915550506001600160a01b0383166000908152600660205260408120805483929061120b908490611c7c565b90915550506001600160a01b03838116600081815260076020908152604080832080546001810182559084528284200187905586835260089091529081902080546001600160a01b03191683179055600d549051632142170760e11b8152600481019290925230602483015260448201859052909116906342842e0e90606401600060405180830381600087803b1580156112a557600080fd5b505af11580156112b9573d6000803e3d6000fd5b505060408051858152602081018590526001600160a01b03871693507f1449c6dd7851abc30abf37f57715f492010519147cc2652fbc38202c18a6ee909250015b60405180910390a2505050565b6000546001600160a01b031633146106d35760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161081a565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600d546040516343e2ec1960e11b8152600481018390526000916001600160a01b0316906387c5d83290602401602060405180830381865afa1580156113fb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061141f9190611d50565b905080600360008282546114339190611c28565b9250508190555060016004600082825461144d9190611c28565b90915550503360009081526006602052604081208054839290611471908490611c28565b9091555050600082815260086020526040902080546001600160a01b031916905561149c8383611655565b6114e15760405162461bcd60e51b815260206004820152601660248201527510d85b881b9bdd081c995b5bdd99481d1bdad95b925960521b604482015260640161081a565b600d54604051632142170760e11b81523060048201526001600160a01b03858116602483015260448201859052909116906342842e0e90606401600060405180830381600087803b15801561153557600080fd5b505af1158015611549573d6000803e3d6000fd5b505060408051858152602081018590526001600160a01b03871693507f92ccf450a286a957af52509bc1c9939d1a6a481783e142e41e2499f0bb66ebc69250016112fa565b600e546040516370a0823160e01b81523060048201526000916001600160a01b031690829082906370a0823190602401602060405180830381865afa1580156115db573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115ff9190611d50565b9050801561164a578084111561162c576116236001600160a01b038316868361176e565b915061070d9050565b6116406001600160a01b038316868661176e565b839250505061070d565b506000949350505050565b6001600160a01b03821660009081526007602052604081208054825b81811015611762578483828154811061168c5761168c611c8f565b906000526020600020015403611750576116a7600183611c28565b8110156116f457826116ba600184611c28565b815481106116ca576116ca611c8f565b90600052602060002001548382815481106116e7576116e7611c8f565b6000918252602090912001555b82611700600184611c28565b8154811061171057611710611c8f565b90600052602060002001600090558280548061172e5761172e611d69565b600190038181906000526020600020016000905590556001935050505061070d565b8061175a81611ca5565b915050611671565b50600095945050505050565b604080516001600160a01b03848116602483015260448083018590528351808403909101815260649092018352602080830180516001600160e01b031663a9059cbb60e01b17905283518085019094528084527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564908401526109d4928692916000916117fe91851690849061187e565b905080516000148061181f57508080602001905181019061181f9190611d12565b6109d45760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161081a565b60606105e6848460008585600080866001600160a01b031685876040516118a59190611da3565b60006040518083038185875af1925050503d80600081146118e2576040519150601f19603f3d011682016040523d82523d6000602084013e6118e7565b606091505b50915091506118f887838387611903565b979650505050505050565b6060831561197257825160000361196b576001600160a01b0385163b61196b5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161081a565b50816105e6565b6105e683838151156119875781518083602001fd5b8060405162461bcd60e51b815260040161081a9190611dbf565b80356001600160a01b03811681146119b857600080fd5b919050565b6000602082840312156119cf57600080fd5b6119d8826119a1565b9392505050565b634e487b7160e01b600052604160045260246000fd5b60006020808385031215611a0857600080fd5b823567ffffffffffffffff80821115611a2057600080fd5b818501915085601f830112611a3457600080fd5b813581811115611a4657611a466119df565b8060051b604051601f19603f83011681018181108582111715611a6b57611a6b6119df565b604052918252848201925083810185019188831115611a8957600080fd5b938501935b82851015611aa757843584529385019392850192611a8e565b98975050505050505050565b600080600080600060808688031215611acb57600080fd5b611ad4866119a1565b9450611ae2602087016119a1565b935060408601359250606086013567ffffffffffffffff80821115611b0657600080fd5b818801915088601f830112611b1a57600080fd5b813581811115611b2957600080fd5b896020828501011115611b3b57600080fd5b9699959850939650602001949392505050565b60008060408385031215611b6157600080fd5b611b6a836119a1565b946020939093013593505050565b600060208284031215611b8a57600080fd5b5035919050565b600080600060608486031215611ba657600080fd5b611baf846119a1565b9250611bbd602085016119a1565b9150604084013590509250925092565b801515811461067257600080fd5b60008060408385031215611bee57600080fd5b611bf7836119a1565b91506020830135611c0781611bcd565b809150509250929050565b634e487b7160e01b600052601160045260246000fd5b8181038181111561070d5761070d611c12565b6000816000190483118215151615611c5557611c55611c12565b500290565b600082611c7757634e487b7160e01b600052601260045260246000fd5b500490565b8082018082111561070d5761070d611c12565b634e487b7160e01b600052603260045260246000fd5b600060018201611cb757611cb7611c12565b5060010190565b6001600160a01b038681168252851660208201526040810184905260806060820181905281018290526000828460a0840137600060a0848401015260a0601f19601f85011683010190509695505050505050565b600060208284031215611d2457600080fd5b81516119d881611bcd565b60208082526007908201526610b5b2b2b832b960c91b604082015260600190565b600060208284031215611d6257600080fd5b5051919050565b634e487b7160e01b600052603160045260246000fd5b60005b83811015611d9a578181015183820152602001611d82565b50506000910152565b60008251611db5818460208701611d7f565b9190910192915050565b6020815260008251806020840152611dde816040850160208701611d7f565b601f01601f1916919091016040019291505056fea26469706673582212203a2383849b64c50e138b3c4e348e82dddf6d8c36ce601f0876d0b122e3646b6264736f6c63430008100033000000000000000000000000be924d57fd9858d912aefde359c996b06de791a3000000000000000000000000039e2fb66102314ce7b64ce5ce3e5183bc94ad3800000000000000000000000000000000000000000000000000000000677767220000000000000000000000000000000000000000000000000000000000093a800000000000000000000000000000000000000000000000000000000000000000
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106102315760003560e01c8063715018a611610130578063bfe10928116100b8578063db3ad22c1161007c578063db3ad22c146104f6578063e8cf8608146104ff578063ec9bccd314610522578063f2fde38b14610535578063fdc3a7621461054857600080fd5b8063bfe1092814610487578063c4d66de81461049a578063c58e3843146104ad578063c5967c26146104db578063d1b9e853146104e357600080fd5b8063983d95ce116100ff578063983d95ce14610433578063ab9bebde14610446578063b2118a8d14610459578063b88a802f1461046c578063ba79f6b01461047457600080fd5b8063715018a61461040857806389c614b8146104105780638da5cb5b14610419578063900cf0cf1461042a57600080fd5b80632f745c59116101be578063446a2ec811610182578063446a2ec8146103a857806347ccca02146103b057806357d775f8146103c357806370a08231146103cc578063714b4658146103df57600080fd5b80632f745c591461033e57806330188ee814610351578063372a45981461035a578063392e53cd146103835780633f9e3f04146103a057600080fd5b80631604e416116102055780631604e416146102d957806318160ddd146102e2578063228cb733146102eb57806327e235e3146103165780632abd4dee1461033657600080fd5b80628cc2621461023657806308ae4b0c1461025c5780630fbf0a9314610298578063150b7a02146102ad575b600080fd5b6102496102443660046119bd565b61055b565b6040519081526020015b60405180910390f35b61028361026a3660046119bd565b6010602052600090815260409020805460019091015482565b60408051928352602083019190915201610253565b6102ab6102a63660046119f5565b6105ee565b005b6102c06102bb366004611ab3565b610675565b6040516001600160e01b03199091168152602001610253565b610249600c5481565b61024960045481565b600e546102fe906001600160a01b031681565b6040516001600160a01b039091168152602001610253565b6102496103243660046119bd565b60066020526000908152604090205481565b6102ab6106c8565b61024961034c366004611b4e565b6106d5565b61024960055481565b6102fe610368366004611b78565b6008602052600090815260409020546001600160a01b031681565b6002546103909060ff1681565b6040519015158152602001610253565b610249610713565b61024961072a565b600d546102fe906001600160a01b031681565b610249600b5481565b6102496103da3660046119bd565b61073d565b6102496103ed3660046119bd565b6001600160a01b031660009081526010602052604090205490565b6102ab6107a8565b61024960095481565b6000546001600160a01b03166102fe565b610249600a5481565b6102ab6104413660046119f5565b6107ba565b610249610454366004611b4e565b610894565b6102ab610467366004611b91565b6108c5565b6102ab6109d9565b6102ab610482366004611b78565b610a5a565b600f546102fe906001600160a01b031681565b6102ab6104a83660046119bd565b610a8e565b6104c06104bb366004611b78565b610b24565b60408051938452602084019290925290820152606001610253565b610249610b57565b6102ab6104f1366004611bdb565b610b69565b61024960035481565b61039061050d3660046119bd565b60126020526000908152604090205460ff1681565b6102ab610530366004611b78565b610b9c565b6102ab6105433660046119bd565b610e15565b6102ab610556366004611b78565b610e8b565b600080610566610f29565b604001519050600061057784610fa3565b6040908101516001600160a01b038616600090815260106020529190912060010154909150670de0b6b3a76400006105af8385611c28565b6001600160a01b0387166000908152600660205260409020546105d29190611c3b565b6105dc9190611c5a565b6105e69190611c7c565b949350505050565b6105f6611036565b338015610606576106068161108f565b3360009081526010602052604090206001015415610626576106266109d9565b60005b8251811015610667576106553384838151811061064857610648611c8f565b6020026020010151611102565b8061065f81611ca5565b915050610629565b505061067260018055565b50565b60007f15e63df890c010799d5a5fbe20c68fa6097dfd0d0203223676f1517927e5065486868686866040516106ae959493929190611cbe565b60405180910390a150630a85bd0160e11b95945050505050565b6106d3600c54610b9c565b565b6001600160a01b03821660009081526007602052604081208054839081106106ff576106ff611c8f565b906000526020600020015490505b92915050565b60115460009061072590600190611c28565b905090565b6000610734610f29565b60400151905090565b6001600160a01b03811660009081526007602090815260408083208054825181850281018501909352808352849383018282801561079a57602002820191906000526020600020905b815481526020019060010190808311610786575b505092519695505050505050565b6107b0611307565b6106d36000611361565b6107c2611036565b336000908152600660205260409020546108235760405162461bcd60e51b815260206004820152601960248201527f546865206d656d62657220646f6573206e6f742065786973740000000000000060448201526064015b60405180910390fd5b338015610833576108338161108f565b3360009081526010602052604090206001015415610853576108536109d9565b60005b8251811015610667576108823384838151811061087557610875611c8f565b60200260200101516113b1565b8061088c81611ca5565b915050610856565b600760205281600052604060002081815481106108b057600080fd5b90600052602060002001600091509150505481565b6108cd611307565b6001600160a01b0382166109235760405162461bcd60e51b815260206004820152601960248201527f496e76616c696420726563697069656e74206164647265737300000000000000604482015260640161081a565b60405163a9059cbb60e01b81526001600160a01b0383811660048301526024820183905284169063a9059cbb906044016020604051808303816000875af1158015610972573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109969190611d12565b6109d45760405162461bcd60e51b815260206004820152600f60248201526e151c985b9cd9995c8819985a5b1959608a1b604482015260640161081a565b505050565b3380156109e9576109e98161108f565b336000908152601060205260409020600101548015610a565733600081815260106020526040812060010155610a1f908261158e565b5060405181815233907fe2403640ba68fed3a2f88b7557551d1993f84b99bb10ff833f0cf8db0c5e04869060200160405180910390a25b5050565b3360009081526012602052604090205460ff16610a895760405162461bcd60e51b815260040161081a90611d2f565b600c55565b610a96611307565b60025460ff1615610af45760405162461bcd60e51b815260206004820152602260248201527f526577617264547261636b65723a20616c726561647920696e697469616c697a604482015261195960f21b606482015260840161081a565b6002805460ff19166001179055600f80546001600160a01b039092166001600160a01b0319909216919091179055565b60118181548110610b3457600080fd5b600091825260209091206003909102018054600182015460029092015490925083565b6000600b546009546107259190611c7c565b610b71611307565b6001600160a01b03919091166000908152601260205260409020805460ff1916911515919091179055565b610ba4611036565b6000610bae610b57565b905080421015610bea5760405162461bcd60e51b8152602060048201526007602482015266085bdc195b995960ca1b604482015260640161081a565b3360009081526012602052604090205460ff16610c195760405162461bcd60e51b815260040161081a90611d2f565b6000600354600014610c2b5782610c2e565b60005b600c81905590506000610c3f610f29565b60400151905060008215610c7b57600354610c6284670de0b6b3a7640000611c3b565b610c6c9190611c5a565b610c769083611c7c565b610c7e565b60005b60408051606081018252438152602081018681528183018481526011805460018101825560009190915283517f31ecc21a745e3968a04e9570e4425bc18fa8019c68028196b546d1669c200c6860039092029182015591517f31ecc21a745e3968a04e9570e4425bc18fa8019c68028196b546d1669c200c69830155517f31ecc21a745e3968a04e9570e4425bc18fa8019c68028196b546d1669c200c6a90910155600f54600e549251631f72642160e31b81526001600160a01b03938416600482015260248101889052939450909291169063fb932108906044016020604051808303816000875af1158015610d79573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d9d9190611d50565b508360056000828254610db09190611c7c565b909155505060405184815233907fac24935fd910bc682b5ccb1a07b718cadf8cf2f6d1404c4f3ddc3662dae40e299060200160405180910390a250505050806009819055506001600a6000828254610e089190611c7c565b9091555050600180555050565b610e1d611307565b6001600160a01b038116610e825760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161081a565b61067281611361565b3360009081526012602052604090205460ff16610eba5760405162461bcd60e51b815260040161081a90611d2f565b42811015610f165760405162461bcd60e51b8152602060048201526024808201527f6e65787445706f6368506f696e7420636f756c64206e6f7420626520746865206044820152631c185cdd60e21b606482015260840161081a565b600b54610f239082611c28565b60095550565b610f4d60405180606001604052806000815260200160008152602001600081525090565b6011610f57610713565b81548110610f6757610f67611c8f565b90600052602060002090600302016040518060600160405290816000820154815260200160018201548152602001600282015481525050905090565b610fc760405180606001604052806000815260200160008152602001600081525090565b6011610fe8836001600160a01b031660009081526010602052604090205490565b81548110610ff857610ff8611c8f565b906000526020600020906003020160405180606001604052908160008201548152602001600182015481526020016002820154815250509050919050565b6002600154036110885760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640161081a565b6002600155565b6001600160a01b03811660009081526010602090815260409182902082518084019093528054835260010154908201526110c88261055b565b60208201526110d5610713565b81526001600160a01b03909116600090815260106020908152604090912082518155910151600190910155565b600d546040516343e2ec1960e11b8152600481018390526000916001600160a01b0316906387c5d83290602401602060405180830381865afa15801561114c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111709190611d50565b9050600081116111b25760405162461bcd60e51b815260206004820152600d60248201526c34b73b30b634b2103837bbb2b960991b604482015260640161081a565b80600360008282546111c49190611c7c565b925050819055506001600460008282546111de9190611c7c565b90915550506001600160a01b0383166000908152600660205260408120805483929061120b908490611c7c565b90915550506001600160a01b03838116600081815260076020908152604080832080546001810182559084528284200187905586835260089091529081902080546001600160a01b03191683179055600d549051632142170760e11b8152600481019290925230602483015260448201859052909116906342842e0e90606401600060405180830381600087803b1580156112a557600080fd5b505af11580156112b9573d6000803e3d6000fd5b505060408051858152602081018590526001600160a01b03871693507f1449c6dd7851abc30abf37f57715f492010519147cc2652fbc38202c18a6ee909250015b60405180910390a2505050565b6000546001600160a01b031633146106d35760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161081a565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600d546040516343e2ec1960e11b8152600481018390526000916001600160a01b0316906387c5d83290602401602060405180830381865afa1580156113fb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061141f9190611d50565b905080600360008282546114339190611c28565b9250508190555060016004600082825461144d9190611c28565b90915550503360009081526006602052604081208054839290611471908490611c28565b9091555050600082815260086020526040902080546001600160a01b031916905561149c8383611655565b6114e15760405162461bcd60e51b815260206004820152601660248201527510d85b881b9bdd081c995b5bdd99481d1bdad95b925960521b604482015260640161081a565b600d54604051632142170760e11b81523060048201526001600160a01b03858116602483015260448201859052909116906342842e0e90606401600060405180830381600087803b15801561153557600080fd5b505af1158015611549573d6000803e3d6000fd5b505060408051858152602081018590526001600160a01b03871693507f92ccf450a286a957af52509bc1c9939d1a6a481783e142e41e2499f0bb66ebc69250016112fa565b600e546040516370a0823160e01b81523060048201526000916001600160a01b031690829082906370a0823190602401602060405180830381865afa1580156115db573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115ff9190611d50565b9050801561164a578084111561162c576116236001600160a01b038316868361176e565b915061070d9050565b6116406001600160a01b038316868661176e565b839250505061070d565b506000949350505050565b6001600160a01b03821660009081526007602052604081208054825b81811015611762578483828154811061168c5761168c611c8f565b906000526020600020015403611750576116a7600183611c28565b8110156116f457826116ba600184611c28565b815481106116ca576116ca611c8f565b90600052602060002001548382815481106116e7576116e7611c8f565b6000918252602090912001555b82611700600184611c28565b8154811061171057611710611c8f565b90600052602060002001600090558280548061172e5761172e611d69565b600190038181906000526020600020016000905590556001935050505061070d565b8061175a81611ca5565b915050611671565b50600095945050505050565b604080516001600160a01b03848116602483015260448083018590528351808403909101815260649092018352602080830180516001600160e01b031663a9059cbb60e01b17905283518085019094528084527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564908401526109d4928692916000916117fe91851690849061187e565b905080516000148061181f57508080602001905181019061181f9190611d12565b6109d45760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161081a565b60606105e6848460008585600080866001600160a01b031685876040516118a59190611da3565b60006040518083038185875af1925050503d80600081146118e2576040519150601f19603f3d011682016040523d82523d6000602084013e6118e7565b606091505b50915091506118f887838387611903565b979650505050505050565b6060831561197257825160000361196b576001600160a01b0385163b61196b5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161081a565b50816105e6565b6105e683838151156119875781518083602001fd5b8060405162461bcd60e51b815260040161081a9190611dbf565b80356001600160a01b03811681146119b857600080fd5b919050565b6000602082840312156119cf57600080fd5b6119d8826119a1565b9392505050565b634e487b7160e01b600052604160045260246000fd5b60006020808385031215611a0857600080fd5b823567ffffffffffffffff80821115611a2057600080fd5b818501915085601f830112611a3457600080fd5b813581811115611a4657611a466119df565b8060051b604051601f19603f83011681018181108582111715611a6b57611a6b6119df565b604052918252848201925083810185019188831115611a8957600080fd5b938501935b82851015611aa757843584529385019392850192611a8e565b98975050505050505050565b600080600080600060808688031215611acb57600080fd5b611ad4866119a1565b9450611ae2602087016119a1565b935060408601359250606086013567ffffffffffffffff80821115611b0657600080fd5b818801915088601f830112611b1a57600080fd5b813581811115611b2957600080fd5b896020828501011115611b3b57600080fd5b9699959850939650602001949392505050565b60008060408385031215611b6157600080fd5b611b6a836119a1565b946020939093013593505050565b600060208284031215611b8a57600080fd5b5035919050565b600080600060608486031215611ba657600080fd5b611baf846119a1565b9250611bbd602085016119a1565b9150604084013590509250925092565b801515811461067257600080fd5b60008060408385031215611bee57600080fd5b611bf7836119a1565b91506020830135611c0781611bcd565b809150509250929050565b634e487b7160e01b600052601160045260246000fd5b8181038181111561070d5761070d611c12565b6000816000190483118215151615611c5557611c55611c12565b500290565b600082611c7757634e487b7160e01b600052601260045260246000fd5b500490565b8082018082111561070d5761070d611c12565b634e487b7160e01b600052603260045260246000fd5b600060018201611cb757611cb7611c12565b5060010190565b6001600160a01b038681168252851660208201526040810184905260806060820181905281018290526000828460a0840137600060a0848401015260a0601f19601f85011683010190509695505050505050565b600060208284031215611d2457600080fd5b81516119d881611bcd565b60208082526007908201526610b5b2b2b832b960c91b604082015260600190565b600060208284031215611d6257600080fd5b5051919050565b634e487b7160e01b600052603160045260246000fd5b60005b83811015611d9a578181015183820152602001611d82565b50506000910152565b60008251611db5818460208701611d7f565b9190910192915050565b6020815260008251806020840152611dde816040850160208701611d7f565b601f01601f1916919091016040019291505056fea26469706673582212203a2383849b64c50e138b3c4e348e82dddf6d8c36ce601f0876d0b122e3646b6264736f6c63430008100033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000be924d57fd9858d912aefde359c996b06de791a3000000000000000000000000039e2fb66102314ce7b64ce5ce3e5183bc94ad3800000000000000000000000000000000000000000000000000000000677767220000000000000000000000000000000000000000000000000000000000093a800000000000000000000000000000000000000000000000000000000000000000
-----Decoded View---------------
Arg [0] : _nft (address): 0xbE924d57fd9858d912aEFDe359c996b06dE791A3
Arg [1] : _reward (address): 0x039e2fB66102314Ce7b64Ce5Ce3E5183bc94aD38
Arg [2] : _startTime (uint256): 1735878434
Arg [3] : _epochLength (uint256): 604800
Arg [4] : _epochReward (uint256): 0
-----Encoded View---------------
5 Constructor Arguments found :
Arg [0] : 000000000000000000000000be924d57fd9858d912aefde359c996b06de791a3
Arg [1] : 000000000000000000000000039e2fb66102314ce7b64ce5ce3e5183bc94ad38
Arg [2] : 0000000000000000000000000000000000000000000000000000000067776722
Arg [3] : 0000000000000000000000000000000000000000000000000000000000093a80
Arg [4] : 0000000000000000000000000000000000000000000000000000000000000000
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.