Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
- Contract name:
- NFTStake
- Optimization enabled
- true
- Compiler version
- v0.8.23+commit.f704f362
- Optimization runs
- 20
- EVM Version
- london
- Verified at
- 2024-10-31T14:34:45.786813Z
Constructor Arguments
0x00000000000000000000000081e609b897393731a3d23c1d311330340cebb9e9
Arg [0] (address) : 0x81e609b897393731a3d23c1d311330340cebb9e9
contracts/prebuilts/staking/NFTStake.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.11; /// @author thirdweb // $$\ $$\ $$\ $$\ $$\ // $$ | $$ | \__| $$ | $$ | // $$$$$$\ $$$$$$$\ $$\ $$$$$$\ $$$$$$$ |$$\ $$\ $$\ $$$$$$\ $$$$$$$\ // \_$$ _| $$ __$$\ $$ |$$ __$$\ $$ __$$ |$$ | $$ | $$ |$$ __$$\ $$ __$$\ // $$ | $$ | $$ |$$ |$$ | \__|$$ / $$ |$$ | $$ | $$ |$$$$$$$$ |$$ | $$ | // $$ |$$\ $$ | $$ |$$ |$$ | $$ | $$ |$$ | $$ | $$ |$$ ____|$$ | $$ | // \$$$$ |$$ | $$ |$$ |$$ | \$$$$$$$ |\$$$$$\$$$$ |\$$$$$$$\ $$$$$$$ | // \____/ \__| \__|\__|\__| \_______| \_____\____/ \_______|\_______/ // Token import "../../eip/interface/IERC721.sol"; import "@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC721/IERC721ReceiverUpgradeable.sol"; // Meta transactions import "../../external-deps/openzeppelin/metatx/ERC2771ContextUpgradeable.sol"; // Utils import "../../extension/Multicall.sol"; import "../../lib/CurrencyTransferLib.sol"; // ========== Features ========== import "../../extension/ContractMetadata.sol"; import "../../extension/PermissionsEnumerable.sol"; import { Staking721Upgradeable } from "../../extension/Staking721Upgradeable.sol"; import "../interface/staking/INFTStake.sol"; contract NFTStake is Initializable, ContractMetadata, PermissionsEnumerable, ERC2771ContextUpgradeable, Multicall, Staking721Upgradeable, ERC165Upgradeable, IERC721ReceiverUpgradeable, INFTStake { bytes32 private constant MODULE_TYPE = bytes32("NFTStake"); uint256 private constant VERSION = 1; /// @dev The address of the native token wrapper contract. address internal immutable nativeTokenWrapper; /// @dev ERC20 Reward Token address. See {_mintRewards} below. address public rewardToken; /// @dev Total amount of reward tokens in the contract. uint256 private rewardTokenBalance; constructor(address _nativeTokenWrapper) initializer { nativeTokenWrapper = _nativeTokenWrapper; } /// @dev Initializes the contract, like a constructor. function initialize( address _defaultAdmin, string memory _contractURI, address[] memory _trustedForwarders, address _rewardToken, address _stakingToken, uint256 _timeUnit, uint256 _rewardsPerUnitTime ) external initializer { __ERC2771Context_init_unchained(_trustedForwarders); rewardToken = _rewardToken; __Staking721_init(_stakingToken); _setStakingCondition(_timeUnit, _rewardsPerUnitTime); _setupContractURI(_contractURI); _setupRole(DEFAULT_ADMIN_ROLE, _defaultAdmin); } /// @dev Returns the module type of the contract. function contractType() external pure virtual returns (bytes32) { return MODULE_TYPE; } /// @dev Returns the version of the contract. function contractVersion() external pure virtual returns (uint8) { return uint8(VERSION); } /// @dev Lets the contract receive ether to unwrap native tokens. receive() external payable { require(msg.sender == nativeTokenWrapper, "caller not native token wrapper."); } /// @dev Admin deposits reward tokens. function depositRewardTokens(uint256 _amount) external payable nonReentrant { require(hasRole(DEFAULT_ADMIN_ROLE, _msgSender()), "Not authorized"); address _rewardToken = rewardToken == CurrencyTransferLib.NATIVE_TOKEN ? nativeTokenWrapper : rewardToken; uint256 balanceBefore = IERC20(_rewardToken).balanceOf(address(this)); CurrencyTransferLib.transferCurrencyWithWrapper( rewardToken, _msgSender(), address(this), _amount, nativeTokenWrapper ); uint256 actualAmount = IERC20(_rewardToken).balanceOf(address(this)) - balanceBefore; rewardTokenBalance += actualAmount; emit RewardTokensDepositedByAdmin(actualAmount); } /// @dev Admin can withdraw excess reward tokens. function withdrawRewardTokens(uint256 _amount) external nonReentrant { require(hasRole(DEFAULT_ADMIN_ROLE, _msgSender()), "Not authorized"); // to prevent locking of direct-transferred tokens rewardTokenBalance = _amount > rewardTokenBalance ? 0 : rewardTokenBalance - _amount; CurrencyTransferLib.transferCurrencyWithWrapper( rewardToken, address(this), _msgSender(), _amount, nativeTokenWrapper ); emit RewardTokensWithdrawnByAdmin(_amount); } /// @notice View total rewards available in the staking contract. function getRewardTokenBalance() external view override returns (uint256) { return rewardTokenBalance; } /*/////////////////////////////////////////////////////////////// ERC 165 / 721 logic //////////////////////////////////////////////////////////////*/ function onERC721Received(address, address, uint256, bytes calldata) external view override returns (bytes4) { require(isStaking == 2, "Direct transfer"); return this.onERC721Received.selector; } function supportsInterface(bytes4 interfaceId) public view override returns (bool) { return interfaceId == type(IERC721ReceiverUpgradeable).interfaceId || super.supportsInterface(interfaceId); } /*/////////////////////////////////////////////////////////////// Transfer Staking Rewards //////////////////////////////////////////////////////////////*/ /// @dev Mint/Transfer ERC20 rewards to the staker. function _mintRewards(address _staker, uint256 _rewards) internal override { require(_rewards <= rewardTokenBalance, "Not enough reward tokens"); rewardTokenBalance -= _rewards; CurrencyTransferLib.transferCurrencyWithWrapper( rewardToken, address(this), _staker, _rewards, nativeTokenWrapper ); } /*/////////////////////////////////////////////////////////////// Internal functions //////////////////////////////////////////////////////////////*/ /// @dev Returns whether staking related restrictions can be set in the given execution context. function _canSetStakeConditions() internal view override returns (bool) { return hasRole(DEFAULT_ADMIN_ROLE, _msgSender()); } /// @dev Checks whether contract metadata can be set in the given execution context. function _canSetContractURI() internal view override returns (bool) { return hasRole(DEFAULT_ADMIN_ROLE, _msgSender()); } /*/////////////////////////////////////////////////////////////// Miscellaneous //////////////////////////////////////////////////////////////*/ function _stakeMsgSender() internal view virtual override returns (address) { return _msgSender(); } function _msgSender() internal view virtual override(ERC2771ContextUpgradeable, Multicall) returns (address sender) { return ERC2771ContextUpgradeable._msgSender(); } }
contracts/eip/interface/IERC20.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; /** * @title ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/20 */ interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address who) external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); function transfer(address to, uint256 value) external returns (bool); function approve(address spender, uint256 value) external returns (bool); function transferFrom(address from, address to, uint256 value) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); }
contracts/eip/interface/IERC721.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 { /** * @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); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 tokenId) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external; }
contracts/extension/ContractMetadata.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; /// @author thirdweb import "./interface/IContractMetadata.sol"; /** * @title Contract Metadata * @notice Thirdweb's `ContractMetadata` is a contract extension for any base contracts. It lets you set a metadata URI * for you contract. * Additionally, `ContractMetadata` is necessary for NFT contracts that want royalties to get distributed on OpenSea. */ abstract contract ContractMetadata is IContractMetadata { /// @dev The sender is not authorized to perform the action error ContractMetadataUnauthorized(); /// @notice Returns the contract metadata URI. string public override contractURI; /** * @notice Lets a contract admin set the URI for contract-level metadata. * @dev Caller should be authorized to setup contractURI, e.g. contract admin. * See {_canSetContractURI}. * Emits {ContractURIUpdated Event}. * * @param _uri keccak256 hash of the role. e.g. keccak256("TRANSFER_ROLE") */ function setContractURI(string memory _uri) external override { if (!_canSetContractURI()) { revert ContractMetadataUnauthorized(); } _setupContractURI(_uri); } /// @dev Lets a contract admin set the URI for contract-level metadata. function _setupContractURI(string memory _uri) internal { string memory prevURI = contractURI; contractURI = _uri; emit ContractURIUpdated(prevURI, _uri); } /// @dev Returns whether contract metadata can be set in the given execution context. function _canSetContractURI() internal view virtual returns (bool); }
contracts/extension/Multicall.sol
// SPDX-License-Identifier: Apache 2.0 pragma solidity ^0.8.0; /// @author thirdweb import "../lib/Address.sol"; import "./interface/IMulticall.sol"; /** * @dev Provides a function to batch together multiple calls in a single external call. * * _Available since v4.1._ */ contract Multicall is IMulticall { /** * @notice Receives and executes a batch of function calls on this contract. * @dev Receives and executes a batch of function calls on this contract. * * @param data The bytes data that makes up the batch of function calls to execute. * @return results The bytes data that makes up the result of the batch of function calls executed. */ function multicall(bytes[] calldata data) external returns (bytes[] memory results) { results = new bytes[](data.length); address sender = _msgSender(); bool isForwarder = msg.sender != sender; for (uint256 i = 0; i < data.length; i++) { if (isForwarder) { results[i] = Address.functionDelegateCall(address(this), abi.encodePacked(data[i], sender)); } else { results[i] = Address.functionDelegateCall(address(this), data[i]); } } return results; } /// @notice Returns the sender in the given execution context. function _msgSender() internal view virtual returns (address) { return msg.sender; } }
contracts/extension/Permissions.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; /// @author thirdweb import "./interface/IPermissions.sol"; import "../lib/Strings.sol"; /** * @title Permissions * @dev This contracts provides extending-contracts with role-based access control mechanisms */ contract Permissions is IPermissions { /// @dev The `account` is missing a role. error PermissionsUnauthorizedAccount(address account, bytes32 neededRole); /// @dev The `account` already is a holder of `role` error PermissionsAlreadyGranted(address account, bytes32 role); /// @dev Invalid priviledge to revoke error PermissionsInvalidPermission(address expected, address actual); /// @dev Map from keccak256 hash of a role => a map from address => whether address has role. mapping(bytes32 => mapping(address => bool)) private _hasRole; /// @dev Map from keccak256 hash of a role to role admin. See {getRoleAdmin}. mapping(bytes32 => bytes32) private _getRoleAdmin; /// @dev Default admin role for all roles. Only accounts with this role can grant/revoke other roles. bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /// @dev Modifier that checks if an account has the specified role; reverts otherwise. modifier onlyRole(bytes32 role) { _checkRole(role, msg.sender); _; } /** * @notice Checks whether an account has a particular role. * @dev Returns `true` if `account` has been granted `role`. * * @param role keccak256 hash of the role. e.g. keccak256("TRANSFER_ROLE") * @param account Address of the account for which the role is being checked. */ function hasRole(bytes32 role, address account) public view override returns (bool) { return _hasRole[role][account]; } /** * @notice Checks whether an account has a particular role; * role restrictions can be swtiched on and off. * * @dev Returns `true` if `account` has been granted `role`. * Role restrictions can be swtiched on and off: * - If address(0) has ROLE, then the ROLE restrictions * don't apply. * - If address(0) does not have ROLE, then the ROLE * restrictions will apply. * * @param role keccak256 hash of the role. e.g. keccak256("TRANSFER_ROLE") * @param account Address of the account for which the role is being checked. */ function hasRoleWithSwitch(bytes32 role, address account) public view returns (bool) { if (!_hasRole[role][address(0)]) { return _hasRole[role][account]; } return true; } /** * @notice Returns the admin role that controls the specified role. * @dev See {grantRole} and {revokeRole}. * To change a role's admin, use {_setRoleAdmin}. * * @param role keccak256 hash of the role. e.g. keccak256("TRANSFER_ROLE") */ function getRoleAdmin(bytes32 role) external view override returns (bytes32) { return _getRoleAdmin[role]; } /** * @notice Grants a role to an account, if not previously granted. * @dev Caller must have admin role for the `role`. * Emits {RoleGranted Event}. * * @param role keccak256 hash of the role. e.g. keccak256("TRANSFER_ROLE") * @param account Address of the account to which the role is being granted. */ function grantRole(bytes32 role, address account) public virtual override { _checkRole(_getRoleAdmin[role], msg.sender); if (_hasRole[role][account]) { revert PermissionsAlreadyGranted(account, role); } _setupRole(role, account); } /** * @notice Revokes role from an account. * @dev Caller must have admin role for the `role`. * Emits {RoleRevoked Event}. * * @param role keccak256 hash of the role. e.g. keccak256("TRANSFER_ROLE") * @param account Address of the account from which the role is being revoked. */ function revokeRole(bytes32 role, address account) public virtual override { _checkRole(_getRoleAdmin[role], msg.sender); _revokeRole(role, account); } /** * @notice Revokes role from the account. * @dev Caller must have the `role`, with caller being the same as `account`. * Emits {RoleRevoked Event}. * * @param role keccak256 hash of the role. e.g. keccak256("TRANSFER_ROLE") * @param account Address of the account from which the role is being revoked. */ function renounceRole(bytes32 role, address account) public virtual override { if (msg.sender != account) { revert PermissionsInvalidPermission(msg.sender, account); } _revokeRole(role, account); } /// @dev Sets `adminRole` as `role`'s admin role. function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { bytes32 previousAdminRole = _getRoleAdmin[role]; _getRoleAdmin[role] = adminRole; emit RoleAdminChanged(role, previousAdminRole, adminRole); } /// @dev Sets up `role` for `account` function _setupRole(bytes32 role, address account) internal virtual { _hasRole[role][account] = true; emit RoleGranted(role, account, msg.sender); } /// @dev Revokes `role` from `account` function _revokeRole(bytes32 role, address account) internal virtual { _checkRole(role, account); delete _hasRole[role][account]; emit RoleRevoked(role, account, msg.sender); } /// @dev Checks `role` for `account`. Reverts with a message including the required role. function _checkRole(bytes32 role, address account) internal view virtual { if (!_hasRole[role][account]) { revert PermissionsUnauthorizedAccount(account, role); } } /// @dev Checks `role` for `account`. Reverts with a message including the required role. function _checkRoleWithSwitch(bytes32 role, address account) internal view virtual { if (!hasRoleWithSwitch(role, account)) { revert PermissionsUnauthorizedAccount(account, role); } } }
contracts/extension/PermissionsEnumerable.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; /// @author thirdweb import "./interface/IPermissionsEnumerable.sol"; import "./Permissions.sol"; /** * @title PermissionsEnumerable * @dev This contracts provides extending-contracts with role-based access control mechanisms. * Also provides interfaces to view all members with a given role, and total count of members. */ contract PermissionsEnumerable is IPermissionsEnumerable, Permissions { /** * @notice A data structure to store data of members for a given role. * * @param index Current index in the list of accounts that have a role. * @param members map from index => address of account that has a role * @param indexOf map from address => index which the account has. */ struct RoleMembers { uint256 index; mapping(uint256 => address) members; mapping(address => uint256) indexOf; } /// @dev map from keccak256 hash of a role to its members' data. See {RoleMembers}. mapping(bytes32 => RoleMembers) private roleMembers; /** * @notice Returns the role-member from a list of members for a role, * at a given index. * @dev Returns `member` who has `role`, at `index` of role-members list. * See struct {RoleMembers}, and mapping {roleMembers} * * @param role keccak256 hash of the role. e.g. keccak256("TRANSFER_ROLE") * @param index Index in list of current members for the role. * * @return member Address of account that has `role` */ function getRoleMember(bytes32 role, uint256 index) external view override returns (address member) { uint256 currentIndex = roleMembers[role].index; uint256 check; for (uint256 i = 0; i < currentIndex; i += 1) { if (roleMembers[role].members[i] != address(0)) { if (check == index) { member = roleMembers[role].members[i]; return member; } check += 1; } else if (hasRole(role, address(0)) && i == roleMembers[role].indexOf[address(0)]) { check += 1; } } } /** * @notice Returns total number of accounts that have a role. * @dev Returns `count` of accounts that have `role`. * See struct {RoleMembers}, and mapping {roleMembers} * * @param role keccak256 hash of the role. e.g. keccak256("TRANSFER_ROLE") * * @return count Total number of accounts that have `role` */ function getRoleMemberCount(bytes32 role) external view override returns (uint256 count) { uint256 currentIndex = roleMembers[role].index; for (uint256 i = 0; i < currentIndex; i += 1) { if (roleMembers[role].members[i] != address(0)) { count += 1; } } if (hasRole(role, address(0))) { count += 1; } } /// @dev Revokes `role` from `account`, and removes `account` from {roleMembers} /// See {_removeMember} function _revokeRole(bytes32 role, address account) internal override { super._revokeRole(role, account); _removeMember(role, account); } /// @dev Grants `role` to `account`, and adds `account` to {roleMembers} /// See {_addMember} function _setupRole(bytes32 role, address account) internal override { super._setupRole(role, account); _addMember(role, account); } /// @dev adds `account` to {roleMembers}, for `role` function _addMember(bytes32 role, address account) internal { uint256 idx = roleMembers[role].index; roleMembers[role].index += 1; roleMembers[role].members[idx] = account; roleMembers[role].indexOf[account] = idx; } /// @dev removes `account` from {roleMembers}, for `role` function _removeMember(bytes32 role, address account) internal { uint256 idx = roleMembers[role].indexOf[account]; delete roleMembers[role].members[idx]; delete roleMembers[role].indexOf[account]; } }
contracts/extension/Staking721Upgradeable.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.11; /// @author thirdweb import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol"; import "../external-deps/openzeppelin/utils/math/SafeMath.sol"; import "../eip/interface/IERC721.sol"; import "./interface/IStaking721.sol"; abstract contract Staking721Upgradeable is ReentrancyGuardUpgradeable, IStaking721 { /*/////////////////////////////////////////////////////////////// State variables / Mappings //////////////////////////////////////////////////////////////*/ ///@dev Address of ERC721 NFT contract -- staked tokens belong to this contract. address public stakingToken; /// @dev Flag to check direct transfers of staking tokens. uint8 internal isStaking = 1; ///@dev Next staking condition Id. Tracks number of conditon updates so far. uint64 private nextConditionId; ///@dev List of token-ids ever staked. uint256[] public indexedTokens; /// @dev List of accounts that have staked their NFTs. address[] public stakersArray; ///@dev Mapping from token-id to whether it is indexed or not. mapping(uint256 => bool) public isIndexed; ///@dev Mapping from staker address to Staker struct. See {struct IStaking721.Staker}. mapping(address => Staker) public stakers; /// @dev Mapping from staked token-id to staker address. mapping(uint256 => address) public stakerAddress; ///@dev Mapping from condition Id to staking condition. See {struct IStaking721.StakingCondition} mapping(uint256 => StakingCondition) private stakingConditions; function __Staking721_init(address _stakingToken) internal onlyInitializing { __ReentrancyGuard_init(); require(address(_stakingToken) != address(0), "collection address 0"); stakingToken = _stakingToken; } /*/////////////////////////////////////////////////////////////// External/Public Functions //////////////////////////////////////////////////////////////*/ /** * @notice Stake ERC721 Tokens. * * @dev See {_stake}. Override that to implement custom logic. * * @param _tokenIds List of tokens to stake. */ function stake(uint256[] calldata _tokenIds) external nonReentrant { _stake(_tokenIds); } /** * @notice Withdraw staked tokens. * * @dev See {_withdraw}. Override that to implement custom logic. * * @param _tokenIds List of tokens to withdraw. */ function withdraw(uint256[] calldata _tokenIds) external nonReentrant { _withdraw(_tokenIds); } /** * @notice Claim accumulated rewards. * * @dev See {_claimRewards}. Override that to implement custom logic. * See {_calculateRewards} for reward-calculation logic. */ function claimRewards() external nonReentrant { _claimRewards(); } /** * @notice Set time unit. Set as a number of seconds. * Could be specified as -- x * 1 hours, x * 1 days, etc. * * @dev Only admin/authorized-account can call it. * * * @param _timeUnit New time unit. */ function setTimeUnit(uint256 _timeUnit) external virtual { if (!_canSetStakeConditions()) { revert("Not authorized"); } StakingCondition memory condition = stakingConditions[nextConditionId - 1]; require(_timeUnit != condition.timeUnit, "Time-unit unchanged."); _setStakingCondition(_timeUnit, condition.rewardsPerUnitTime); emit UpdatedTimeUnit(condition.timeUnit, _timeUnit); } /** * @notice Set rewards per unit of time. * Interpreted as x rewards per second/per day/etc based on time-unit. * * @dev Only admin/authorized-account can call it. * * * @param _rewardsPerUnitTime New rewards per unit time. */ function setRewardsPerUnitTime(uint256 _rewardsPerUnitTime) external virtual { if (!_canSetStakeConditions()) { revert("Not authorized"); } StakingCondition memory condition = stakingConditions[nextConditionId - 1]; require(_rewardsPerUnitTime != condition.rewardsPerUnitTime, "Reward unchanged."); _setStakingCondition(condition.timeUnit, _rewardsPerUnitTime); emit UpdatedRewardsPerUnitTime(condition.rewardsPerUnitTime, _rewardsPerUnitTime); } /** * @notice View amount staked and total rewards for a user. * * @param _staker Address for which to calculated rewards. * @return _tokensStaked List of token-ids staked by staker. * @return _rewards Available reward amount. */ function getStakeInfo( address _staker ) external view virtual returns (uint256[] memory _tokensStaked, uint256 _rewards) { uint256[] memory _indexedTokens = indexedTokens; bool[] memory _isStakerToken = new bool[](_indexedTokens.length); uint256 indexedTokenCount = _indexedTokens.length; uint256 stakerTokenCount = 0; for (uint256 i = 0; i < indexedTokenCount; i++) { _isStakerToken[i] = stakerAddress[_indexedTokens[i]] == _staker; if (_isStakerToken[i]) stakerTokenCount += 1; } _tokensStaked = new uint256[](stakerTokenCount); uint256 count = 0; for (uint256 i = 0; i < indexedTokenCount; i++) { if (_isStakerToken[i]) { _tokensStaked[count] = _indexedTokens[i]; count += 1; } } _rewards = _availableRewards(_staker); } function getTimeUnit() public view returns (uint256 _timeUnit) { _timeUnit = stakingConditions[nextConditionId - 1].timeUnit; } function getRewardsPerUnitTime() public view returns (uint256 _rewardsPerUnitTime) { _rewardsPerUnitTime = stakingConditions[nextConditionId - 1].rewardsPerUnitTime; } /*/////////////////////////////////////////////////////////////// Internal Functions //////////////////////////////////////////////////////////////*/ /// @dev Staking logic. Override to add custom logic. function _stake(uint256[] calldata _tokenIds) internal virtual { uint64 len = uint64(_tokenIds.length); require(len != 0, "Staking 0 tokens"); address _stakingToken = stakingToken; if (stakers[_stakeMsgSender()].amountStaked > 0) { _updateUnclaimedRewardsForStaker(_stakeMsgSender()); } else { stakersArray.push(_stakeMsgSender()); stakers[_stakeMsgSender()].timeOfLastUpdate = uint128(block.timestamp); stakers[_stakeMsgSender()].conditionIdOflastUpdate = nextConditionId - 1; } for (uint256 i = 0; i < len; ++i) { isStaking = 2; IERC721(_stakingToken).safeTransferFrom(_stakeMsgSender(), address(this), _tokenIds[i]); isStaking = 1; stakerAddress[_tokenIds[i]] = _stakeMsgSender(); if (!isIndexed[_tokenIds[i]]) { isIndexed[_tokenIds[i]] = true; indexedTokens.push(_tokenIds[i]); } } stakers[_stakeMsgSender()].amountStaked += len; emit TokensStaked(_stakeMsgSender(), _tokenIds); } /// @dev Withdraw logic. Override to add custom logic. function _withdraw(uint256[] calldata _tokenIds) internal virtual { uint256 _amountStaked = stakers[_stakeMsgSender()].amountStaked; uint64 len = uint64(_tokenIds.length); require(len != 0, "Withdrawing 0 tokens"); require(_amountStaked >= len, "Withdrawing more than staked"); address _stakingToken = stakingToken; _updateUnclaimedRewardsForStaker(_stakeMsgSender()); if (_amountStaked == len) { address[] memory _stakersArray = stakersArray; for (uint256 i = 0; i < _stakersArray.length; ++i) { if (_stakersArray[i] == _stakeMsgSender()) { stakersArray[i] = _stakersArray[_stakersArray.length - 1]; stakersArray.pop(); break; } } } stakers[_stakeMsgSender()].amountStaked -= len; for (uint256 i = 0; i < len; ++i) { require(stakerAddress[_tokenIds[i]] == _stakeMsgSender(), "Not staker"); stakerAddress[_tokenIds[i]] = address(0); IERC721(_stakingToken).safeTransferFrom(address(this), _stakeMsgSender(), _tokenIds[i]); } emit TokensWithdrawn(_stakeMsgSender(), _tokenIds); } /// @dev Logic for claiming rewards. Override to add custom logic. function _claimRewards() internal virtual { uint256 rewards = stakers[_stakeMsgSender()].unclaimedRewards + _calculateRewards(_stakeMsgSender()); require(rewards != 0, "No rewards"); stakers[_stakeMsgSender()].timeOfLastUpdate = uint128(block.timestamp); stakers[_stakeMsgSender()].unclaimedRewards = 0; stakers[_stakeMsgSender()].conditionIdOflastUpdate = nextConditionId - 1; _mintRewards(_stakeMsgSender(), rewards); emit RewardsClaimed(_stakeMsgSender(), rewards); } /// @dev View available rewards for a user. function _availableRewards(address _user) internal view virtual returns (uint256 _rewards) { if (stakers[_user].amountStaked == 0) { _rewards = stakers[_user].unclaimedRewards; } else { _rewards = stakers[_user].unclaimedRewards + _calculateRewards(_user); } } /// @dev Update unclaimed rewards for a users. Called for every state change for a user. function _updateUnclaimedRewardsForStaker(address _staker) internal virtual { uint256 rewards = _calculateRewards(_staker); stakers[_staker].unclaimedRewards += rewards; stakers[_staker].timeOfLastUpdate = uint128(block.timestamp); stakers[_staker].conditionIdOflastUpdate = nextConditionId - 1; } /// @dev Set staking conditions. function _setStakingCondition(uint256 _timeUnit, uint256 _rewardsPerUnitTime) internal virtual { require(_timeUnit != 0, "time-unit can't be 0"); uint256 conditionId = nextConditionId; nextConditionId += 1; stakingConditions[conditionId] = StakingCondition({ timeUnit: _timeUnit, rewardsPerUnitTime: _rewardsPerUnitTime, startTimestamp: block.timestamp, endTimestamp: 0 }); if (conditionId > 0) { stakingConditions[conditionId - 1].endTimestamp = block.timestamp; } } /// @dev Calculate rewards for a staker. function _calculateRewards(address _staker) internal view virtual returns (uint256 _rewards) { Staker memory staker = stakers[_staker]; uint256 _stakerConditionId = staker.conditionIdOflastUpdate; uint256 _nextConditionId = nextConditionId; for (uint256 i = _stakerConditionId; i < _nextConditionId; i += 1) { StakingCondition memory condition = stakingConditions[i]; uint256 startTime = i != _stakerConditionId ? condition.startTimestamp : staker.timeOfLastUpdate; uint256 endTime = condition.endTimestamp != 0 ? condition.endTimestamp : block.timestamp; (bool noOverflowProduct, uint256 rewardsProduct) = SafeMath.tryMul( (endTime - startTime) * staker.amountStaked, condition.rewardsPerUnitTime ); (bool noOverflowSum, uint256 rewardsSum) = SafeMath.tryAdd(_rewards, rewardsProduct / condition.timeUnit); _rewards = noOverflowProduct && noOverflowSum ? rewardsSum : _rewards; } } /*//////////////////////////////////////////////////////////////////// Optional hooks that can be implemented in the derived contract ///////////////////////////////////////////////////////////////////*/ /// @dev Exposes the ability to override the msg sender -- support ERC2771. function _stakeMsgSender() internal virtual returns (address) { return msg.sender; } /*/////////////////////////////////////////////////////////////// Virtual functions to be implemented in derived contract //////////////////////////////////////////////////////////////*/ /** * @notice View total rewards available in the staking contract. * */ function getRewardTokenBalance() external view virtual returns (uint256 _rewardsAvailableInContract); /** * @dev Mint/Transfer ERC20 rewards to the staker. Must override. * * @param _staker Address for which to calculated rewards. * @param _rewards Amount of tokens to be given out as reward. * * For example, override as below to mint ERC20 rewards: * * ``` * function _mintRewards(address _staker, uint256 _rewards) internal override { * * TokenERC20(rewardTokenAddress).mintTo(_staker, _rewards); * * } * ``` */ function _mintRewards(address _staker, uint256 _rewards) internal virtual; /** * @dev Returns whether staking restrictions can be set in given execution context. * Must override. * * * For example, override as below to restrict access to admin: * * ``` * function _canSetStakeConditions() internal override { * * return msg.sender == adminAddress; * * } * ``` */ function _canSetStakeConditions() internal view virtual returns (bool); }
contracts/extension/interface/IContractMetadata.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; /// @author thirdweb /** * Thirdweb's `ContractMetadata` is a contract extension for any base contracts. It lets you set a metadata URI * for you contract. * * Additionally, `ContractMetadata` is necessary for NFT contracts that want royalties to get distributed on OpenSea. */ interface IContractMetadata { /// @dev Returns the metadata URI of the contract. function contractURI() external view returns (string memory); /** * @dev Sets contract URI for the storefront-level metadata of the contract. * Only module admin can call this function. */ function setContractURI(string calldata _uri) external; /// @dev Emitted when the contract URI is updated. event ContractURIUpdated(string prevURI, string newURI); }
contracts/extension/interface/IMulticall.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @author thirdweb /** * @dev Provides a function to batch together multiple calls in a single external call. * * _Available since v4.1._ */ interface IMulticall { /** * @dev Receives and executes a batch of function calls on this contract. */ function multicall(bytes[] calldata data) external returns (bytes[] memory results); }
contracts/extension/interface/IPermissions.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; /// @author thirdweb /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IPermissions { /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {AccessControl-_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) external view returns (bool); /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {AccessControl-_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) external view returns (bytes32); /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) external; /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) external; /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) external; }
contracts/extension/interface/IPermissionsEnumerable.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; /// @author thirdweb import "./IPermissions.sol"; /** * @dev External interface of AccessControlEnumerable declared to support ERC165 detection. */ interface IPermissionsEnumerable is IPermissions { /** * @dev Returns one of the accounts that have `role`. `index` must be a * value between 0 and {getRoleMemberCount}, non-inclusive. * * Role bearers are not sorted in any particular way, and their ordering may * change at any point. * * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure * you perform all queries on the same block. See the following * [forum post](https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296) * for more information. */ function getRoleMember(bytes32 role, uint256 index) external view returns (address); /** * @dev Returns the number of accounts that have `role`. Can be used * together with {getRoleMember} to enumerate all bearers of a role. */ function getRoleMemberCount(bytes32 role) external view returns (uint256); }
contracts/extension/interface/IStaking721.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.11; /// @author thirdweb interface IStaking721 { /// @dev Emitted when a set of token-ids are staked. event TokensStaked(address indexed staker, uint256[] indexed tokenIds); /// @dev Emitted when a set of staked token-ids are withdrawn. event TokensWithdrawn(address indexed staker, uint256[] indexed tokenIds); /// @dev Emitted when a staker claims staking rewards. event RewardsClaimed(address indexed staker, uint256 rewardAmount); /// @dev Emitted when contract admin updates timeUnit. event UpdatedTimeUnit(uint256 oldTimeUnit, uint256 newTimeUnit); /// @dev Emitted when contract admin updates rewardsPerUnitTime. event UpdatedRewardsPerUnitTime(uint256 oldRewardsPerUnitTime, uint256 newRewardsPerUnitTime); /** * @notice Staker Info. * * @param amountStaked Total number of tokens staked by the staker. * * @param timeOfLastUpdate Last reward-update timestamp. * * @param unclaimedRewards Rewards accumulated but not claimed by user yet. * * @param conditionIdOflastUpdate Condition-Id when rewards were last updated for user. */ struct Staker { uint64 amountStaked; uint64 conditionIdOflastUpdate; uint128 timeOfLastUpdate; uint256 unclaimedRewards; } /** * @notice Staking Condition. * * @param timeUnit Unit of time specified in number of seconds. Can be set as 1 seconds, 1 days, 1 hours, etc. * * @param rewardsPerUnitTime Rewards accumulated per unit of time. * * @param startTimestamp Condition start timestamp. * * @param endTimestamp Condition end timestamp. */ struct StakingCondition { uint256 timeUnit; uint256 rewardsPerUnitTime; uint256 startTimestamp; uint256 endTimestamp; } /** * @notice Stake ERC721 Tokens. * * @param tokenIds List of tokens to stake. */ function stake(uint256[] calldata tokenIds) external; /** * @notice Withdraw staked tokens. * * @param tokenIds List of tokens to withdraw. */ function withdraw(uint256[] calldata tokenIds) external; /** * @notice Claim accumulated rewards. */ function claimRewards() external; /** * @notice View amount staked and total rewards for a user. * * @param staker Address for which to calculated rewards. */ function getStakeInfo(address staker) external view returns (uint256[] memory _tokensStaked, uint256 _rewards); }
contracts/external-deps/openzeppelin/metatx/ERC2771ContextUpgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (metatx/ERC2771Context.sol) pragma solidity ^0.8.11; import "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; /** * @dev Context variant with ERC2771 support. */ abstract contract ERC2771ContextUpgradeable is Initializable, ContextUpgradeable { mapping(address => bool) private _trustedForwarder; function __ERC2771Context_init(address[] memory trustedForwarder) internal onlyInitializing { __Context_init_unchained(); __ERC2771Context_init_unchained(trustedForwarder); } function __ERC2771Context_init_unchained(address[] memory trustedForwarder) internal onlyInitializing { for (uint256 i = 0; i < trustedForwarder.length; i++) { _trustedForwarder[trustedForwarder[i]] = true; } } function isTrustedForwarder(address forwarder) public view virtual returns (bool) { return _trustedForwarder[forwarder]; } function _msgSender() internal view virtual override returns (address sender) { if (isTrustedForwarder(msg.sender)) { // The assembly code is more direct than the Solidity version using `abi.decode`. assembly { sender := shr(96, calldataload(sub(calldatasize(), 20))) } } else { return super._msgSender(); } } function _msgData() internal view virtual override returns (bytes calldata) { if (isTrustedForwarder(msg.sender)) { return msg.data[:msg.data.length - 20]; } else { return super._msgData(); } } uint256[49] private __gap; }
contracts/external-deps/openzeppelin/token/ERC20/utils/SafeERC20.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "../../../../../eip/interface/IERC20.sol"; import { Address } from "../../../../../lib/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } }
contracts/external-deps/openzeppelin/utils/math/SafeMath.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (utils/math/SafeMath.sol) pragma solidity ^0.8.0; // CAUTION // This version of SafeMath should only be used with Solidity 0.8 or later, // because it relies on the compiler's built in overflow checks. /** * @dev Wrappers over Solidity's arithmetic operations. * * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler * now has built in overflow checking. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the subtraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { return a + b; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { return a * b; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b <= a, errorMessage); return a - b; } } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a / b; } } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a % b; } } }
contracts/infra/interface/IWETH.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; interface IWETH { function deposit() external payable; function withdraw(uint256 amount) external; function transfer(address to, uint256 value) external returns (bool); }
contracts/lib/Address.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.1; /// @author thirdweb, OpenZeppelin Contracts (v4.9.0) /** * @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); } } }
contracts/lib/CurrencyTransferLib.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; /// @author thirdweb // Helper interfaces import { IWETH } from "../infra/interface/IWETH.sol"; import { SafeERC20, IERC20 } from "../external-deps/openzeppelin/token/ERC20/utils/SafeERC20.sol"; library CurrencyTransferLib { using SafeERC20 for IERC20; error CurrencyTransferLibMismatchedValue(uint256 expected, uint256 actual); error CurrencyTransferLibFailedNativeTransfer(address recipient, uint256 value); /// @dev The address interpreted as native token of the chain. address public constant NATIVE_TOKEN = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE; /// @dev Transfers a given amount of currency. function transferCurrency(address _currency, address _from, address _to, uint256 _amount) internal { if (_amount == 0) { return; } if (_currency == NATIVE_TOKEN) { safeTransferNativeToken(_to, _amount); } else { safeTransferERC20(_currency, _from, _to, _amount); } } /// @dev Transfers a given amount of currency. (With native token wrapping) function transferCurrencyWithWrapper( address _currency, address _from, address _to, uint256 _amount, address _nativeTokenWrapper ) internal { if (_amount == 0) { return; } if (_currency == NATIVE_TOKEN) { if (_from == address(this)) { // withdraw from weth then transfer withdrawn native token to recipient IWETH(_nativeTokenWrapper).withdraw(_amount); safeTransferNativeTokenWithWrapper(_to, _amount, _nativeTokenWrapper); } else if (_to == address(this)) { // store native currency in weth if (_amount != msg.value) { revert CurrencyTransferLibMismatchedValue(msg.value, _amount); } IWETH(_nativeTokenWrapper).deposit{ value: _amount }(); } else { safeTransferNativeTokenWithWrapper(_to, _amount, _nativeTokenWrapper); } } else { safeTransferERC20(_currency, _from, _to, _amount); } } /// @dev Transfer `amount` of ERC20 token from `from` to `to`. function safeTransferERC20(address _currency, address _from, address _to, uint256 _amount) internal { if (_from == _to) { return; } if (_from == address(this)) { IERC20(_currency).safeTransfer(_to, _amount); } else { IERC20(_currency).safeTransferFrom(_from, _to, _amount); } } /// @dev Transfers `amount` of native token to `to`. function safeTransferNativeToken(address to, uint256 value) internal { // solhint-disable avoid-low-level-calls // slither-disable-next-line low-level-calls (bool success, ) = to.call{ value: value }(""); if (!success) { revert CurrencyTransferLibFailedNativeTransfer(to, value); } } /// @dev Transfers `amount` of native token to `to`. (With native token wrapping) function safeTransferNativeTokenWithWrapper(address to, uint256 value, address _nativeTokenWrapper) internal { // solhint-disable avoid-low-level-calls // slither-disable-next-line low-level-calls (bool success, ) = to.call{ value: value }(""); if (!success) { IWETH(_nativeTokenWrapper).deposit{ value: value }(); IERC20(_nativeTokenWrapper).safeTransfer(to, value); } } }
contracts/lib/Strings.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; /// @author thirdweb /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } /// @dev Returns the hexadecimal representation of `value`. /// The output is prefixed with "0x", encoded using 2 hexadecimal digits per byte, /// and the alphabets are capitalized conditionally according to /// https://eips.ethereum.org/EIPS/eip-55 function toHexStringChecksummed(address value) internal pure returns (string memory str) { str = toHexString(value); /// @solidity memory-safe-assembly assembly { let mask := shl(6, div(not(0), 255)) // `0b010000000100000000 ...` let o := add(str, 0x22) let hashed := and(keccak256(o, 40), mul(34, mask)) // `0b10001000 ... ` let t := shl(240, 136) // `0b10001000 << 240` for { let i := 0 } 1 { } { mstore(add(i, i), mul(t, byte(i, hashed))) i := add(i, 1) if eq(i, 20) { break } } mstore(o, xor(mload(o), shr(1, and(mload(0x00), and(mload(o), mask))))) o := add(o, 0x20) mstore(o, xor(mload(o), shr(1, and(mload(0x20), and(mload(o), mask))))) } } /// @dev Returns the hexadecimal representation of `value`. /// The output is prefixed with "0x" and encoded using 2 hexadecimal digits per byte. function toHexString(address value) internal pure returns (string memory str) { str = toHexStringNoPrefix(value); /// @solidity memory-safe-assembly assembly { let strLength := add(mload(str), 2) // Compute the length. mstore(str, 0x3078) // Write the "0x" prefix. str := sub(str, 2) // Move the pointer. mstore(str, strLength) // Write the length. } } /// @dev Returns the hexadecimal representation of `value`. /// The output is encoded using 2 hexadecimal digits per byte. function toHexStringNoPrefix(address value) internal pure returns (string memory str) { /// @solidity memory-safe-assembly assembly { str := mload(0x40) // Allocate the memory. // We need 0x20 bytes for the trailing zeros padding, 0x20 bytes for the length, // 0x02 bytes for the prefix, and 0x28 bytes for the digits. // The next multiple of 0x20 above (0x20 + 0x20 + 0x02 + 0x28) is 0x80. mstore(0x40, add(str, 0x80)) // Store "0123456789abcdef" in scratch space. mstore(0x0f, 0x30313233343536373839616263646566) str := add(str, 2) mstore(str, 40) let o := add(str, 0x20) mstore(add(o, 40), 0) value := shl(96, value) // We write the string from rightmost digit to leftmost digit. // The following is essentially a do-while loop that also handles the zero case. for { let i := 0 } 1 { } { let p := add(o, add(i, i)) let temp := byte(i, value) mstore8(add(p, 1), mload(and(temp, 15))) mstore8(p, mload(shr(4, temp))) i := add(i, 1) if eq(i, 20) { break } } } } /// @dev Returns the hex encoded string from the raw bytes. /// The output is encoded using 2 hexadecimal digits per byte. function toHexString(bytes memory raw) internal pure returns (string memory str) { str = toHexStringNoPrefix(raw); /// @solidity memory-safe-assembly assembly { let strLength := add(mload(str), 2) // Compute the length. mstore(str, 0x3078) // Write the "0x" prefix. str := sub(str, 2) // Move the pointer. mstore(str, strLength) // Write the length. } } /// @dev Returns the hex encoded string from the raw bytes. /// The output is encoded using 2 hexadecimal digits per byte. function toHexStringNoPrefix(bytes memory raw) internal pure returns (string memory str) { /// @solidity memory-safe-assembly assembly { let length := mload(raw) str := add(mload(0x40), 2) // Skip 2 bytes for the optional prefix. mstore(str, add(length, length)) // Store the length of the output. // Store "0123456789abcdef" in scratch space. mstore(0x0f, 0x30313233343536373839616263646566) let o := add(str, 0x20) let end := add(raw, length) for { } iszero(eq(raw, end)) { } { raw := add(raw, 1) mstore8(add(o, 1), mload(and(mload(raw), 15))) mstore8(o, mload(and(shr(4, mload(raw)), 15))) o := add(o, 2) } mstore(o, 0) // Zeroize the slot after the string. mstore(0x40, add(o, 0x20)) // Allocate the memory. } } }
contracts/prebuilts/interface/staking/INFTStake.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.11; /** * Thirdweb's NFTStake smart contract allows users to stake their ERC-721 NFTs * and earn rewards in form of an ERC-20 token. * * note: * - Reward token and staking token can't be changed after deployment. * * - ERC721 tokens from only the specified contract can be staked. * * - All token/NFT transfers require approval on their respective contracts. * * - Admin must deposit reward tokens using the `depositRewardTokens` function only. * Any direct transfers may cause unintended consequences, such as locking of tokens. * * - Users must stake NFTs using the `stake` function only. * Any direct transfers may cause unintended consequences, such as locking of NFTs. */ interface INFTStake { /// @dev Emitted when contract admin withdraws reward tokens. event RewardTokensWithdrawnByAdmin(uint256 _amount); /// @dev Emitted when contract admin deposits reward tokens. event RewardTokensDepositedByAdmin(uint256 _amount); /** * @notice Lets a contract admin (account with `DEFAULT_ADMIN_ROLE`) deposit reward-tokens. * * note: Tokens should be approved on the reward-token contract before depositing. * * @param _amount Amount of tokens to deposit. */ function depositRewardTokens(uint256 _amount) external payable; /** * @notice Lets a contract admin (account with `DEFAULT_ADMIN_ROLE`) withdraw reward-tokens. * Useful for removing excess balance, thus preventing locking of tokens. * * @param _amount Amount of tokens to deposit. */ function withdrawRewardTokens(uint256 _amount) external; }
lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol) pragma solidity ^0.8.2; import "../../utils/AddressUpgradeable.sol"; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in * case an upgrade adds a module that needs to be initialized. * * For example: * * [.hljs-theme-light.nopadding] * ```solidity * contract MyToken is ERC20Upgradeable { * function initialize() initializer public { * __ERC20_init("MyToken", "MTK"); * } * } * * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable { * function initializeV2() reinitializer(2) public { * __ERC20Permit_init("MyToken"); * } * } * ``` * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() { * _disableInitializers(); * } * ``` * ==== */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. * @custom:oz-retyped-from bool */ uint8 private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Triggered when the contract has been initialized or reinitialized. */ event Initialized(uint8 version); /** * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope, * `onlyInitializing` functions can be used to initialize parent contracts. * * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a * constructor. * * Emits an {Initialized} event. */ modifier initializer() { bool isTopLevelCall = !_initializing; require( (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1), "Initializable: contract is already initialized" ); _initialized = 1; if (isTopLevelCall) { _initializing = true; } _; if (isTopLevelCall) { _initializing = false; emit Initialized(1); } } /** * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be * used to initialize parent contracts. * * A reinitializer may be used after the original initialization step. This is essential to configure modules that * are added through upgrades and that require initialization. * * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer` * cannot be nested. If one is invoked in the context of another, execution will revert. * * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in * a contract, executing them in the right order is up to the developer or operator. * * WARNING: setting the version to 255 will prevent any future reinitialization. * * Emits an {Initialized} event. */ modifier reinitializer(uint8 version) { require(!_initializing && _initialized < version, "Initializable: contract is already initialized"); _initialized = version; _initializing = true; _; _initializing = false; emit Initialized(version); } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} and {reinitializer} modifiers, directly or indirectly. */ modifier onlyInitializing() { require(_initializing, "Initializable: contract is not initializing"); _; } /** * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call. * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized * to any version. It is recommended to use this to lock implementation contracts that are designed to be called * through proxies. * * Emits an {Initialized} event the first time it is successfully executed. */ function _disableInitializers() internal virtual { require(!_initializing, "Initializable: contract is initializing"); if (_initialized != type(uint8).max) { _initialized = type(uint8).max; emit Initialized(type(uint8).max); } } /** * @dev Returns the highest version that has been initialized. See {reinitializer}. */ function _getInitializedVersion() internal view returns (uint8) { return _initialized; } /** * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}. */ function _isInitializing() internal view returns (bool) { return _initializing; } }
lib/openzeppelin-contracts-upgradeable/contracts/security/ReentrancyGuardUpgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol) pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @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 ReentrancyGuardUpgradeable is Initializable { // 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; function __ReentrancyGuard_init() internal onlyInitializing { __ReentrancyGuard_init_unchained(); } function __ReentrancyGuard_init_unchained() internal onlyInitializing { _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; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; }
lib/openzeppelin-contracts-upgradeable/contracts/token/ERC721/IERC721ReceiverUpgradeable.sol
// 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 IERC721ReceiverUpgradeable { /** * @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); }
lib/openzeppelin-contracts-upgradeable/contracts/utils/AddressUpgradeable.sol
// 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 AddressUpgradeable { /** * @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); } } }
lib/openzeppelin-contracts-upgradeable/contracts/utils/ContextUpgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract ContextUpgradeable is Initializable { function __Context_init() internal onlyInitializing { } function __Context_init_unchained() internal onlyInitializing { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
lib/openzeppelin-contracts-upgradeable/contracts/utils/introspection/ERC165Upgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165Upgradeable.sol"; import "../../proxy/utils/Initializable.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 ERC165Upgradeable is Initializable, IERC165Upgradeable { function __ERC165_init() internal onlyInitializing { } function __ERC165_init_unchained() internal onlyInitializing { } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165Upgradeable).interfaceId; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
lib/openzeppelin-contracts-upgradeable/contracts/utils/introspection/IERC165Upgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165Upgradeable { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
Compiler Settings
{"remappings":["@chainlink/=lib/chainlink/","@ds-test/=lib/ds-test/src/","@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/","@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/","@rari-capital/solmate/=lib/seaport/lib/solmate/","@seaport/=lib/seaport/contracts/","@std/=lib/forge-std/src/","@thirdweb-dev/dynamic-contracts/=lib/dynamic-contracts/","ERC721A-Upgradeable/=lib/ERC721A-Upgradeable/contracts/","ERC721A/=lib/ERC721A/contracts/","chainlink/=lib/chainlink/contracts/","contracts/=contracts/","ds-test/=lib/ds-test/src/","dynamic-contracts/=lib/dynamic-contracts/src/","erc4626-tests/=lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/","erc721a-upgradeable/=lib/ERC721A-Upgradeable/","erc721a/=lib/ERC721A/","forge-std/=lib/forge-std/src/","lib/sstore2/=lib/dynamic-contracts/lib/sstore2/","murky/=lib/murky/src/","openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/","openzeppelin-contracts/=lib/openzeppelin-contracts/","openzeppelin/=lib/openzeppelin-contracts-upgradeable/contracts/","seaport-core/=lib/seaport/lib/seaport-core/","seaport-sol/=lib/seaport-sol/src/","seaport-types/=lib/seaport/lib/seaport-types/","seaport/=lib/seaport/","solady/=lib/solady/","solarray/=lib/seaport/lib/solarray/src/","solmate/=lib/seaport/lib/solmate/src/","sstore2/=lib/dynamic-contracts/lib/sstore2/contracts/"],"outputSelection":{"*":{"*":["abi","evm.bytecode","evm.deployedBytecode","evm.methodIdentifiers","metadata"],"":["ast"]}},"optimizer":{"runs":20,"enabled":true},"libraries":{},"evmVersion":"london"}
Contract ABI
[{"type":"constructor","stateMutability":"nonpayable","inputs":[{"type":"address","name":"_nativeTokenWrapper","internalType":"address"}]},{"type":"error","name":"ContractMetadataUnauthorized","inputs":[]},{"type":"error","name":"CurrencyTransferLibMismatchedValue","inputs":[{"type":"uint256","name":"expected","internalType":"uint256"},{"type":"uint256","name":"actual","internalType":"uint256"}]},{"type":"error","name":"PermissionsAlreadyGranted","inputs":[{"type":"address","name":"account","internalType":"address"},{"type":"bytes32","name":"role","internalType":"bytes32"}]},{"type":"error","name":"PermissionsInvalidPermission","inputs":[{"type":"address","name":"expected","internalType":"address"},{"type":"address","name":"actual","internalType":"address"}]},{"type":"error","name":"PermissionsUnauthorizedAccount","inputs":[{"type":"address","name":"account","internalType":"address"},{"type":"bytes32","name":"neededRole","internalType":"bytes32"}]},{"type":"event","name":"ContractURIUpdated","inputs":[{"type":"string","name":"prevURI","internalType":"string","indexed":false},{"type":"string","name":"newURI","internalType":"string","indexed":false}],"anonymous":false},{"type":"event","name":"Initialized","inputs":[{"type":"uint8","name":"version","internalType":"uint8","indexed":false}],"anonymous":false},{"type":"event","name":"RewardTokensDepositedByAdmin","inputs":[{"type":"uint256","name":"_amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"RewardTokensWithdrawnByAdmin","inputs":[{"type":"uint256","name":"_amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"RewardsClaimed","inputs":[{"type":"address","name":"staker","internalType":"address","indexed":true},{"type":"uint256","name":"rewardAmount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"RoleAdminChanged","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32","indexed":true},{"type":"bytes32","name":"previousAdminRole","internalType":"bytes32","indexed":true},{"type":"bytes32","name":"newAdminRole","internalType":"bytes32","indexed":true}],"anonymous":false},{"type":"event","name":"RoleGranted","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32","indexed":true},{"type":"address","name":"account","internalType":"address","indexed":true},{"type":"address","name":"sender","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"RoleRevoked","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32","indexed":true},{"type":"address","name":"account","internalType":"address","indexed":true},{"type":"address","name":"sender","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"TokensStaked","inputs":[{"type":"address","name":"staker","internalType":"address","indexed":true},{"type":"uint256[]","name":"tokenIds","internalType":"uint256[]","indexed":true}],"anonymous":false},{"type":"event","name":"TokensWithdrawn","inputs":[{"type":"address","name":"staker","internalType":"address","indexed":true},{"type":"uint256[]","name":"tokenIds","internalType":"uint256[]","indexed":true}],"anonymous":false},{"type":"event","name":"UpdatedRewardsPerUnitTime","inputs":[{"type":"uint256","name":"oldRewardsPerUnitTime","internalType":"uint256","indexed":false},{"type":"uint256","name":"newRewardsPerUnitTime","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"UpdatedTimeUnit","inputs":[{"type":"uint256","name":"oldTimeUnit","internalType":"uint256","indexed":false},{"type":"uint256","name":"newTimeUnit","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"DEFAULT_ADMIN_ROLE","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"claimRewards","inputs":[]},{"type":"function","stateMutability":"pure","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"contractType","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"contractURI","inputs":[]},{"type":"function","stateMutability":"pure","outputs":[{"type":"uint8","name":"","internalType":"uint8"}],"name":"contractVersion","inputs":[]},{"type":"function","stateMutability":"payable","outputs":[],"name":"depositRewardTokens","inputs":[{"type":"uint256","name":"_amount","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getRewardTokenBalance","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"_rewardsPerUnitTime","internalType":"uint256"}],"name":"getRewardsPerUnitTime","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"getRoleAdmin","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"member","internalType":"address"}],"name":"getRoleMember","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"uint256","name":"index","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"count","internalType":"uint256"}],"name":"getRoleMemberCount","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256[]","name":"_tokensStaked","internalType":"uint256[]"},{"type":"uint256","name":"_rewards","internalType":"uint256"}],"name":"getStakeInfo","inputs":[{"type":"address","name":"_staker","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"_timeUnit","internalType":"uint256"}],"name":"getTimeUnit","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"grantRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"hasRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"hasRoleWithSwitch","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"indexedTokens","inputs":[{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"initialize","inputs":[{"type":"address","name":"_defaultAdmin","internalType":"address"},{"type":"string","name":"_contractURI","internalType":"string"},{"type":"address[]","name":"_trustedForwarders","internalType":"address[]"},{"type":"address","name":"_rewardToken","internalType":"address"},{"type":"address","name":"_stakingToken","internalType":"address"},{"type":"uint256","name":"_timeUnit","internalType":"uint256"},{"type":"uint256","name":"_rewardsPerUnitTime","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isIndexed","inputs":[{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isTrustedForwarder","inputs":[{"type":"address","name":"forwarder","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bytes[]","name":"results","internalType":"bytes[]"}],"name":"multicall","inputs":[{"type":"bytes[]","name":"data","internalType":"bytes[]"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes4","name":"","internalType":"bytes4"}],"name":"onERC721Received","inputs":[{"type":"address","name":"","internalType":"address"},{"type":"address","name":"","internalType":"address"},{"type":"uint256","name":"","internalType":"uint256"},{"type":"bytes","name":"","internalType":"bytes"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"revokeRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"rewardToken","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setContractURI","inputs":[{"type":"string","name":"_uri","internalType":"string"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setRewardsPerUnitTime","inputs":[{"type":"uint256","name":"_rewardsPerUnitTime","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setTimeUnit","inputs":[{"type":"uint256","name":"_timeUnit","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"stake","inputs":[{"type":"uint256[]","name":"_tokenIds","internalType":"uint256[]"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"stakerAddress","inputs":[{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint64","name":"amountStaked","internalType":"uint64"},{"type":"uint64","name":"conditionIdOflastUpdate","internalType":"uint64"},{"type":"uint128","name":"timeOfLastUpdate","internalType":"uint128"},{"type":"uint256","name":"unclaimedRewards","internalType":"uint256"}],"name":"stakers","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"stakersArray","inputs":[{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"stakingToken","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"supportsInterface","inputs":[{"type":"bytes4","name":"interfaceId","internalType":"bytes4"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"withdraw","inputs":[{"type":"uint256[]","name":"_tokenIds","internalType":"uint256[]"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"withdrawRewardTokens","inputs":[{"type":"uint256","name":"_amount","internalType":"uint256"}]},{"type":"receive","stateMutability":"payable"}]
Contract Creation Code
0x60a0604052609b805460ff60a01b1916600160a01b1790553480156200002457600080fd5b5060405162003c0e38038062003c0e83398101604081905262000047916200016c565b600054610100900460ff1615808015620000685750600054600160ff909116105b80620000845750303b15801562000084575060005460ff166001145b620000ec5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b606482015260840160405180910390fd5b6000805460ff19166001179055801562000110576000805461ff0019166101001790555b6001600160a01b038216608052801562000164576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50506200019e565b6000602082840312156200017f57600080fd5b81516001600160a01b03811681146200019757600080fd5b9392505050565b608051613a38620001d6600039600081816101c3015281816108f0015281816109a0015281816115c70152612cfb0152613a386000f3fe6080604052600436106101b35760003560e01c8063938e3d7b116100e8578063938e3d7b1461052557806393ce534314610545578063940670451461055a578063961004d314610590578063983d95ce146105b0578063a0a8e460146105d0578063a217fddf146105ec578063a32fa5b314610601578063ac9650d814610621578063c34531531461064e578063ca15c8731461067c578063cb2ef6f71461069c578063cb43b2dd146106ba578063d547741f146106da578063d68124c7146106fa578063e8a3d4851461070f578063f7c618c114610731578063fd48ba171461075157600080fd5b806301ffc9a71461023c5780630e8b229b146102715780630fbf0a9314610294578063150b7a02146102b457806316c621e0146102ed57806323ef258014610300578063248a9ca3146103205780632f2ff15d1461034d57806336568abe1461036d578063372500ab1461038d5780635357e916146103a2578063572b6c05146103cf5780636360106f146103ef5780636a5ab6e51461040f57806372f702f31461042f5780639010d07c1461044f5780639168ae721461046f57806391d148541461050557600080fd5b3661023757336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146102355760405162461bcd60e51b815260206004820181905260248201527f63616c6c6572206e6f74206e617469766520746f6b656e20777261707065722e60448201526064015b60405180910390fd5b005b600080fd5b34801561024857600080fd5b5061025c6102573660046130ca565b610781565b60405190151581526020015b60405180910390f35b34801561027d57600080fd5b506102866107b8565b604051908152602001610268565b3480156102a057600080fd5b506102356102af366004613138565b610800565b3480156102c057600080fd5b506102d46102cf366004613190565b610820565b6040516001600160e01b03199091168152602001610268565b6102356102fb36600461322a565b610883565b34801561030c57600080fd5b5061023561031b36600461322a565b610a9a565b34801561032c57600080fd5b5061028661033b36600461322a565b60009081526003602052604090205490565b34801561035957600080fd5b50610235610368366004613243565b610bc1565b34801561037957600080fd5b50610235610388366004613243565b610c2c565b34801561039957600080fd5b50610235610c70565b3480156103ae57600080fd5b506103c26103bd36600461322a565b610c8c565b604051610268919061326f565b3480156103db57600080fd5b5061025c6103ea366004613283565b610cb6565b3480156103fb57600080fd5b5061023561040a36600461322a565b610cd4565b34801561041b57600080fd5b5061023561042a366004613353565b610dfc565b34801561043b57600080fd5b50609b546103c2906001600160a01b031681565b34801561045b57600080fd5b506103c261046a36600461346b565b610f5e565b34801561047b57600080fd5b506104cc61048a366004613283565b609f60205260009081526040902080546001909101546001600160401b0380831692600160401b810490911691600160801b9091046001600160801b03169084565b604080516001600160401b0395861681529490931660208501526001600160801b03909116918301919091526060820152608001610268565b34801561051157600080fd5b5061025c610520366004613243565b61104c565b34801561053157600080fd5b5061023561054036600461348d565b611077565b34801561055157600080fd5b5060d554610286565b34801561056657600080fd5b506103c261057536600461322a565b60a0602052600090815260409020546001600160a01b031681565b34801561059c57600080fd5b506102866105ab36600461322a565b6110a5565b3480156105bc57600080fd5b506102356105cb366004613138565b6110c6565b3480156105dc57600080fd5b5060405160018152602001610268565b3480156105f857600080fd5b50610286600081565b34801561060d57600080fd5b5061025c61061c366004613243565b6110d8565b34801561062d57600080fd5b5061064161063c366004613138565b61112e565b6040516102689190613511565b34801561065a57600080fd5b5061066e610669366004613283565b6112a1565b604051610268929190613575565b34801561068857600080fd5b5061028661069736600461322a565b6114cf565b3480156106a857600080fd5b50674e46545374616b6560c01b610286565b3480156106c657600080fd5b506102356106d536600461322a565b611558565b3480156106e657600080fd5b506102356106f5366004613243565b611628565b34801561070657600080fd5b50610286611641565b34801561071b57600080fd5b50610724611689565b60405161026891906135c2565b34801561073d57600080fd5b5060d4546103c2906001600160a01b031681565b34801561075d57600080fd5b5061025c61076c36600461322a565b609e6020526000908152604090205460ff1681565b60006001600160e01b03198216630a85bd0160e11b14806107b257506301ffc9a760e01b6001600160e01b03198316145b92915050565b600060a160006001609b60159054906101000a90046001600160401b03166107e091906135eb565b6001600160401b0316815260200190815260200160002060010154905090565b610808611717565b6108128282611770565b61081c6001606955565b5050565b609b54600090600160a01b900460ff166002146108715760405162461bcd60e51b815260206004820152600f60248201526e2234b932b1ba103a3930b739b332b960891b604482015260640161022c565b50630a85bd0160e11b95945050505050565b61088b611717565b6108986000610520611b93565b6108b45760405162461bcd60e51b815260040161022c90613612565b60d4546000906001600160a01b031673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee146108ee5760d4546001600160a01b0316610910565b7f00000000000000000000000000000000000000000000000000000000000000005b90506000816001600160a01b03166370a08231306040518263ffffffff1660e01b8152600401610940919061326f565b602060405180830381865afa15801561095d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610981919061363a565b60d4549091506109c4906001600160a01b031661099c611b93565b30867f0000000000000000000000000000000000000000000000000000000000000000611ba2565b600081836001600160a01b03166370a08231306040518263ffffffff1660e01b81526004016109f3919061326f565b602060405180830381865afa158015610a10573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a34919061363a565b610a3e9190613653565b90508060d56000828254610a529190613666565b90915550506040518181527ff9d14e57815939d300bc94720ede00c8c8e08d254ab28e2917ea46e149aa119b9060200160405180910390a1505050610a976001606955565b50565b610aa2611cf7565b610abe5760405162461bcd60e51b815260040161022c90613612565b600060a160006001609b60159054906101000a90046001600160401b0316610ae691906135eb565b6001600160401b031681526020808201929092526040908101600020815160808101835281548152600182015493810184905260028201549281019290925260030154606082015291508203610b725760405162461bcd60e51b81526020600482015260116024820152702932bbb0b932103ab731b430b733b2b21760791b604482015260640161022c565b8051610b7e9083611d05565b602080820151604080519182529181018490527f243c4656edc72b2c7ec8575d464d955b2f42c1b205960c6c2fb7eecda5419cf691015b60405180910390a15050565b600082815260036020526040902054610bda9033611e0d565b60008281526002602090815260408083206001600160a01b038516845290915290205460ff1615610c22578082604051636a4e0b3560e11b815260040161022c929190613679565b61081c8282611e54565b336001600160a01b03821614610c66576040516320b4e31160e11b81523360048201526001600160a01b038216602482015260440161022c565b61081c8282611e68565b610c78611717565b610c80611ebf565b610c8a6001606955565b565b609d8181548110610c9c57600080fd5b6000918252602090912001546001600160a01b0316905081565b6001600160a01b031660009081526037602052604090205460ff1690565b610cdc611cf7565b610cf85760405162461bcd60e51b815260040161022c90613612565b600060a160006001609b60159054906101000a90046001600160401b0316610d2091906135eb565b6001600160401b03168152602001908152602001600020604051806080016040529081600082015481526020016001820154815260200160028201548152602001600382015481525050905080600001518203610db65760405162461bcd60e51b81526020600482015260146024820152732a34b6b296bab734ba103ab731b430b733b2b21760611b604482015260640161022c565b610dc4828260200151611d05565b805160408051918252602082018490527fd968de290ed68f978b9e4816f7d4be9ef46189fe8eeb3eeb86199e7229cf2de09101610bb5565b600054610100900460ff1615808015610e1c5750600054600160ff909116105b80610e3d5750610e2b30612084565b158015610e3d575060005460ff166001145b610ea05760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b606482015260840161022c565b6000805460ff191660011790558015610ec3576000805461ff0019166101001790555b610ecc86612093565b60d480546001600160a01b0319166001600160a01b038716179055610ef084612118565b610efa8383611d05565b610f03876121b6565b610f0e600089611e54565b8015610f54576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5050505050505050565b60008281526004602052604081205481805b828110156110435760008681526004602090815260408083208484526001019091529020546001600160a01b031615610fec57848203610fda5760008681526004602090815260408083209383526001909301905220546001600160a01b031692506107b2915050565b610fe5600183613666565b9150611031565b610ff786600061104c565b801561101e5750600086815260046020908152604080832083805260020190915290205481145b156110315761102e600183613666565b91505b61103c600182613666565b9050610f70565b50505092915050565b60009182526002602090815260408084206001600160a01b0393909316845291905290205460ff1690565b61107f611cf7565b61109c57604051639f7f092560e01b815260040160405180910390fd5b610a97816121b6565b609c81815481106110b557600080fd5b600091825260209091200154905081565b6110ce611717565b6108128282612286565b600082815260026020908152604080832083805290915281205460ff16611125575060008281526002602090815260408083206001600160a01b038516845290915290205460ff166107b2565b50600192915050565b6060816001600160401b038111156111485761114861329e565b60405190808252806020026020018201604052801561117b57816020015b60608152602001906001900390816111665790505b5090506000611188611b93565b9050336001600160a01b038216141560005b84811015611043578115611219576111f7308787848181106111be576111be613692565b90506020028101906111d091906136a8565b866040516020016111e3939291906136ee565b6040516020818303038152906040526126fe565b84828151811061120957611209613692565b6020026020010181905250611299565b61127b3087878481811061122f5761122f613692565b905060200281019061124191906136a8565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506126fe92505050565b84828151811061128d5761128d613692565b60200260200101819052505b60010161119a565b6060600080609c8054806020026020016040519081016040528092919081815260200182805480156112f257602002820191906000526020600020905b8154815260200190600101908083116112de575b50505050509050600081516001600160401b038111156113145761131461329e565b60405190808252806020026020018201604052801561133d578160200160208202803683370190505b5082519091506000805b828110156113fc57876001600160a01b031660a0600087848151811061136f5761136f613692565b6020026020010151815260200190815260200160002060009054906101000a90046001600160a01b03166001600160a01b0316148482815181106113b5576113b5613692565b6020026020010190151590811515815250508381815181106113d9576113d9613692565b6020026020010151156113f4576113f1600183613666565b91505b600101611347565b50806001600160401b038111156114155761141561329e565b60405190808252806020026020018201604052801561143e578160200160208202803683370190505b5095506000805b838110156114b95784818151811061145f5761145f613692565b6020026020010151156114b15785818151811061147e5761147e613692565b602002602001015188838151811061149857611498613692565b60209081029190910101526114ae600183613666565b91505b600101611445565b506114c38861272a565b95505050505050915091565b600081815260046020526040812054815b818110156115335760008481526004602090815260408083208484526001019091529020546001600160a01b0316156115215761151e600184613666565b92505b61152c600182613666565b90506114e0565b5061153f83600061104c565b156115525761154f600183613666565b91505b50919050565b611560611717565b61156d6000610520611b93565b6115895760405162461bcd60e51b815260040161022c90613612565b60d55481116115a5578060d5546115a09190613653565b6115a8565b60005b60d55560d4546115eb906001600160a01b0316306115c4611b93565b847f0000000000000000000000000000000000000000000000000000000000000000611ba2565b6040518181527f37ff8766c704931c4283e470feb7c20ddcd8aa492746f74b30503709a0452acd9060200160405180910390a1610a976001606955565b600082815260036020526040902054610c669033611e0d565b600060a160006001609b60159054906101000a90046001600160401b031661166991906135eb565b6001600160401b0316815260200190815260200160002060000154905090565b600180546116969061370f565b80601f01602080910402602001604051908101604052809291908181526020018280546116c29061370f565b801561170f5780601f106116e45761010080835404028352916020019161170f565b820191906000526020600020905b8154815290600101906020018083116116f257829003601f168201915b505050505081565b6002606954036117695760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640161022c565b6002606955565b806001600160401b0381166000036117bd5760405162461bcd60e51b815260206004820152601060248201526f5374616b696e67203020746f6b656e7360801b604482015260640161022c565b609b546001600160a01b03166000609f816117d66127a5565b6001600160a01b031681526020810191909152604001600020546001600160401b031611156118145761180f61180a6127a5565b6127af565b6118fe565b609d61181e6127a5565b81546001810183556000928352602083200180546001600160a01b0319166001600160a01b03929092169190911790554290609f9061185b6127a5565b6001600160a01b03168152602081019190915260400160002080546001600160801b03928316600160801b029216919091179055609b546118af906001906001600160401b03600160a81b909104166135eb565b609f60006118bb6127a5565b6001600160a01b03168152602081019190915260400160002080546001600160401b0392909216600160401b02600160401b600160801b03199092169190911790555b60005b826001600160401b0316811015611acb57609b805460ff60a01b1916600160a11b1790556001600160a01b0382166342842e0e61193c6127a5565b3088888681811061194f5761194f613692565b905060200201356040518463ffffffff1660e01b815260040161197493929190613743565b600060405180830381600087803b15801561198e57600080fd5b505af11580156119a2573d6000803e3d6000fd5b5050609b805460ff60a01b1916600160a01b179055506119c290506127a5565b60a060008787858181106119d8576119d8613692565b90506020020135815260200190815260200160002060006101000a8154816001600160a01b0302191690836001600160a01b03160217905550609e6000868684818110611a2757611a27613692565b602090810292909201358352508101919091526040016000205460ff16611ac3576001609e6000878785818110611a6057611a60613692565b90506020020135815260200190815260200160002060006101000a81548160ff021916908315150217905550609c858583818110611aa057611aa0613692565b835460018101855560009485526020948590209190940292909201359190920155505b600101611901565b5081609f6000611ad96127a5565b6001600160a01b03168152602081019190915260400160009081208054909190611b0d9084906001600160401b0316613767565b92506101000a8154816001600160401b0302191690836001600160401b031602179055508383604051611b41929190613787565b6040518091039020611b516127a5565b6001600160a01b03167f540cd34f06460fd67aeca9d19e0a56cd3a7c1cde8dc2263f265b68b2ef3495d260405160405180910390a350505050565b6001606955565b6000611b9d612885565b905090565b8115611cf05773eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeed196001600160a01b03861601611ce457306001600160a01b03851603611c4757604051632e1a7d4d60e01b8152600481018390526001600160a01b03821690632e1a7d4d90602401600060405180830381600087803b158015611c1f57600080fd5b505af1158015611c33573d6000803e3d6000fd5b50505050611c428383836128a7565b611cf0565b306001600160a01b03841603611cd957348214611c80576040516303e085f960e01b81523460048201526024810183905260440161022c565b806001600160a01b031663d0e30db0836040518263ffffffff1660e01b81526004016000604051808303818588803b158015611cbb57600080fd5b505af1158015611ccf573d6000803e3d6000fd5b5050505050611cf0565b611c428383836128a7565b611cf085858585612972565b5050505050565b6000611b9d81610520611b93565b81600003611d4c5760405162461bcd60e51b8152602060048201526014602482015273074696d652d756e69742063616e277420626520360641b604482015260640161022c565b609b8054600160a81b90046001600160401b0316906001906015611d708385613767565b82546001600160401b039182166101009390930a9283029190920219909116179055506040805160808101825284815260208082018581524283850190815260006060850181815287825260a190945294909420925183555160018301559151600282015590516003909101558015611e08574260a16000611df3600185613653565b81526020810191909152604001600020600301555b505050565b60008281526002602090815260408083206001600160a01b038516845290915290205460ff1661081c57808260405163043c588360e11b815260040161022c929190613679565b611e5e82826129ca565b61081c8282612a25565b611e728282612a92565b60008281526004602090815260408083206001600160a01b03851680855260028201808552838620805487526001909301855292852080546001600160a01b031916905584529152555050565b6000611ed1611ecc6127a5565b612af4565b609f6000611edd6127a5565b6001600160a01b03166001600160a01b0316815260200190815260200160002060010154611f0b9190613666565b905080600003611f4a5760405162461bcd60e51b815260206004820152600a6024820152694e6f207265776172647360b01b604482015260640161022c565b42609f6000611f576127a5565b6001600160a01b031681526020810191909152604001600090812080546001600160801b03938416600160801b02931692909217909155609f81611f996127a5565b6001600160a01b031681526020810191909152604001600020600190810191909155609b54611fd89190600160a81b90046001600160401b03166135eb565b609f6000611fe46127a5565b6001600160a01b03168152602081019190915260400160002080546001600160401b0392909216600160401b02600160401b600160801b03199092169190911790556120376120316127a5565b82612c82565b61203f6127a5565b6001600160a01b03167ffc30cddea38e2bf4d6ea7d3f9ed3b6ad7f176419f4963bd81318067a4aee73fe8260405161207991815260200190565b60405180910390a250565b6001600160a01b03163b151590565b600054610100900460ff166120ba5760405162461bcd60e51b815260040161022c906137b0565b60005b815181101561081c576001603760008484815181106120de576120de613692565b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff19169115159190911790556001016120bd565b600054610100900460ff1661213f5760405162461bcd60e51b815260040161022c906137b0565b612147612d1f565b6001600160a01b0381166121945760405162461bcd60e51b81526020600482015260146024820152730636f6c6c656374696f6e206164647265737320360641b604482015260640161022c565b609b80546001600160a01b0319166001600160a01b0392909216919091179055565b6000600180546121c59061370f565b80601f01602080910402602001604051908101604052809291908181526020018280546121f19061370f565b801561223e5780601f106122135761010080835404028352916020019161223e565b820191906000526020600020905b81548152906001019060200180831161222157829003601f168201915b505050505090508160019081612254919061384b565b507fc9c7c3fe08b88b4df9d4d47ef47d2c43d55c025a0ba88ca442580ed9e7348a168183604051610bb592919061390a565b6000609f60006122946127a5565b6001600160a01b0316815260208101919091526040016000908120546001600160401b039081169250839190821690036123075760405162461bcd60e51b81526020600482015260146024820152735769746864726177696e67203020746f6b656e7360601b604482015260640161022c565b806001600160401b031682101561235f5760405162461bcd60e51b815260206004820152601c60248201527b15da5d1a191c985dda5b99c81b5bdc99481d1a185b881cdd185ad95960221b604482015260640161022c565b609b546001600160a01b031661237661180a6127a5565b816001600160401b031683036124d5576000609d8054806020026020016040519081016040528092919081815260200182805480156123de57602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116123c0575b5050505050905060005b81518110156124d2576123f96127a5565b6001600160a01b031682828151811061241457612414613692565b60200260200101516001600160a01b0316036124ca5781600183516124399190613653565b8151811061244957612449613692565b6020026020010151609d828154811061246457612464613692565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550609d8054806124a3576124a3613938565b600082815260209020810160001990810180546001600160a01b03191690550190556124d2565b6001016123e8565b50505b81609f60006124e26127a5565b6001600160a01b031681526020810191909152604001600090812080549091906125169084906001600160401b03166135eb565b92506101000a8154816001600160401b0302191690836001600160401b0316021790555060005b826001600160401b03168110156126a1576125566127a5565b6001600160a01b031660a0600088888581811061257557612575613692565b60209081029290920135835250810191909152604001600020546001600160a01b0316146125d25760405162461bcd60e51b815260206004820152600a6024820152692737ba1039ba30b5b2b960b11b604482015260640161022c565b600060a060008888858181106125ea576125ea613692565b6020908102929092013583525081019190915260400160002080546001600160a01b0319166001600160a01b0392831617905582166342842e0e3061262d6127a5565b89898681811061263f5761263f613692565b905060200201356040518463ffffffff1660e01b815260040161266493929190613743565b600060405180830381600087803b15801561267e57600080fd5b505af1158015612692573d6000803e3d6000fd5b5050505080600101905061253d565b5084846040516126b2929190613787565b60405180910390206126c26127a5565b6001600160a01b03167f09ba0ae49142860d7eec1f3ce54722d70b60910facbe018cccb1099e4e84755c60405160405180910390a35050505050565b606061272383836040518060600160405280602781526020016139dc60279139612d4e565b9392505050565b6001600160a01b0381166000908152609f60205260408120546001600160401b0316810361277157506001600160a01b03166000908152609f602052604090206001015490565b61277a82612af4565b6001600160a01b0383166000908152609f60205260409020600101546107b29190613666565b919050565b6000611b9d611b93565b60006127ba82612af4565b6001600160a01b0383166000908152609f60205260408120600101805492935083929091906127ea908490613666565b90915550506001600160a01b0382166000908152609f6020526040902080546001600160801b03428116600160801b029116179055609b5461283f906001906001600160401b03600160a81b909104166135eb565b6001600160a01b039092166000908152609f6020526040902080546001600160401b0393909316600160401b02600160401b600160801b03199093169290921790915550565b600061289033610cb6565b156128a2575060131936013560601c90565b503390565b6000836001600160a01b03168360405160006040518083038185875af1925050503d80600081146128f4576040519150601f19603f3d011682016040523d82523d6000602084013e6128f9565b606091505b505090508061296c57816001600160a01b031663d0e30db0846040518263ffffffff1660e01b81526004016000604051808303818588803b15801561293d57600080fd5b505af1158015612951573d6000803e3d6000fd5b5061296c935050506001600160a01b03841690508585612dc6565b50505050565b816001600160a01b0316836001600160a01b0316031561296c57306001600160a01b038416036129b5576129b06001600160a01b0385168383612dc6565b61296c565b61296c6001600160a01b038516848484612e1c565b60008281526002602090815260408083206001600160a01b0385168085529252808320805460ff1916600117905551339285917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9190a45050565b600082815260046020526040812080549160019190612a448385613666565b9091555050600092835260046020908152604080852083865260018101835281862080546001600160a01b039096166001600160a01b03199096168617905593855260029093019052912055565b612a9c8282611e0d565b60008281526002602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6001600160a01b0381166000908152609f60209081526040808320815160808101835281546001600160401b038082168352600160401b82048116958301869052600160801b9091046001600160801b0316938201939093526001909101546060820152609b54909291600160a81b90910416815b81811015612c7957600081815260a16020908152604080832081516080810183528154815260018201549381019390935260028101549183019190915260030154606082015290848303612bca5785604001516001600160801b0316612bd0565b81604001515b905060008260600151600003612be65742612bec565b82606001515b9050600080612c2289600001516001600160401b03168585612c0e9190613653565b612c18919061394e565b8660200151612e3d565b91509150600080612c428c886000015185612c3d919061397b565b612e88565b91509150838015612c505750815b612c5a578b612c5c565b805b9b5050505050505050600181612c729190613666565b9050612b69565b50505050919050565b60d554811115612ccf5760405162461bcd60e51b81526020600482015260186024820152774e6f7420656e6f7567682072657761726420746f6b656e7360401b604482015260640161022c565b8060d56000828254612ce19190613653565b909155505060d45461081c906001600160a01b03163084847f0000000000000000000000000000000000000000000000000000000000000000611ba2565b600054610100900460ff16612d465760405162461bcd60e51b815260040161022c906137b0565b610c8a612ea3565b6060600080856001600160a01b031685604051612d6b919061399d565b600060405180830381855af49150503d8060008114612da6576040519150601f19603f3d011682016040523d82523d6000602084013e612dab565b606091505b5091509150612dbc86838387612eca565b9695505050505050565b611e088363a9059cbb60e01b8484604051602401612de5929190613679565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612f49565b61296c846323b872dd60e01b858585604051602401612de593929190613743565b60008083600003612e545750600190506000612e81565b83830283858281612e6757612e67613965565b0414612e7a576000809250925050612e81565b6001925090505b9250929050565b60008083830184811015612e7a576000809250925050612e81565b600054610100900460ff16611b8c5760405162461bcd60e51b815260040161022c906137b0565b60608315612f37578251600003612f3057612ee485612084565b612f305760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161022c565b5081612f41565b612f41838361301b565b949350505050565b6000612f9e826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166130459092919063ffffffff16565b805190915015611e085780806020019051810190612fbc91906139b9565b611e085760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161022c565b81511561302b5781518083602001fd5b8060405162461bcd60e51b815260040161022c91906135c2565b6060612f41848460008585600080866001600160a01b0316858760405161306c919061399d565b60006040518083038185875af1925050503d80600081146130a9576040519150601f19603f3d011682016040523d82523d6000602084013e6130ae565b606091505b50915091506130bf87838387612eca565b979650505050505050565b6000602082840312156130dc57600080fd5b81356001600160e01b03198116811461272357600080fd5b60008083601f84011261310657600080fd5b5081356001600160401b0381111561311d57600080fd5b6020830191508360208260051b8501011115612e8157600080fd5b6000806020838503121561314b57600080fd5b82356001600160401b0381111561316157600080fd5b61316d858286016130f4565b90969095509350505050565b80356001600160a01b03811681146127a057600080fd5b6000806000806000608086880312156131a857600080fd5b6131b186613179565b94506131bf60208701613179565b93506040860135925060608601356001600160401b03808211156131e257600080fd5b818801915088601f8301126131f657600080fd5b81358181111561320557600080fd5b89602082850101111561321757600080fd5b9699959850939650602001949392505050565b60006020828403121561323c57600080fd5b5035919050565b6000806040838503121561325657600080fd5b8235915061326660208401613179565b90509250929050565b6001600160a01b0391909116815260200190565b60006020828403121561329557600080fd5b61272382613179565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b03811182821017156132dc576132dc61329e565b604052919050565b600082601f8301126132f557600080fd5b81356001600160401b0381111561330e5761330e61329e565b613321601f8201601f19166020016132b4565b81815284602083860101111561333657600080fd5b816020850160208301376000918101602001919091529392505050565b600080600080600080600060e0888a03121561336e57600080fd5b61337788613179565b96506020808901356001600160401b038082111561339457600080fd5b6133a08c838d016132e4565b985060408b01359150808211156133b657600080fd5b818b0191508b601f8301126133ca57600080fd5b8135818111156133dc576133dc61329e565b8060051b91506133ed8483016132b4565b818152918301840191848101908e84111561340757600080fd5b938501935b8385101561342c5761341d85613179565b8252938501939085019061340c565b809a5050505050505061344160608901613179565b935061344f60808901613179565b925060a0880135915060c0880135905092959891949750929550565b6000806040838503121561347e57600080fd5b50508035926020909101359150565b60006020828403121561349f57600080fd5b81356001600160401b038111156134b557600080fd5b612f41848285016132e4565b60005b838110156134dc5781810151838201526020016134c4565b50506000910152565b600081518084526134fd8160208601602086016134c1565b601f01601f19169290920160200192915050565b600060208083016020845280855180835260408601915060408160051b87010192506020870160005b8281101561356857603f198886030184526135568583516134e5565b9450928501929085019060010161353a565b5092979650505050505050565b604080825283519082018190526000906020906060840190828701845b828110156135ae57815184529284019290840190600101613592565b505050602093909301939093525092915050565b60208152600061272360208301846134e5565b634e487b7160e01b600052601160045260246000fd5b6001600160401b0382811682821603908082111561360b5761360b6135d5565b5092915050565b6020808252600e908201526d139bdd08185d5d1a1bdc9a5e995960921b604082015260600190565b60006020828403121561364c57600080fd5b5051919050565b818103818111156107b2576107b26135d5565b808201808211156107b2576107b26135d5565b6001600160a01b03929092168252602082015260400190565b634e487b7160e01b600052603260045260246000fd5b6000808335601e198436030181126136bf57600080fd5b8301803591506001600160401b038211156136d957600080fd5b602001915036819003821315612e8157600080fd5b8284823760609190911b6001600160601b0319169101908152601401919050565b600181811c9082168061372357607f821691505b60208210810361155257634e487b7160e01b600052602260045260246000fd5b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160401b0381811683821601908082111561360b5761360b6135d5565b60006001600160fb1b0383111561379d57600080fd5b8260051b80858437919091019392505050565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b601f821115611e08576000816000526020600020601f850160051c810160208610156138245750805b601f850160051c820191505b8181101561384357828155600101613830565b505050505050565b81516001600160401b038111156138645761386461329e565b61387881613872845461370f565b846137fb565b602080601f8311600181146138ad57600084156138955750858301515b600019600386901b1c1916600185901b178555613843565b600085815260208120601f198616915b828110156138dc578886015182559484019460019091019084016138bd565b50858210156138fa5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b60408152600061391d60408301856134e5565b828103602084015261392f81856134e5565b95945050505050565b634e487b7160e01b600052603160045260246000fd5b80820281158282048414176107b2576107b26135d5565b634e487b7160e01b600052601260045260246000fd5b60008261399857634e487b7160e01b600052601260045260246000fd5b500490565b600082516139af8184602087016134c1565b9190910192915050565b6000602082840312156139cb57600080fd5b8151801515811461272357600080fdfe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a264697066735822122018b857bb92bc5d65c474932dfb42c375ebdf98805e3ab20ee242c2748d82261b64736f6c6343000817003300000000000000000000000081e609b897393731a3d23c1d311330340cebb9e9
Deployed ByteCode
0x6080604052600436106101b35760003560e01c8063938e3d7b116100e8578063938e3d7b1461052557806393ce534314610545578063940670451461055a578063961004d314610590578063983d95ce146105b0578063a0a8e460146105d0578063a217fddf146105ec578063a32fa5b314610601578063ac9650d814610621578063c34531531461064e578063ca15c8731461067c578063cb2ef6f71461069c578063cb43b2dd146106ba578063d547741f146106da578063d68124c7146106fa578063e8a3d4851461070f578063f7c618c114610731578063fd48ba171461075157600080fd5b806301ffc9a71461023c5780630e8b229b146102715780630fbf0a9314610294578063150b7a02146102b457806316c621e0146102ed57806323ef258014610300578063248a9ca3146103205780632f2ff15d1461034d57806336568abe1461036d578063372500ab1461038d5780635357e916146103a2578063572b6c05146103cf5780636360106f146103ef5780636a5ab6e51461040f57806372f702f31461042f5780639010d07c1461044f5780639168ae721461046f57806391d148541461050557600080fd5b3661023757336001600160a01b037f00000000000000000000000081e609b897393731a3d23c1d311330340cebb9e916146102355760405162461bcd60e51b815260206004820181905260248201527f63616c6c6572206e6f74206e617469766520746f6b656e20777261707065722e60448201526064015b60405180910390fd5b005b600080fd5b34801561024857600080fd5b5061025c6102573660046130ca565b610781565b60405190151581526020015b60405180910390f35b34801561027d57600080fd5b506102866107b8565b604051908152602001610268565b3480156102a057600080fd5b506102356102af366004613138565b610800565b3480156102c057600080fd5b506102d46102cf366004613190565b610820565b6040516001600160e01b03199091168152602001610268565b6102356102fb36600461322a565b610883565b34801561030c57600080fd5b5061023561031b36600461322a565b610a9a565b34801561032c57600080fd5b5061028661033b36600461322a565b60009081526003602052604090205490565b34801561035957600080fd5b50610235610368366004613243565b610bc1565b34801561037957600080fd5b50610235610388366004613243565b610c2c565b34801561039957600080fd5b50610235610c70565b3480156103ae57600080fd5b506103c26103bd36600461322a565b610c8c565b604051610268919061326f565b3480156103db57600080fd5b5061025c6103ea366004613283565b610cb6565b3480156103fb57600080fd5b5061023561040a36600461322a565b610cd4565b34801561041b57600080fd5b5061023561042a366004613353565b610dfc565b34801561043b57600080fd5b50609b546103c2906001600160a01b031681565b34801561045b57600080fd5b506103c261046a36600461346b565b610f5e565b34801561047b57600080fd5b506104cc61048a366004613283565b609f60205260009081526040902080546001909101546001600160401b0380831692600160401b810490911691600160801b9091046001600160801b03169084565b604080516001600160401b0395861681529490931660208501526001600160801b03909116918301919091526060820152608001610268565b34801561051157600080fd5b5061025c610520366004613243565b61104c565b34801561053157600080fd5b5061023561054036600461348d565b611077565b34801561055157600080fd5b5060d554610286565b34801561056657600080fd5b506103c261057536600461322a565b60a0602052600090815260409020546001600160a01b031681565b34801561059c57600080fd5b506102866105ab36600461322a565b6110a5565b3480156105bc57600080fd5b506102356105cb366004613138565b6110c6565b3480156105dc57600080fd5b5060405160018152602001610268565b3480156105f857600080fd5b50610286600081565b34801561060d57600080fd5b5061025c61061c366004613243565b6110d8565b34801561062d57600080fd5b5061064161063c366004613138565b61112e565b6040516102689190613511565b34801561065a57600080fd5b5061066e610669366004613283565b6112a1565b604051610268929190613575565b34801561068857600080fd5b5061028661069736600461322a565b6114cf565b3480156106a857600080fd5b50674e46545374616b6560c01b610286565b3480156106c657600080fd5b506102356106d536600461322a565b611558565b3480156106e657600080fd5b506102356106f5366004613243565b611628565b34801561070657600080fd5b50610286611641565b34801561071b57600080fd5b50610724611689565b60405161026891906135c2565b34801561073d57600080fd5b5060d4546103c2906001600160a01b031681565b34801561075d57600080fd5b5061025c61076c36600461322a565b609e6020526000908152604090205460ff1681565b60006001600160e01b03198216630a85bd0160e11b14806107b257506301ffc9a760e01b6001600160e01b03198316145b92915050565b600060a160006001609b60159054906101000a90046001600160401b03166107e091906135eb565b6001600160401b0316815260200190815260200160002060010154905090565b610808611717565b6108128282611770565b61081c6001606955565b5050565b609b54600090600160a01b900460ff166002146108715760405162461bcd60e51b815260206004820152600f60248201526e2234b932b1ba103a3930b739b332b960891b604482015260640161022c565b50630a85bd0160e11b95945050505050565b61088b611717565b6108986000610520611b93565b6108b45760405162461bcd60e51b815260040161022c90613612565b60d4546000906001600160a01b031673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee146108ee5760d4546001600160a01b0316610910565b7f00000000000000000000000081e609b897393731a3d23c1d311330340cebb9e95b90506000816001600160a01b03166370a08231306040518263ffffffff1660e01b8152600401610940919061326f565b602060405180830381865afa15801561095d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610981919061363a565b60d4549091506109c4906001600160a01b031661099c611b93565b30867f00000000000000000000000081e609b897393731a3d23c1d311330340cebb9e9611ba2565b600081836001600160a01b03166370a08231306040518263ffffffff1660e01b81526004016109f3919061326f565b602060405180830381865afa158015610a10573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a34919061363a565b610a3e9190613653565b90508060d56000828254610a529190613666565b90915550506040518181527ff9d14e57815939d300bc94720ede00c8c8e08d254ab28e2917ea46e149aa119b9060200160405180910390a1505050610a976001606955565b50565b610aa2611cf7565b610abe5760405162461bcd60e51b815260040161022c90613612565b600060a160006001609b60159054906101000a90046001600160401b0316610ae691906135eb565b6001600160401b031681526020808201929092526040908101600020815160808101835281548152600182015493810184905260028201549281019290925260030154606082015291508203610b725760405162461bcd60e51b81526020600482015260116024820152702932bbb0b932103ab731b430b733b2b21760791b604482015260640161022c565b8051610b7e9083611d05565b602080820151604080519182529181018490527f243c4656edc72b2c7ec8575d464d955b2f42c1b205960c6c2fb7eecda5419cf691015b60405180910390a15050565b600082815260036020526040902054610bda9033611e0d565b60008281526002602090815260408083206001600160a01b038516845290915290205460ff1615610c22578082604051636a4e0b3560e11b815260040161022c929190613679565b61081c8282611e54565b336001600160a01b03821614610c66576040516320b4e31160e11b81523360048201526001600160a01b038216602482015260440161022c565b61081c8282611e68565b610c78611717565b610c80611ebf565b610c8a6001606955565b565b609d8181548110610c9c57600080fd5b6000918252602090912001546001600160a01b0316905081565b6001600160a01b031660009081526037602052604090205460ff1690565b610cdc611cf7565b610cf85760405162461bcd60e51b815260040161022c90613612565b600060a160006001609b60159054906101000a90046001600160401b0316610d2091906135eb565b6001600160401b03168152602001908152602001600020604051806080016040529081600082015481526020016001820154815260200160028201548152602001600382015481525050905080600001518203610db65760405162461bcd60e51b81526020600482015260146024820152732a34b6b296bab734ba103ab731b430b733b2b21760611b604482015260640161022c565b610dc4828260200151611d05565b805160408051918252602082018490527fd968de290ed68f978b9e4816f7d4be9ef46189fe8eeb3eeb86199e7229cf2de09101610bb5565b600054610100900460ff1615808015610e1c5750600054600160ff909116105b80610e3d5750610e2b30612084565b158015610e3d575060005460ff166001145b610ea05760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b606482015260840161022c565b6000805460ff191660011790558015610ec3576000805461ff0019166101001790555b610ecc86612093565b60d480546001600160a01b0319166001600160a01b038716179055610ef084612118565b610efa8383611d05565b610f03876121b6565b610f0e600089611e54565b8015610f54576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5050505050505050565b60008281526004602052604081205481805b828110156110435760008681526004602090815260408083208484526001019091529020546001600160a01b031615610fec57848203610fda5760008681526004602090815260408083209383526001909301905220546001600160a01b031692506107b2915050565b610fe5600183613666565b9150611031565b610ff786600061104c565b801561101e5750600086815260046020908152604080832083805260020190915290205481145b156110315761102e600183613666565b91505b61103c600182613666565b9050610f70565b50505092915050565b60009182526002602090815260408084206001600160a01b0393909316845291905290205460ff1690565b61107f611cf7565b61109c57604051639f7f092560e01b815260040160405180910390fd5b610a97816121b6565b609c81815481106110b557600080fd5b600091825260209091200154905081565b6110ce611717565b6108128282612286565b600082815260026020908152604080832083805290915281205460ff16611125575060008281526002602090815260408083206001600160a01b038516845290915290205460ff166107b2565b50600192915050565b6060816001600160401b038111156111485761114861329e565b60405190808252806020026020018201604052801561117b57816020015b60608152602001906001900390816111665790505b5090506000611188611b93565b9050336001600160a01b038216141560005b84811015611043578115611219576111f7308787848181106111be576111be613692565b90506020028101906111d091906136a8565b866040516020016111e3939291906136ee565b6040516020818303038152906040526126fe565b84828151811061120957611209613692565b6020026020010181905250611299565b61127b3087878481811061122f5761122f613692565b905060200281019061124191906136a8565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506126fe92505050565b84828151811061128d5761128d613692565b60200260200101819052505b60010161119a565b6060600080609c8054806020026020016040519081016040528092919081815260200182805480156112f257602002820191906000526020600020905b8154815260200190600101908083116112de575b50505050509050600081516001600160401b038111156113145761131461329e565b60405190808252806020026020018201604052801561133d578160200160208202803683370190505b5082519091506000805b828110156113fc57876001600160a01b031660a0600087848151811061136f5761136f613692565b6020026020010151815260200190815260200160002060009054906101000a90046001600160a01b03166001600160a01b0316148482815181106113b5576113b5613692565b6020026020010190151590811515815250508381815181106113d9576113d9613692565b6020026020010151156113f4576113f1600183613666565b91505b600101611347565b50806001600160401b038111156114155761141561329e565b60405190808252806020026020018201604052801561143e578160200160208202803683370190505b5095506000805b838110156114b95784818151811061145f5761145f613692565b6020026020010151156114b15785818151811061147e5761147e613692565b602002602001015188838151811061149857611498613692565b60209081029190910101526114ae600183613666565b91505b600101611445565b506114c38861272a565b95505050505050915091565b600081815260046020526040812054815b818110156115335760008481526004602090815260408083208484526001019091529020546001600160a01b0316156115215761151e600184613666565b92505b61152c600182613666565b90506114e0565b5061153f83600061104c565b156115525761154f600183613666565b91505b50919050565b611560611717565b61156d6000610520611b93565b6115895760405162461bcd60e51b815260040161022c90613612565b60d55481116115a5578060d5546115a09190613653565b6115a8565b60005b60d55560d4546115eb906001600160a01b0316306115c4611b93565b847f00000000000000000000000081e609b897393731a3d23c1d311330340cebb9e9611ba2565b6040518181527f37ff8766c704931c4283e470feb7c20ddcd8aa492746f74b30503709a0452acd9060200160405180910390a1610a976001606955565b600082815260036020526040902054610c669033611e0d565b600060a160006001609b60159054906101000a90046001600160401b031661166991906135eb565b6001600160401b0316815260200190815260200160002060000154905090565b600180546116969061370f565b80601f01602080910402602001604051908101604052809291908181526020018280546116c29061370f565b801561170f5780601f106116e45761010080835404028352916020019161170f565b820191906000526020600020905b8154815290600101906020018083116116f257829003601f168201915b505050505081565b6002606954036117695760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640161022c565b6002606955565b806001600160401b0381166000036117bd5760405162461bcd60e51b815260206004820152601060248201526f5374616b696e67203020746f6b656e7360801b604482015260640161022c565b609b546001600160a01b03166000609f816117d66127a5565b6001600160a01b031681526020810191909152604001600020546001600160401b031611156118145761180f61180a6127a5565b6127af565b6118fe565b609d61181e6127a5565b81546001810183556000928352602083200180546001600160a01b0319166001600160a01b03929092169190911790554290609f9061185b6127a5565b6001600160a01b03168152602081019190915260400160002080546001600160801b03928316600160801b029216919091179055609b546118af906001906001600160401b03600160a81b909104166135eb565b609f60006118bb6127a5565b6001600160a01b03168152602081019190915260400160002080546001600160401b0392909216600160401b02600160401b600160801b03199092169190911790555b60005b826001600160401b0316811015611acb57609b805460ff60a01b1916600160a11b1790556001600160a01b0382166342842e0e61193c6127a5565b3088888681811061194f5761194f613692565b905060200201356040518463ffffffff1660e01b815260040161197493929190613743565b600060405180830381600087803b15801561198e57600080fd5b505af11580156119a2573d6000803e3d6000fd5b5050609b805460ff60a01b1916600160a01b179055506119c290506127a5565b60a060008787858181106119d8576119d8613692565b90506020020135815260200190815260200160002060006101000a8154816001600160a01b0302191690836001600160a01b03160217905550609e6000868684818110611a2757611a27613692565b602090810292909201358352508101919091526040016000205460ff16611ac3576001609e6000878785818110611a6057611a60613692565b90506020020135815260200190815260200160002060006101000a81548160ff021916908315150217905550609c858583818110611aa057611aa0613692565b835460018101855560009485526020948590209190940292909201359190920155505b600101611901565b5081609f6000611ad96127a5565b6001600160a01b03168152602081019190915260400160009081208054909190611b0d9084906001600160401b0316613767565b92506101000a8154816001600160401b0302191690836001600160401b031602179055508383604051611b41929190613787565b6040518091039020611b516127a5565b6001600160a01b03167f540cd34f06460fd67aeca9d19e0a56cd3a7c1cde8dc2263f265b68b2ef3495d260405160405180910390a350505050565b6001606955565b6000611b9d612885565b905090565b8115611cf05773eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeed196001600160a01b03861601611ce457306001600160a01b03851603611c4757604051632e1a7d4d60e01b8152600481018390526001600160a01b03821690632e1a7d4d90602401600060405180830381600087803b158015611c1f57600080fd5b505af1158015611c33573d6000803e3d6000fd5b50505050611c428383836128a7565b611cf0565b306001600160a01b03841603611cd957348214611c80576040516303e085f960e01b81523460048201526024810183905260440161022c565b806001600160a01b031663d0e30db0836040518263ffffffff1660e01b81526004016000604051808303818588803b158015611cbb57600080fd5b505af1158015611ccf573d6000803e3d6000fd5b5050505050611cf0565b611c428383836128a7565b611cf085858585612972565b5050505050565b6000611b9d81610520611b93565b81600003611d4c5760405162461bcd60e51b8152602060048201526014602482015273074696d652d756e69742063616e277420626520360641b604482015260640161022c565b609b8054600160a81b90046001600160401b0316906001906015611d708385613767565b82546001600160401b039182166101009390930a9283029190920219909116179055506040805160808101825284815260208082018581524283850190815260006060850181815287825260a190945294909420925183555160018301559151600282015590516003909101558015611e08574260a16000611df3600185613653565b81526020810191909152604001600020600301555b505050565b60008281526002602090815260408083206001600160a01b038516845290915290205460ff1661081c57808260405163043c588360e11b815260040161022c929190613679565b611e5e82826129ca565b61081c8282612a25565b611e728282612a92565b60008281526004602090815260408083206001600160a01b03851680855260028201808552838620805487526001909301855292852080546001600160a01b031916905584529152555050565b6000611ed1611ecc6127a5565b612af4565b609f6000611edd6127a5565b6001600160a01b03166001600160a01b0316815260200190815260200160002060010154611f0b9190613666565b905080600003611f4a5760405162461bcd60e51b815260206004820152600a6024820152694e6f207265776172647360b01b604482015260640161022c565b42609f6000611f576127a5565b6001600160a01b031681526020810191909152604001600090812080546001600160801b03938416600160801b02931692909217909155609f81611f996127a5565b6001600160a01b031681526020810191909152604001600020600190810191909155609b54611fd89190600160a81b90046001600160401b03166135eb565b609f6000611fe46127a5565b6001600160a01b03168152602081019190915260400160002080546001600160401b0392909216600160401b02600160401b600160801b03199092169190911790556120376120316127a5565b82612c82565b61203f6127a5565b6001600160a01b03167ffc30cddea38e2bf4d6ea7d3f9ed3b6ad7f176419f4963bd81318067a4aee73fe8260405161207991815260200190565b60405180910390a250565b6001600160a01b03163b151590565b600054610100900460ff166120ba5760405162461bcd60e51b815260040161022c906137b0565b60005b815181101561081c576001603760008484815181106120de576120de613692565b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff19169115159190911790556001016120bd565b600054610100900460ff1661213f5760405162461bcd60e51b815260040161022c906137b0565b612147612d1f565b6001600160a01b0381166121945760405162461bcd60e51b81526020600482015260146024820152730636f6c6c656374696f6e206164647265737320360641b604482015260640161022c565b609b80546001600160a01b0319166001600160a01b0392909216919091179055565b6000600180546121c59061370f565b80601f01602080910402602001604051908101604052809291908181526020018280546121f19061370f565b801561223e5780601f106122135761010080835404028352916020019161223e565b820191906000526020600020905b81548152906001019060200180831161222157829003601f168201915b505050505090508160019081612254919061384b565b507fc9c7c3fe08b88b4df9d4d47ef47d2c43d55c025a0ba88ca442580ed9e7348a168183604051610bb592919061390a565b6000609f60006122946127a5565b6001600160a01b0316815260208101919091526040016000908120546001600160401b039081169250839190821690036123075760405162461bcd60e51b81526020600482015260146024820152735769746864726177696e67203020746f6b656e7360601b604482015260640161022c565b806001600160401b031682101561235f5760405162461bcd60e51b815260206004820152601c60248201527b15da5d1a191c985dda5b99c81b5bdc99481d1a185b881cdd185ad95960221b604482015260640161022c565b609b546001600160a01b031661237661180a6127a5565b816001600160401b031683036124d5576000609d8054806020026020016040519081016040528092919081815260200182805480156123de57602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116123c0575b5050505050905060005b81518110156124d2576123f96127a5565b6001600160a01b031682828151811061241457612414613692565b60200260200101516001600160a01b0316036124ca5781600183516124399190613653565b8151811061244957612449613692565b6020026020010151609d828154811061246457612464613692565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550609d8054806124a3576124a3613938565b600082815260209020810160001990810180546001600160a01b03191690550190556124d2565b6001016123e8565b50505b81609f60006124e26127a5565b6001600160a01b031681526020810191909152604001600090812080549091906125169084906001600160401b03166135eb565b92506101000a8154816001600160401b0302191690836001600160401b0316021790555060005b826001600160401b03168110156126a1576125566127a5565b6001600160a01b031660a0600088888581811061257557612575613692565b60209081029290920135835250810191909152604001600020546001600160a01b0316146125d25760405162461bcd60e51b815260206004820152600a6024820152692737ba1039ba30b5b2b960b11b604482015260640161022c565b600060a060008888858181106125ea576125ea613692565b6020908102929092013583525081019190915260400160002080546001600160a01b0319166001600160a01b0392831617905582166342842e0e3061262d6127a5565b89898681811061263f5761263f613692565b905060200201356040518463ffffffff1660e01b815260040161266493929190613743565b600060405180830381600087803b15801561267e57600080fd5b505af1158015612692573d6000803e3d6000fd5b5050505080600101905061253d565b5084846040516126b2929190613787565b60405180910390206126c26127a5565b6001600160a01b03167f09ba0ae49142860d7eec1f3ce54722d70b60910facbe018cccb1099e4e84755c60405160405180910390a35050505050565b606061272383836040518060600160405280602781526020016139dc60279139612d4e565b9392505050565b6001600160a01b0381166000908152609f60205260408120546001600160401b0316810361277157506001600160a01b03166000908152609f602052604090206001015490565b61277a82612af4565b6001600160a01b0383166000908152609f60205260409020600101546107b29190613666565b919050565b6000611b9d611b93565b60006127ba82612af4565b6001600160a01b0383166000908152609f60205260408120600101805492935083929091906127ea908490613666565b90915550506001600160a01b0382166000908152609f6020526040902080546001600160801b03428116600160801b029116179055609b5461283f906001906001600160401b03600160a81b909104166135eb565b6001600160a01b039092166000908152609f6020526040902080546001600160401b0393909316600160401b02600160401b600160801b03199093169290921790915550565b600061289033610cb6565b156128a2575060131936013560601c90565b503390565b6000836001600160a01b03168360405160006040518083038185875af1925050503d80600081146128f4576040519150601f19603f3d011682016040523d82523d6000602084013e6128f9565b606091505b505090508061296c57816001600160a01b031663d0e30db0846040518263ffffffff1660e01b81526004016000604051808303818588803b15801561293d57600080fd5b505af1158015612951573d6000803e3d6000fd5b5061296c935050506001600160a01b03841690508585612dc6565b50505050565b816001600160a01b0316836001600160a01b0316031561296c57306001600160a01b038416036129b5576129b06001600160a01b0385168383612dc6565b61296c565b61296c6001600160a01b038516848484612e1c565b60008281526002602090815260408083206001600160a01b0385168085529252808320805460ff1916600117905551339285917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9190a45050565b600082815260046020526040812080549160019190612a448385613666565b9091555050600092835260046020908152604080852083865260018101835281862080546001600160a01b039096166001600160a01b03199096168617905593855260029093019052912055565b612a9c8282611e0d565b60008281526002602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6001600160a01b0381166000908152609f60209081526040808320815160808101835281546001600160401b038082168352600160401b82048116958301869052600160801b9091046001600160801b0316938201939093526001909101546060820152609b54909291600160a81b90910416815b81811015612c7957600081815260a16020908152604080832081516080810183528154815260018201549381019390935260028101549183019190915260030154606082015290848303612bca5785604001516001600160801b0316612bd0565b81604001515b905060008260600151600003612be65742612bec565b82606001515b9050600080612c2289600001516001600160401b03168585612c0e9190613653565b612c18919061394e565b8660200151612e3d565b91509150600080612c428c886000015185612c3d919061397b565b612e88565b91509150838015612c505750815b612c5a578b612c5c565b805b9b5050505050505050600181612c729190613666565b9050612b69565b50505050919050565b60d554811115612ccf5760405162461bcd60e51b81526020600482015260186024820152774e6f7420656e6f7567682072657761726420746f6b656e7360401b604482015260640161022c565b8060d56000828254612ce19190613653565b909155505060d45461081c906001600160a01b03163084847f00000000000000000000000081e609b897393731a3d23c1d311330340cebb9e9611ba2565b600054610100900460ff16612d465760405162461bcd60e51b815260040161022c906137b0565b610c8a612ea3565b6060600080856001600160a01b031685604051612d6b919061399d565b600060405180830381855af49150503d8060008114612da6576040519150601f19603f3d011682016040523d82523d6000602084013e612dab565b606091505b5091509150612dbc86838387612eca565b9695505050505050565b611e088363a9059cbb60e01b8484604051602401612de5929190613679565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612f49565b61296c846323b872dd60e01b858585604051602401612de593929190613743565b60008083600003612e545750600190506000612e81565b83830283858281612e6757612e67613965565b0414612e7a576000809250925050612e81565b6001925090505b9250929050565b60008083830184811015612e7a576000809250925050612e81565b600054610100900460ff16611b8c5760405162461bcd60e51b815260040161022c906137b0565b60608315612f37578251600003612f3057612ee485612084565b612f305760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161022c565b5081612f41565b612f41838361301b565b949350505050565b6000612f9e826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166130459092919063ffffffff16565b805190915015611e085780806020019051810190612fbc91906139b9565b611e085760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161022c565b81511561302b5781518083602001fd5b8060405162461bcd60e51b815260040161022c91906135c2565b6060612f41848460008585600080866001600160a01b0316858760405161306c919061399d565b60006040518083038185875af1925050503d80600081146130a9576040519150601f19603f3d011682016040523d82523d6000602084013e6130ae565b606091505b50915091506130bf87838387612eca565b979650505050505050565b6000602082840312156130dc57600080fd5b81356001600160e01b03198116811461272357600080fd5b60008083601f84011261310657600080fd5b5081356001600160401b0381111561311d57600080fd5b6020830191508360208260051b8501011115612e8157600080fd5b6000806020838503121561314b57600080fd5b82356001600160401b0381111561316157600080fd5b61316d858286016130f4565b90969095509350505050565b80356001600160a01b03811681146127a057600080fd5b6000806000806000608086880312156131a857600080fd5b6131b186613179565b94506131bf60208701613179565b93506040860135925060608601356001600160401b03808211156131e257600080fd5b818801915088601f8301126131f657600080fd5b81358181111561320557600080fd5b89602082850101111561321757600080fd5b9699959850939650602001949392505050565b60006020828403121561323c57600080fd5b5035919050565b6000806040838503121561325657600080fd5b8235915061326660208401613179565b90509250929050565b6001600160a01b0391909116815260200190565b60006020828403121561329557600080fd5b61272382613179565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b03811182821017156132dc576132dc61329e565b604052919050565b600082601f8301126132f557600080fd5b81356001600160401b0381111561330e5761330e61329e565b613321601f8201601f19166020016132b4565b81815284602083860101111561333657600080fd5b816020850160208301376000918101602001919091529392505050565b600080600080600080600060e0888a03121561336e57600080fd5b61337788613179565b96506020808901356001600160401b038082111561339457600080fd5b6133a08c838d016132e4565b985060408b01359150808211156133b657600080fd5b818b0191508b601f8301126133ca57600080fd5b8135818111156133dc576133dc61329e565b8060051b91506133ed8483016132b4565b818152918301840191848101908e84111561340757600080fd5b938501935b8385101561342c5761341d85613179565b8252938501939085019061340c565b809a5050505050505061344160608901613179565b935061344f60808901613179565b925060a0880135915060c0880135905092959891949750929550565b6000806040838503121561347e57600080fd5b50508035926020909101359150565b60006020828403121561349f57600080fd5b81356001600160401b038111156134b557600080fd5b612f41848285016132e4565b60005b838110156134dc5781810151838201526020016134c4565b50506000910152565b600081518084526134fd8160208601602086016134c1565b601f01601f19169290920160200192915050565b600060208083016020845280855180835260408601915060408160051b87010192506020870160005b8281101561356857603f198886030184526135568583516134e5565b9450928501929085019060010161353a565b5092979650505050505050565b604080825283519082018190526000906020906060840190828701845b828110156135ae57815184529284019290840190600101613592565b505050602093909301939093525092915050565b60208152600061272360208301846134e5565b634e487b7160e01b600052601160045260246000fd5b6001600160401b0382811682821603908082111561360b5761360b6135d5565b5092915050565b6020808252600e908201526d139bdd08185d5d1a1bdc9a5e995960921b604082015260600190565b60006020828403121561364c57600080fd5b5051919050565b818103818111156107b2576107b26135d5565b808201808211156107b2576107b26135d5565b6001600160a01b03929092168252602082015260400190565b634e487b7160e01b600052603260045260246000fd5b6000808335601e198436030181126136bf57600080fd5b8301803591506001600160401b038211156136d957600080fd5b602001915036819003821315612e8157600080fd5b8284823760609190911b6001600160601b0319169101908152601401919050565b600181811c9082168061372357607f821691505b60208210810361155257634e487b7160e01b600052602260045260246000fd5b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160401b0381811683821601908082111561360b5761360b6135d5565b60006001600160fb1b0383111561379d57600080fd5b8260051b80858437919091019392505050565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b601f821115611e08576000816000526020600020601f850160051c810160208610156138245750805b601f850160051c820191505b8181101561384357828155600101613830565b505050505050565b81516001600160401b038111156138645761386461329e565b61387881613872845461370f565b846137fb565b602080601f8311600181146138ad57600084156138955750858301515b600019600386901b1c1916600185901b178555613843565b600085815260208120601f198616915b828110156138dc578886015182559484019460019091019084016138bd565b50858210156138fa5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b60408152600061391d60408301856134e5565b828103602084015261392f81856134e5565b95945050505050565b634e487b7160e01b600052603160045260246000fd5b80820281158282048414176107b2576107b26135d5565b634e487b7160e01b600052601260045260246000fd5b60008261399857634e487b7160e01b600052601260045260246000fd5b500490565b600082516139af8184602087016134c1565b9190910192915050565b6000602082840312156139cb57600080fd5b8151801515811461272357600080fdfe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a264697066735822122018b857bb92bc5d65c474932dfb42c375ebdf98805e3ab20ee242c2748d82261b64736f6c63430008170033