Source Code
Overview
ETH Balance
0 ETH
ETH Value
$0.00| Transaction Hash |
|
Block
|
From
|
To
|
|||||
|---|---|---|---|---|---|---|---|---|---|
Latest 1 internal transaction
Advanced mode:
| Parent Transaction Hash | Block | From | To | |||
|---|---|---|---|---|---|---|
| 431062 | 691 days ago | Contract Creation | 0 ETH |
Cross-Chain Transactions
Loading...
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Contract Name:
NFTStake
Compiler Version
v0.8.23+commit.f704f362
Optimization Enabled:
Yes with 20 runs
Other Settings:
london EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// 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 {
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();
}
}// 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);
}// 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;
}// 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 {
/// @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("Not authorized");
}
_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);
}// 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;
}
}// 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 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("Can only grant to non holders");
}
_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("Can only renounce for self");
}
_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(
string(
abi.encodePacked(
"Permissions: account ",
Strings.toHexString(uint160(account), 20),
" is missing role ",
Strings.toHexString(uint256(role), 32)
)
)
);
}
}
/// @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(
string(
abi.encodePacked(
"Permissions: account ",
Strings.toHexString(uint160(account), 20),
" is missing role ",
Strings.toHexString(uint256(role), 32)
)
)
);
}
}
}// 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];
}
}// 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);
}// 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);
}// 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);
}// 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;
}// 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);
}// 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);
}// 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;
}// 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 "@openzeppelin/contracts/utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
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");
}
}
}// 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;
}
}
}// 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);
}// 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);
}
}
}// 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;
/// @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
require(_amount == msg.value, "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 }("");
require(success, "native token transfer failed");
}
/// @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);
}
}
}// 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.
}
}
}// 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;
}// 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;
}
}// 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;
}// 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);
}// 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);
}
}
}// 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;
}// 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;
}// 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);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
*
* Furthermore, `isContract` will also return true if the target contract within
* the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
* which only has an effect at the end of a transaction.
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
* the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
*
* _Available since v4.8._
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
// only check isContract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
/**
* @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason or using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}{
"optimizer": {
"enabled": true,
"runs": 20
},
"evmVersion": "london",
"remappings": [
":@chainlink/=lib/chainlink/",
":@ds-test/=lib/ds-test/src/",
":@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
":@openzeppelin/contracts/=lib/openzeppelin-contracts/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/",
":openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/",
":openzeppelin-contracts/=lib/openzeppelin-contracts/",
":openzeppelin/=lib/openzeppelin-contracts-upgradeable/contracts/",
":sstore2/=lib/dynamic-contracts/lib/sstore2/contracts/"
],
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"address","name":"_nativeTokenWrapper","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"prevURI","type":"string"},{"indexed":false,"internalType":"string","name":"newURI","type":"string"}],"name":"ContractURIUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"RewardTokensDepositedByAdmin","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"RewardTokensWithdrawnByAdmin","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"staker","type":"address"},{"indexed":false,"internalType":"uint256","name":"rewardAmount","type":"uint256"}],"name":"RewardsClaimed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"staker","type":"address"},{"indexed":true,"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"name":"TokensStaked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"staker","type":"address"},{"indexed":true,"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"name":"TokensWithdrawn","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldRewardsPerUnitTime","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newRewardsPerUnitTime","type":"uint256"}],"name":"UpdatedRewardsPerUnitTime","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldTimeUnit","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newTimeUnit","type":"uint256"}],"name":"UpdatedTimeUnit","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claimRewards","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"contractType","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"contractURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"contractVersion","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"depositRewardTokens","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"getRewardTokenBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getRewardsPerUnitTime","outputs":[{"internalType":"uint256","name":"_rewardsPerUnitTime","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getRoleMember","outputs":[{"internalType":"address","name":"member","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleMemberCount","outputs":[{"internalType":"uint256","name":"count","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_staker","type":"address"}],"name":"getStakeInfo","outputs":[{"internalType":"uint256[]","name":"_tokensStaked","type":"uint256[]"},{"internalType":"uint256","name":"_rewards","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTimeUnit","outputs":[{"internalType":"uint256","name":"_timeUnit","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRoleWithSwitch","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"indexedTokens","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_defaultAdmin","type":"address"},{"internalType":"string","name":"_contractURI","type":"string"},{"internalType":"address[]","name":"_trustedForwarders","type":"address[]"},{"internalType":"address","name":"_rewardToken","type":"address"},{"internalType":"address","name":"_stakingToken","type":"address"},{"internalType":"uint256","name":"_timeUnit","type":"uint256"},{"internalType":"uint256","name":"_rewardsPerUnitTime","type":"uint256"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"isIndexed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"forwarder","type":"address"}],"name":"isTrustedForwarder","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes[]","name":"data","type":"bytes[]"}],"name":"multicall","outputs":[{"internalType":"bytes[]","name":"results","type":"bytes[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC721Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"rewardToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"_uri","type":"string"}],"name":"setContractURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_rewardsPerUnitTime","type":"uint256"}],"name":"setRewardsPerUnitTime","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_timeUnit","type":"uint256"}],"name":"setTimeUnit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_tokenIds","type":"uint256[]"}],"name":"stake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"stakerAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"stakers","outputs":[{"internalType":"uint64","name":"amountStaked","type":"uint64"},{"internalType":"uint64","name":"conditionIdOflastUpdate","type":"uint64"},{"internalType":"uint128","name":"timeOfLastUpdate","type":"uint128"},{"internalType":"uint256","name":"unclaimedRewards","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"stakersArray","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"stakingToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_tokenIds","type":"uint256[]"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdrawRewardTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]Contract Creation Code
60a0604052609b805460ff60a01b1916600160a01b1790553480156200002457600080fd5b5060405162003eac38038062003eac83398101604081905262000047916200016c565b600054610100900460ff1615808015620000685750600054600160ff909116105b80620000845750303b15801562000084575060005460ff166001145b620000ec5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b606482015260840160405180910390fd5b6000805460ff19166001179055801562000110576000805461ff0019166101001790555b6001600160a01b038216608052801562000164576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50506200019e565b6000602082840312156200017f57600080fd5b81516001600160a01b03811681146200019757600080fd5b9392505050565b608051613cd6620001d6600039600081816101c3015281816108f0015281816109a0015281816116040152612f210152613cd66000f3fe6080604052600436106101b35760003560e01c8063938e3d7b116100e8578063938e3d7b1461052557806393ce534314610545578063940670451461055a578063961004d314610590578063983d95ce146105b0578063a0a8e460146105d0578063a217fddf146105ec578063a32fa5b314610601578063ac9650d814610621578063c34531531461064e578063ca15c8731461067c578063cb2ef6f71461069c578063cb43b2dd146106ba578063d547741f146106da578063d68124c7146106fa578063e8a3d4851461070f578063f7c618c114610731578063fd48ba171461075157600080fd5b806301ffc9a71461023c5780630e8b229b146102715780630fbf0a9314610294578063150b7a02146102b457806316c621e0146102ed57806323ef258014610300578063248a9ca3146103205780632f2ff15d1461034d57806336568abe1461036d578063372500ab1461038d5780635357e916146103a2578063572b6c05146103cf5780636360106f146103ef5780636a5ab6e51461040f57806372f702f31461042f5780639010d07c1461044f5780639168ae721461046f57806391d148541461050557600080fd5b3661023757336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146102355760405162461bcd60e51b815260206004820181905260248201527f63616c6c6572206e6f74206e617469766520746f6b656e20777261707065722e60448201526064015b60405180910390fd5b005b600080fd5b34801561024857600080fd5b5061025c6102573660046132fd565b610781565b60405190151581526020015b60405180910390f35b34801561027d57600080fd5b506102866107b8565b604051908152602001610268565b3480156102a057600080fd5b506102356102af36600461336b565b610800565b3480156102c057600080fd5b506102d46102cf3660046133c3565b610820565b6040516001600160e01b03199091168152602001610268565b6102356102fb36600461345d565b610883565b34801561030c57600080fd5b5061023561031b36600461345d565b610a9a565b34801561032c57600080fd5b5061028661033b36600461345d565b60009081526003602052604090205490565b34801561035957600080fd5b50610235610368366004613476565b610bc1565b34801561037957600080fd5b50610235610388366004613476565b610c57565b34801561039957600080fd5b50610235610cb6565b3480156103ae57600080fd5b506103c26103bd36600461345d565b610cd2565b60405161026891906134a2565b3480156103db57600080fd5b5061025c6103ea3660046134b6565b610cfc565b3480156103fb57600080fd5b5061023561040a36600461345d565b610d1a565b34801561041b57600080fd5b5061023561042a366004613586565b610e42565b34801561043b57600080fd5b50609b546103c2906001600160a01b031681565b34801561045b57600080fd5b506103c261046a36600461369e565b610fa4565b34801561047b57600080fd5b506104cc61048a3660046134b6565b609f60205260009081526040902080546001909101546001600160401b0380831692600160401b810490911691600160801b9091046001600160801b03169084565b604080516001600160401b0395861681529490931660208501526001600160801b03909116918301919091526060820152608001610268565b34801561051157600080fd5b5061025c610520366004613476565b611092565b34801561053157600080fd5b506102356105403660046136c0565b6110bd565b34801561055157600080fd5b5060d554610286565b34801561056657600080fd5b506103c261057536600461345d565b60a0602052600090815260409020546001600160a01b031681565b34801561059c57600080fd5b506102866105ab36600461345d565b6110ea565b3480156105bc57600080fd5b506102356105cb36600461336b565b61110b565b3480156105dc57600080fd5b5060405160018152602001610268565b3480156105f857600080fd5b50610286600081565b34801561060d57600080fd5b5061025c61061c366004613476565b61111d565b34801561062d57600080fd5b5061064161063c36600461336b565b611173565b6040516102689190613744565b34801561065a57600080fd5b5061066e6106693660046134b6565b6112e6565b6040516102689291906137a8565b34801561068857600080fd5b5061028661069736600461345d565b611514565b3480156106a857600080fd5b50674e46545374616b6560c01b610286565b3480156106c657600080fd5b506102356106d536600461345d565b61159d565b3480156106e657600080fd5b506102356106f5366004613476565b61165e565b34801561070657600080fd5b50610286611677565b34801561071b57600080fd5b506107246116bf565b60405161026891906137f5565b34801561073d57600080fd5b5060d4546103c2906001600160a01b031681565b34801561075d57600080fd5b5061025c61076c36600461345d565b609e6020526000908152604090205460ff1681565b60006001600160e01b03198216630a85bd0160e11b14806107b257506301ffc9a760e01b6001600160e01b03198316145b92915050565b600060a160006001609b60159054906101000a90046001600160401b03166107e0919061381e565b6001600160401b0316815260200190815260200160002060010154905090565b61080861174d565b61081282826117a6565b61081c6001606955565b5050565b609b54600090600160a01b900460ff166002146108715760405162461bcd60e51b815260206004820152600f60248201526e2234b932b1ba103a3930b739b332b960891b604482015260640161022c565b50630a85bd0160e11b95945050505050565b61088b61174d565b6108986000610520611bc9565b6108b45760405162461bcd60e51b815260040161022c90613845565b60d4546000906001600160a01b031673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee146108ee5760d4546001600160a01b0316610910565b7f00000000000000000000000000000000000000000000000000000000000000005b90506000816001600160a01b03166370a08231306040518263ffffffff1660e01b815260040161094091906134a2565b602060405180830381865afa15801561095d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610981919061386d565b60d4549091506109c4906001600160a01b031661099c611bc9565b30867f0000000000000000000000000000000000000000000000000000000000000000611bd8565b600081836001600160a01b03166370a08231306040518263ffffffff1660e01b81526004016109f391906134a2565b602060405180830381865afa158015610a10573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a34919061386d565b610a3e9190613886565b90508060d56000828254610a529190613899565b90915550506040518181527ff9d14e57815939d300bc94720ede00c8c8e08d254ab28e2917ea46e149aa119b9060200160405180910390a1505050610a976001606955565b50565b610aa2611d49565b610abe5760405162461bcd60e51b815260040161022c90613845565b600060a160006001609b60159054906101000a90046001600160401b0316610ae6919061381e565b6001600160401b031681526020808201929092526040908101600020815160808101835281548152600182015493810184905260028201549281019290925260030154606082015291508203610b725760405162461bcd60e51b81526020600482015260116024820152702932bbb0b932103ab731b430b733b2b21760791b604482015260640161022c565b8051610b7e9083611d57565b602080820151604080519182529181018490527f243c4656edc72b2c7ec8575d464d955b2f42c1b205960c6c2fb7eecda5419cf691015b60405180910390a15050565b600082815260036020526040902054610bda9033611e5f565b60008281526002602090815260408083206001600160a01b038516845290915290205460ff1615610c4d5760405162461bcd60e51b815260206004820152601d60248201527f43616e206f6e6c79206772616e7420746f206e6f6e20686f6c64657273000000604482015260640161022c565b61081c8282611edf565b336001600160a01b03821614610cac5760405162461bcd60e51b815260206004820152601a60248201527921b0b71037b7363c903932b737bab731b2903337b91039b2b63360311b604482015260640161022c565b61081c8282611ef3565b610cbe61174d565b610cc6611f4a565b610cd06001606955565b565b609d8181548110610ce257600080fd5b6000918252602090912001546001600160a01b0316905081565b6001600160a01b031660009081526037602052604090205460ff1690565b610d22611d49565b610d3e5760405162461bcd60e51b815260040161022c90613845565b600060a160006001609b60159054906101000a90046001600160401b0316610d66919061381e565b6001600160401b03168152602001908152602001600020604051806080016040529081600082015481526020016001820154815260200160028201548152602001600382015481525050905080600001518203610dfc5760405162461bcd60e51b81526020600482015260146024820152732a34b6b296bab734ba103ab731b430b733b2b21760611b604482015260640161022c565b610e0a828260200151611d57565b805160408051918252602082018490527fd968de290ed68f978b9e4816f7d4be9ef46189fe8eeb3eeb86199e7229cf2de09101610bb5565b600054610100900460ff1615808015610e625750600054600160ff909116105b80610e835750610e713061210f565b158015610e83575060005460ff166001145b610ee65760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b606482015260840161022c565b6000805460ff191660011790558015610f09576000805461ff0019166101001790555b610f128661211e565b60d480546001600160a01b0319166001600160a01b038716179055610f36846121a3565b610f408383611d57565b610f4987612241565b610f54600089611edf565b8015610f9a576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5050505050505050565b60008281526004602052604081205481805b828110156110895760008681526004602090815260408083208484526001019091529020546001600160a01b031615611032578482036110205760008681526004602090815260408083209383526001909301905220546001600160a01b031692506107b2915050565b61102b600183613899565b9150611077565b61103d866000611092565b80156110645750600086815260046020908152604080832083805260020190915290205481145b1561107757611074600183613899565b91505b611082600182613899565b9050610fb6565b50505092915050565b60009182526002602090815260408084206001600160a01b0393909316845291905290205460ff1690565b6110c5611d49565b6110e15760405162461bcd60e51b815260040161022c90613845565b610a9781612241565b609c81815481106110fa57600080fd5b600091825260209091200154905081565b61111361174d565b6108128282612311565b600082815260026020908152604080832083805290915281205460ff1661116a575060008281526002602090815260408083206001600160a01b038516845290915290205460ff166107b2565b50600192915050565b6060816001600160401b0381111561118d5761118d6134d1565b6040519080825280602002602001820160405280156111c057816020015b60608152602001906001900390816111ab5790505b50905060006111cd611bc9565b9050336001600160a01b038216141560005b8481101561108957811561125e5761123c30878784818110611203576112036138ac565b905060200281019061121591906138c2565b8660405160200161122893929190613908565b604051602081830303815290604052612789565b84828151811061124e5761124e6138ac565b60200260200101819052506112de565b6112c030878784818110611274576112746138ac565b905060200281019061128691906138c2565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061278992505050565b8482815181106112d2576112d26138ac565b60200260200101819052505b6001016111df565b6060600080609c80548060200260200160405190810160405280929190818152602001828054801561133757602002820191906000526020600020905b815481526020019060010190808311611323575b50505050509050600081516001600160401b03811115611359576113596134d1565b604051908082528060200260200182016040528015611382578160200160208202803683370190505b5082519091506000805b8281101561144157876001600160a01b031660a060008784815181106113b4576113b46138ac565b6020026020010151815260200190815260200160002060009054906101000a90046001600160a01b03166001600160a01b0316148482815181106113fa576113fa6138ac565b60200260200101901515908115158152505083818151811061141e5761141e6138ac565b60200260200101511561143957611436600183613899565b91505b60010161138c565b50806001600160401b0381111561145a5761145a6134d1565b604051908082528060200260200182016040528015611483578160200160208202803683370190505b5095506000805b838110156114fe578481815181106114a4576114a46138ac565b6020026020010151156114f6578581815181106114c3576114c36138ac565b60200260200101518883815181106114dd576114dd6138ac565b60209081029190910101526114f3600183613899565b91505b60010161148a565b50611508886127b5565b95505050505050915091565b600081815260046020526040812054815b818110156115785760008481526004602090815260408083208484526001019091529020546001600160a01b03161561156657611563600184613899565b92505b611571600182613899565b9050611525565b50611584836000611092565b1561159757611594600183613899565b91505b50919050565b6115aa6000610520611bc9565b6115c65760405162461bcd60e51b815260040161022c90613845565b60d55481116115e2578060d5546115dd9190613886565b6115e5565b60005b60d55560d454611628906001600160a01b031630611601611bc9565b847f0000000000000000000000000000000000000000000000000000000000000000611bd8565b6040518181527f37ff8766c704931c4283e470feb7c20ddcd8aa492746f74b30503709a0452acd9060200160405180910390a150565b600082815260036020526040902054610cac9033611e5f565b600060a160006001609b60159054906101000a90046001600160401b031661169f919061381e565b6001600160401b0316815260200190815260200160002060000154905090565b600180546116cc90613929565b80601f01602080910402602001604051908101604052809291908181526020018280546116f890613929565b80156117455780601f1061171a57610100808354040283529160200191611745565b820191906000526020600020905b81548152906001019060200180831161172857829003601f168201915b505050505081565b60026069540361179f5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640161022c565b6002606955565b806001600160401b0381166000036117f35760405162461bcd60e51b815260206004820152601060248201526f5374616b696e67203020746f6b656e7360801b604482015260640161022c565b609b546001600160a01b03166000609f8161180c612830565b6001600160a01b031681526020810191909152604001600020546001600160401b0316111561184a57611845611840612830565b61283a565b611934565b609d611854612830565b81546001810183556000928352602083200180546001600160a01b0319166001600160a01b03929092169190911790554290609f90611891612830565b6001600160a01b03168152602081019190915260400160002080546001600160801b03928316600160801b029216919091179055609b546118e5906001906001600160401b03600160a81b9091041661381e565b609f60006118f1612830565b6001600160a01b03168152602081019190915260400160002080546001600160401b0392909216600160401b02600160401b600160801b03199092169190911790555b60005b826001600160401b0316811015611b0157609b805460ff60a01b1916600160a11b1790556001600160a01b0382166342842e0e611972612830565b30888886818110611985576119856138ac565b905060200201356040518463ffffffff1660e01b81526004016119aa9392919061395d565b600060405180830381600087803b1580156119c457600080fd5b505af11580156119d8573d6000803e3d6000fd5b5050609b805460ff60a01b1916600160a01b179055506119f89050612830565b60a06000878785818110611a0e57611a0e6138ac565b90506020020135815260200190815260200160002060006101000a8154816001600160a01b0302191690836001600160a01b03160217905550609e6000868684818110611a5d57611a5d6138ac565b602090810292909201358352508101919091526040016000205460ff16611af9576001609e6000878785818110611a9657611a966138ac565b90506020020135815260200190815260200160002060006101000a81548160ff021916908315150217905550609c858583818110611ad657611ad66138ac565b835460018101855560009485526020948590209190940292909201359190920155505b600101611937565b5081609f6000611b0f612830565b6001600160a01b03168152602081019190915260400160009081208054909190611b439084906001600160401b0316613981565b92506101000a8154816001600160401b0302191690836001600160401b031602179055508383604051611b779291906139a1565b6040518091039020611b87612830565b6001600160a01b03167f540cd34f06460fd67aeca9d19e0a56cd3a7c1cde8dc2263f265b68b2ef3495d260405160405180910390a350505050565b6001606955565b6000611bd3612910565b905090565b8115611d425773eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeed196001600160a01b03861601611d3657306001600160a01b03851603611c7d57604051632e1a7d4d60e01b8152600481018390526001600160a01b03821690632e1a7d4d90602401600060405180830381600087803b158015611c5557600080fd5b505af1158015611c69573d6000803e3d6000fd5b50505050611c78838383612932565b611d42565b306001600160a01b03841603611d2b57348214611cd25760405162461bcd60e51b81526020600482015260136024820152721b5cd9cb9d985b1d5948084f48185b5bdd5b9d606a1b604482015260640161022c565b806001600160a01b031663d0e30db0836040518263ffffffff1660e01b81526004016000604051808303818588803b158015611d0d57600080fd5b505af1158015611d21573d6000803e3d6000fd5b5050505050611d42565b611c78838383612932565b611d42858585856129fd565b5050505050565b6000611bd381610520611bc9565b81600003611d9e5760405162461bcd60e51b8152602060048201526014602482015273074696d652d756e69742063616e277420626520360641b604482015260640161022c565b609b8054600160a81b90046001600160401b0316906001906015611dc28385613981565b82546001600160401b039182166101009390930a9283029190920219909116179055506040805160808101825284815260208082018581524283850190815260006060850181815287825260a190945294909420925183555160018301559151600282015590516003909101558015611e5a574260a16000611e45600185613886565b81526020810191909152604001600020600301555b505050565b60008281526002602090815260408083206001600160a01b038516845290915290205460ff1661081c57611e9d816001600160a01b03166014612a55565b611ea8836020612a55565b604051602001611eb99291906139ca565b60408051601f198184030181529082905262461bcd60e51b825261022c916004016137f5565b611ee98282612bf0565b61081c8282612c4b565b611efd8282612cb8565b60008281526004602090815260408083206001600160a01b03851680855260028201808552838620805487526001909301855292852080546001600160a01b031916905584529152555050565b6000611f5c611f57612830565b612d1a565b609f6000611f68612830565b6001600160a01b03166001600160a01b0316815260200190815260200160002060010154611f969190613899565b905080600003611fd55760405162461bcd60e51b815260206004820152600a6024820152694e6f207265776172647360b01b604482015260640161022c565b42609f6000611fe2612830565b6001600160a01b031681526020810191909152604001600090812080546001600160801b03938416600160801b02931692909217909155609f81612024612830565b6001600160a01b031681526020810191909152604001600020600190810191909155609b546120639190600160a81b90046001600160401b031661381e565b609f600061206f612830565b6001600160a01b03168152602081019190915260400160002080546001600160401b0392909216600160401b02600160401b600160801b03199092169190911790556120c26120bc612830565b82612ea8565b6120ca612830565b6001600160a01b03167ffc30cddea38e2bf4d6ea7d3f9ed3b6ad7f176419f4963bd81318067a4aee73fe8260405161210491815260200190565b60405180910390a250565b6001600160a01b03163b151590565b600054610100900460ff166121455760405162461bcd60e51b815260040161022c90613a37565b60005b815181101561081c57600160376000848481518110612169576121696138ac565b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff1916911515919091179055600101612148565b600054610100900460ff166121ca5760405162461bcd60e51b815260040161022c90613a37565b6121d2612f45565b6001600160a01b03811661221f5760405162461bcd60e51b81526020600482015260146024820152730636f6c6c656374696f6e206164647265737320360641b604482015260640161022c565b609b80546001600160a01b0319166001600160a01b0392909216919091179055565b60006001805461225090613929565b80601f016020809104026020016040519081016040528092919081815260200182805461227c90613929565b80156122c95780601f1061229e576101008083540402835291602001916122c9565b820191906000526020600020905b8154815290600101906020018083116122ac57829003601f168201915b5050505050905081600190816122df9190613ad2565b507fc9c7c3fe08b88b4df9d4d47ef47d2c43d55c025a0ba88ca442580ed9e7348a168183604051610bb5929190613b91565b6000609f600061231f612830565b6001600160a01b0316815260208101919091526040016000908120546001600160401b039081169250839190821690036123925760405162461bcd60e51b81526020600482015260146024820152735769746864726177696e67203020746f6b656e7360601b604482015260640161022c565b806001600160401b03168210156123ea5760405162461bcd60e51b815260206004820152601c60248201527b15da5d1a191c985dda5b99c81b5bdc99481d1a185b881cdd185ad95960221b604482015260640161022c565b609b546001600160a01b0316612401611840612830565b816001600160401b03168303612560576000609d80548060200260200160405190810160405280929190818152602001828054801561246957602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831161244b575b5050505050905060005b815181101561255d57612484612830565b6001600160a01b031682828151811061249f5761249f6138ac565b60200260200101516001600160a01b0316036125555781600183516124c49190613886565b815181106124d4576124d46138ac565b6020026020010151609d82815481106124ef576124ef6138ac565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550609d80548061252e5761252e613bbf565b600082815260209020810160001990810180546001600160a01b031916905501905561255d565b600101612473565b50505b81609f600061256d612830565b6001600160a01b031681526020810191909152604001600090812080549091906125a19084906001600160401b031661381e565b92506101000a8154816001600160401b0302191690836001600160401b0316021790555060005b826001600160401b031681101561272c576125e1612830565b6001600160a01b031660a06000888885818110612600576126006138ac565b60209081029290920135835250810191909152604001600020546001600160a01b03161461265d5760405162461bcd60e51b815260206004820152600a6024820152692737ba1039ba30b5b2b960b11b604482015260640161022c565b600060a06000888885818110612675576126756138ac565b6020908102929092013583525081019190915260400160002080546001600160a01b0319166001600160a01b0392831617905582166342842e0e306126b8612830565b8989868181106126ca576126ca6138ac565b905060200201356040518463ffffffff1660e01b81526004016126ef9392919061395d565b600060405180830381600087803b15801561270957600080fd5b505af115801561271d573d6000803e3d6000fd5b505050508060010190506125c8565b50848460405161273d9291906139a1565b604051809103902061274d612830565b6001600160a01b03167f09ba0ae49142860d7eec1f3ce54722d70b60910facbe018cccb1099e4e84755c60405160405180910390a35050505050565b60606127ae8383604051806060016040528060278152602001613c7a60279139612f74565b9392505050565b6001600160a01b0381166000908152609f60205260408120546001600160401b031681036127fc57506001600160a01b03166000908152609f602052604090206001015490565b61280582612d1a565b6001600160a01b0383166000908152609f60205260409020600101546107b29190613899565b919050565b6000611bd3611bc9565b600061284582612d1a565b6001600160a01b0383166000908152609f6020526040812060010180549293508392909190612875908490613899565b90915550506001600160a01b0382166000908152609f6020526040902080546001600160801b03428116600160801b029116179055609b546128ca906001906001600160401b03600160a81b9091041661381e565b6001600160a01b039092166000908152609f6020526040902080546001600160401b0393909316600160401b02600160401b600160801b03199093169290921790915550565b600061291b33610cfc565b1561292d575060131936013560601c90565b503390565b6000836001600160a01b03168360405160006040518083038185875af1925050503d806000811461297f576040519150601f19603f3d011682016040523d82523d6000602084013e612984565b606091505b50509050806129f757816001600160a01b031663d0e30db0846040518263ffffffff1660e01b81526004016000604051808303818588803b1580156129c857600080fd5b505af11580156129dc573d6000803e3d6000fd5b506129f7935050506001600160a01b03841690508585612fec565b50505050565b816001600160a01b0316836001600160a01b031603156129f757306001600160a01b03841603612a4057612a3b6001600160a01b0385168383612fec565b6129f7565b6129f76001600160a01b03851684848461304f565b60606000612a64836002613bd5565b612a6f906002613899565b6001600160401b03811115612a8657612a866134d1565b6040519080825280601f01601f191660200182016040528015612ab0576020820181803683370190505b509050600360fc1b81600081518110612acb57612acb6138ac565b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110612afa57612afa6138ac565b60200101906001600160f81b031916908160001a9053506000612b1e846002613bd5565b612b29906001613899565b90505b6001811115612ba1576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110612b5d57612b5d6138ac565b1a60f81b828281518110612b7357612b736138ac565b60200101906001600160f81b031916908160001a90535060049490941c93612b9a81613bec565b9050612b2c565b5083156127ae5760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e74604482015260640161022c565b60008281526002602090815260408083206001600160a01b0385168085529252808320805460ff1916600117905551339285917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9190a45050565b600082815260046020526040812080549160019190612c6a8385613899565b9091555050600092835260046020908152604080852083865260018101835281862080546001600160a01b039096166001600160a01b03199096168617905593855260029093019052912055565b612cc28282611e5f565b60008281526002602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6001600160a01b0381166000908152609f60209081526040808320815160808101835281546001600160401b038082168352600160401b82048116958301869052600160801b9091046001600160801b0316938201939093526001909101546060820152609b54909291600160a81b90910416815b81811015612e9f57600081815260a16020908152604080832081516080810183528154815260018201549381019390935260028101549183019190915260030154606082015290848303612df05785604001516001600160801b0316612df6565b81604001515b905060008260600151600003612e0c5742612e12565b82606001515b9050600080612e4889600001516001600160401b03168585612e349190613886565b612e3e9190613bd5565b8660200151613070565b91509150600080612e688c886000015185612e639190613c19565b6130bb565b91509150838015612e765750815b612e80578b612e82565b805b9b5050505050505050600181612e989190613899565b9050612d8f565b50505050919050565b60d554811115612ef55760405162461bcd60e51b81526020600482015260186024820152774e6f7420656e6f7567682072657761726420746f6b656e7360401b604482015260640161022c565b8060d56000828254612f079190613886565b909155505060d45461081c906001600160a01b03163084847f0000000000000000000000000000000000000000000000000000000000000000611bd8565b600054610100900460ff16612f6c5760405162461bcd60e51b815260040161022c90613a37565b610cd06130d6565b6060600080856001600160a01b031685604051612f919190613c3b565b600060405180830381855af49150503d8060008114612fcc576040519150601f19603f3d011682016040523d82523d6000602084013e612fd1565b606091505b5091509150612fe2868383876130fd565b9695505050505050565b6040516001600160a01b038316602482015260448101829052611e5a90849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261317c565b6129f7846323b872dd60e01b8585856040516024016130189392919061395d565b6000808360000361308757506001905060006130b4565b8383028385828161309a5761309a613c03565b04146130ad5760008092509250506130b4565b6001925090505b9250929050565b600080838301848110156130ad5760008092509250506130b4565b600054610100900460ff16611bc25760405162461bcd60e51b815260040161022c90613a37565b6060831561316a578251600003613163576131178561210f565b6131635760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161022c565b5081613174565b613174838361324e565b949350505050565b60006131d1826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166132789092919063ffffffff16565b805190915015611e5a57808060200190518101906131ef9190613c57565b611e5a5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161022c565b81511561325e5781518083602001fd5b8060405162461bcd60e51b815260040161022c91906137f5565b6060613174848460008585600080866001600160a01b0316858760405161329f9190613c3b565b60006040518083038185875af1925050503d80600081146132dc576040519150601f19603f3d011682016040523d82523d6000602084013e6132e1565b606091505b50915091506132f2878383876130fd565b979650505050505050565b60006020828403121561330f57600080fd5b81356001600160e01b0319811681146127ae57600080fd5b60008083601f84011261333957600080fd5b5081356001600160401b0381111561335057600080fd5b6020830191508360208260051b85010111156130b457600080fd5b6000806020838503121561337e57600080fd5b82356001600160401b0381111561339457600080fd5b6133a085828601613327565b90969095509350505050565b80356001600160a01b038116811461282b57600080fd5b6000806000806000608086880312156133db57600080fd5b6133e4866133ac565b94506133f2602087016133ac565b93506040860135925060608601356001600160401b038082111561341557600080fd5b818801915088601f83011261342957600080fd5b81358181111561343857600080fd5b89602082850101111561344a57600080fd5b9699959850939650602001949392505050565b60006020828403121561346f57600080fd5b5035919050565b6000806040838503121561348957600080fd5b82359150613499602084016133ac565b90509250929050565b6001600160a01b0391909116815260200190565b6000602082840312156134c857600080fd5b6127ae826133ac565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b038111828210171561350f5761350f6134d1565b604052919050565b600082601f83011261352857600080fd5b81356001600160401b03811115613541576135416134d1565b613554601f8201601f19166020016134e7565b81815284602083860101111561356957600080fd5b816020850160208301376000918101602001919091529392505050565b600080600080600080600060e0888a0312156135a157600080fd5b6135aa886133ac565b96506020808901356001600160401b03808211156135c757600080fd5b6135d38c838d01613517565b985060408b01359150808211156135e957600080fd5b818b0191508b601f8301126135fd57600080fd5b81358181111561360f5761360f6134d1565b8060051b91506136208483016134e7565b818152918301840191848101908e84111561363a57600080fd5b938501935b8385101561365f57613650856133ac565b8252938501939085019061363f565b809a50505050505050613674606089016133ac565b9350613682608089016133ac565b925060a0880135915060c0880135905092959891949750929550565b600080604083850312156136b157600080fd5b50508035926020909101359150565b6000602082840312156136d257600080fd5b81356001600160401b038111156136e857600080fd5b61317484828501613517565b60005b8381101561370f5781810151838201526020016136f7565b50506000910152565b600081518084526137308160208601602086016136f4565b601f01601f19169290920160200192915050565b600060208083016020845280855180835260408601915060408160051b87010192506020870160005b8281101561379b57603f19888603018452613789858351613718565b9450928501929085019060010161376d565b5092979650505050505050565b604080825283519082018190526000906020906060840190828701845b828110156137e1578151845292840192908401906001016137c5565b505050602093909301939093525092915050565b6020815260006127ae6020830184613718565b634e487b7160e01b600052601160045260246000fd5b6001600160401b0382811682821603908082111561383e5761383e613808565b5092915050565b6020808252600e908201526d139bdd08185d5d1a1bdc9a5e995960921b604082015260600190565b60006020828403121561387f57600080fd5b5051919050565b818103818111156107b2576107b2613808565b808201808211156107b2576107b2613808565b634e487b7160e01b600052603260045260246000fd5b6000808335601e198436030181126138d957600080fd5b8301803591506001600160401b038211156138f357600080fd5b6020019150368190038213156130b457600080fd5b8284823760609190911b6001600160601b0319169101908152601401919050565b600181811c9082168061393d57607f821691505b60208210810361159757634e487b7160e01b600052602260045260246000fd5b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160401b0381811683821601908082111561383e5761383e613808565b60006001600160fb1b038311156139b757600080fd5b8260051b80858437919091019392505050565b7402832b936b4b9b9b4b7b7399d1030b1b1b7bab73a1605d1b8152600083516139fa8160158501602088016136f4565b7001034b99036b4b9b9b4b733903937b6329607d1b6015918401918201528351613a2b8160268401602088016136f4565b01602601949350505050565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b601f821115611e5a576000816000526020600020601f850160051c81016020861015613aab5750805b601f850160051c820191505b81811015613aca57828155600101613ab7565b505050505050565b81516001600160401b03811115613aeb57613aeb6134d1565b613aff81613af98454613929565b84613a82565b602080601f831160018114613b345760008415613b1c5750858301515b600019600386901b1c1916600185901b178555613aca565b600085815260208120601f198616915b82811015613b6357888601518255948401946001909101908401613b44565b5085821015613b815787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b604081526000613ba46040830185613718565b8281036020840152613bb68185613718565b95945050505050565b634e487b7160e01b600052603160045260246000fd5b80820281158282048414176107b2576107b2613808565b600081613bfb57613bfb613808565b506000190190565b634e487b7160e01b600052601260045260246000fd5b600082613c3657634e487b7160e01b600052601260045260246000fd5b500490565b60008251613c4d8184602087016136f4565b9190910192915050565b600060208284031215613c6957600080fd5b815180151581146127ae57600080fdfe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212200cb939b9ce70f4a3eb2d950044e2c16fe44aecf5fa30ff90f0e351824d02dc2a64736f6c63430008170033000000000000000000000000d23e77b7e1726577006799b7194b6ae31958a839
Deployed Bytecode
0x6080604052600436106101b35760003560e01c8063938e3d7b116100e8578063938e3d7b1461052557806393ce534314610545578063940670451461055a578063961004d314610590578063983d95ce146105b0578063a0a8e460146105d0578063a217fddf146105ec578063a32fa5b314610601578063ac9650d814610621578063c34531531461064e578063ca15c8731461067c578063cb2ef6f71461069c578063cb43b2dd146106ba578063d547741f146106da578063d68124c7146106fa578063e8a3d4851461070f578063f7c618c114610731578063fd48ba171461075157600080fd5b806301ffc9a71461023c5780630e8b229b146102715780630fbf0a9314610294578063150b7a02146102b457806316c621e0146102ed57806323ef258014610300578063248a9ca3146103205780632f2ff15d1461034d57806336568abe1461036d578063372500ab1461038d5780635357e916146103a2578063572b6c05146103cf5780636360106f146103ef5780636a5ab6e51461040f57806372f702f31461042f5780639010d07c1461044f5780639168ae721461046f57806391d148541461050557600080fd5b3661023757336001600160a01b037f000000000000000000000000d23e77b7e1726577006799b7194b6ae31958a83916146102355760405162461bcd60e51b815260206004820181905260248201527f63616c6c6572206e6f74206e617469766520746f6b656e20777261707065722e60448201526064015b60405180910390fd5b005b600080fd5b34801561024857600080fd5b5061025c6102573660046132fd565b610781565b60405190151581526020015b60405180910390f35b34801561027d57600080fd5b506102866107b8565b604051908152602001610268565b3480156102a057600080fd5b506102356102af36600461336b565b610800565b3480156102c057600080fd5b506102d46102cf3660046133c3565b610820565b6040516001600160e01b03199091168152602001610268565b6102356102fb36600461345d565b610883565b34801561030c57600080fd5b5061023561031b36600461345d565b610a9a565b34801561032c57600080fd5b5061028661033b36600461345d565b60009081526003602052604090205490565b34801561035957600080fd5b50610235610368366004613476565b610bc1565b34801561037957600080fd5b50610235610388366004613476565b610c57565b34801561039957600080fd5b50610235610cb6565b3480156103ae57600080fd5b506103c26103bd36600461345d565b610cd2565b60405161026891906134a2565b3480156103db57600080fd5b5061025c6103ea3660046134b6565b610cfc565b3480156103fb57600080fd5b5061023561040a36600461345d565b610d1a565b34801561041b57600080fd5b5061023561042a366004613586565b610e42565b34801561043b57600080fd5b50609b546103c2906001600160a01b031681565b34801561045b57600080fd5b506103c261046a36600461369e565b610fa4565b34801561047b57600080fd5b506104cc61048a3660046134b6565b609f60205260009081526040902080546001909101546001600160401b0380831692600160401b810490911691600160801b9091046001600160801b03169084565b604080516001600160401b0395861681529490931660208501526001600160801b03909116918301919091526060820152608001610268565b34801561051157600080fd5b5061025c610520366004613476565b611092565b34801561053157600080fd5b506102356105403660046136c0565b6110bd565b34801561055157600080fd5b5060d554610286565b34801561056657600080fd5b506103c261057536600461345d565b60a0602052600090815260409020546001600160a01b031681565b34801561059c57600080fd5b506102866105ab36600461345d565b6110ea565b3480156105bc57600080fd5b506102356105cb36600461336b565b61110b565b3480156105dc57600080fd5b5060405160018152602001610268565b3480156105f857600080fd5b50610286600081565b34801561060d57600080fd5b5061025c61061c366004613476565b61111d565b34801561062d57600080fd5b5061064161063c36600461336b565b611173565b6040516102689190613744565b34801561065a57600080fd5b5061066e6106693660046134b6565b6112e6565b6040516102689291906137a8565b34801561068857600080fd5b5061028661069736600461345d565b611514565b3480156106a857600080fd5b50674e46545374616b6560c01b610286565b3480156106c657600080fd5b506102356106d536600461345d565b61159d565b3480156106e657600080fd5b506102356106f5366004613476565b61165e565b34801561070657600080fd5b50610286611677565b34801561071b57600080fd5b506107246116bf565b60405161026891906137f5565b34801561073d57600080fd5b5060d4546103c2906001600160a01b031681565b34801561075d57600080fd5b5061025c61076c36600461345d565b609e6020526000908152604090205460ff1681565b60006001600160e01b03198216630a85bd0160e11b14806107b257506301ffc9a760e01b6001600160e01b03198316145b92915050565b600060a160006001609b60159054906101000a90046001600160401b03166107e0919061381e565b6001600160401b0316815260200190815260200160002060010154905090565b61080861174d565b61081282826117a6565b61081c6001606955565b5050565b609b54600090600160a01b900460ff166002146108715760405162461bcd60e51b815260206004820152600f60248201526e2234b932b1ba103a3930b739b332b960891b604482015260640161022c565b50630a85bd0160e11b95945050505050565b61088b61174d565b6108986000610520611bc9565b6108b45760405162461bcd60e51b815260040161022c90613845565b60d4546000906001600160a01b031673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee146108ee5760d4546001600160a01b0316610910565b7f000000000000000000000000d23e77b7e1726577006799b7194b6ae31958a8395b90506000816001600160a01b03166370a08231306040518263ffffffff1660e01b815260040161094091906134a2565b602060405180830381865afa15801561095d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610981919061386d565b60d4549091506109c4906001600160a01b031661099c611bc9565b30867f000000000000000000000000d23e77b7e1726577006799b7194b6ae31958a839611bd8565b600081836001600160a01b03166370a08231306040518263ffffffff1660e01b81526004016109f391906134a2565b602060405180830381865afa158015610a10573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a34919061386d565b610a3e9190613886565b90508060d56000828254610a529190613899565b90915550506040518181527ff9d14e57815939d300bc94720ede00c8c8e08d254ab28e2917ea46e149aa119b9060200160405180910390a1505050610a976001606955565b50565b610aa2611d49565b610abe5760405162461bcd60e51b815260040161022c90613845565b600060a160006001609b60159054906101000a90046001600160401b0316610ae6919061381e565b6001600160401b031681526020808201929092526040908101600020815160808101835281548152600182015493810184905260028201549281019290925260030154606082015291508203610b725760405162461bcd60e51b81526020600482015260116024820152702932bbb0b932103ab731b430b733b2b21760791b604482015260640161022c565b8051610b7e9083611d57565b602080820151604080519182529181018490527f243c4656edc72b2c7ec8575d464d955b2f42c1b205960c6c2fb7eecda5419cf691015b60405180910390a15050565b600082815260036020526040902054610bda9033611e5f565b60008281526002602090815260408083206001600160a01b038516845290915290205460ff1615610c4d5760405162461bcd60e51b815260206004820152601d60248201527f43616e206f6e6c79206772616e7420746f206e6f6e20686f6c64657273000000604482015260640161022c565b61081c8282611edf565b336001600160a01b03821614610cac5760405162461bcd60e51b815260206004820152601a60248201527921b0b71037b7363c903932b737bab731b2903337b91039b2b63360311b604482015260640161022c565b61081c8282611ef3565b610cbe61174d565b610cc6611f4a565b610cd06001606955565b565b609d8181548110610ce257600080fd5b6000918252602090912001546001600160a01b0316905081565b6001600160a01b031660009081526037602052604090205460ff1690565b610d22611d49565b610d3e5760405162461bcd60e51b815260040161022c90613845565b600060a160006001609b60159054906101000a90046001600160401b0316610d66919061381e565b6001600160401b03168152602001908152602001600020604051806080016040529081600082015481526020016001820154815260200160028201548152602001600382015481525050905080600001518203610dfc5760405162461bcd60e51b81526020600482015260146024820152732a34b6b296bab734ba103ab731b430b733b2b21760611b604482015260640161022c565b610e0a828260200151611d57565b805160408051918252602082018490527fd968de290ed68f978b9e4816f7d4be9ef46189fe8eeb3eeb86199e7229cf2de09101610bb5565b600054610100900460ff1615808015610e625750600054600160ff909116105b80610e835750610e713061210f565b158015610e83575060005460ff166001145b610ee65760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b606482015260840161022c565b6000805460ff191660011790558015610f09576000805461ff0019166101001790555b610f128661211e565b60d480546001600160a01b0319166001600160a01b038716179055610f36846121a3565b610f408383611d57565b610f4987612241565b610f54600089611edf565b8015610f9a576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5050505050505050565b60008281526004602052604081205481805b828110156110895760008681526004602090815260408083208484526001019091529020546001600160a01b031615611032578482036110205760008681526004602090815260408083209383526001909301905220546001600160a01b031692506107b2915050565b61102b600183613899565b9150611077565b61103d866000611092565b80156110645750600086815260046020908152604080832083805260020190915290205481145b1561107757611074600183613899565b91505b611082600182613899565b9050610fb6565b50505092915050565b60009182526002602090815260408084206001600160a01b0393909316845291905290205460ff1690565b6110c5611d49565b6110e15760405162461bcd60e51b815260040161022c90613845565b610a9781612241565b609c81815481106110fa57600080fd5b600091825260209091200154905081565b61111361174d565b6108128282612311565b600082815260026020908152604080832083805290915281205460ff1661116a575060008281526002602090815260408083206001600160a01b038516845290915290205460ff166107b2565b50600192915050565b6060816001600160401b0381111561118d5761118d6134d1565b6040519080825280602002602001820160405280156111c057816020015b60608152602001906001900390816111ab5790505b50905060006111cd611bc9565b9050336001600160a01b038216141560005b8481101561108957811561125e5761123c30878784818110611203576112036138ac565b905060200281019061121591906138c2565b8660405160200161122893929190613908565b604051602081830303815290604052612789565b84828151811061124e5761124e6138ac565b60200260200101819052506112de565b6112c030878784818110611274576112746138ac565b905060200281019061128691906138c2565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061278992505050565b8482815181106112d2576112d26138ac565b60200260200101819052505b6001016111df565b6060600080609c80548060200260200160405190810160405280929190818152602001828054801561133757602002820191906000526020600020905b815481526020019060010190808311611323575b50505050509050600081516001600160401b03811115611359576113596134d1565b604051908082528060200260200182016040528015611382578160200160208202803683370190505b5082519091506000805b8281101561144157876001600160a01b031660a060008784815181106113b4576113b46138ac565b6020026020010151815260200190815260200160002060009054906101000a90046001600160a01b03166001600160a01b0316148482815181106113fa576113fa6138ac565b60200260200101901515908115158152505083818151811061141e5761141e6138ac565b60200260200101511561143957611436600183613899565b91505b60010161138c565b50806001600160401b0381111561145a5761145a6134d1565b604051908082528060200260200182016040528015611483578160200160208202803683370190505b5095506000805b838110156114fe578481815181106114a4576114a46138ac565b6020026020010151156114f6578581815181106114c3576114c36138ac565b60200260200101518883815181106114dd576114dd6138ac565b60209081029190910101526114f3600183613899565b91505b60010161148a565b50611508886127b5565b95505050505050915091565b600081815260046020526040812054815b818110156115785760008481526004602090815260408083208484526001019091529020546001600160a01b03161561156657611563600184613899565b92505b611571600182613899565b9050611525565b50611584836000611092565b1561159757611594600183613899565b91505b50919050565b6115aa6000610520611bc9565b6115c65760405162461bcd60e51b815260040161022c90613845565b60d55481116115e2578060d5546115dd9190613886565b6115e5565b60005b60d55560d454611628906001600160a01b031630611601611bc9565b847f000000000000000000000000d23e77b7e1726577006799b7194b6ae31958a839611bd8565b6040518181527f37ff8766c704931c4283e470feb7c20ddcd8aa492746f74b30503709a0452acd9060200160405180910390a150565b600082815260036020526040902054610cac9033611e5f565b600060a160006001609b60159054906101000a90046001600160401b031661169f919061381e565b6001600160401b0316815260200190815260200160002060000154905090565b600180546116cc90613929565b80601f01602080910402602001604051908101604052809291908181526020018280546116f890613929565b80156117455780601f1061171a57610100808354040283529160200191611745565b820191906000526020600020905b81548152906001019060200180831161172857829003601f168201915b505050505081565b60026069540361179f5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640161022c565b6002606955565b806001600160401b0381166000036117f35760405162461bcd60e51b815260206004820152601060248201526f5374616b696e67203020746f6b656e7360801b604482015260640161022c565b609b546001600160a01b03166000609f8161180c612830565b6001600160a01b031681526020810191909152604001600020546001600160401b0316111561184a57611845611840612830565b61283a565b611934565b609d611854612830565b81546001810183556000928352602083200180546001600160a01b0319166001600160a01b03929092169190911790554290609f90611891612830565b6001600160a01b03168152602081019190915260400160002080546001600160801b03928316600160801b029216919091179055609b546118e5906001906001600160401b03600160a81b9091041661381e565b609f60006118f1612830565b6001600160a01b03168152602081019190915260400160002080546001600160401b0392909216600160401b02600160401b600160801b03199092169190911790555b60005b826001600160401b0316811015611b0157609b805460ff60a01b1916600160a11b1790556001600160a01b0382166342842e0e611972612830565b30888886818110611985576119856138ac565b905060200201356040518463ffffffff1660e01b81526004016119aa9392919061395d565b600060405180830381600087803b1580156119c457600080fd5b505af11580156119d8573d6000803e3d6000fd5b5050609b805460ff60a01b1916600160a01b179055506119f89050612830565b60a06000878785818110611a0e57611a0e6138ac565b90506020020135815260200190815260200160002060006101000a8154816001600160a01b0302191690836001600160a01b03160217905550609e6000868684818110611a5d57611a5d6138ac565b602090810292909201358352508101919091526040016000205460ff16611af9576001609e6000878785818110611a9657611a966138ac565b90506020020135815260200190815260200160002060006101000a81548160ff021916908315150217905550609c858583818110611ad657611ad66138ac565b835460018101855560009485526020948590209190940292909201359190920155505b600101611937565b5081609f6000611b0f612830565b6001600160a01b03168152602081019190915260400160009081208054909190611b439084906001600160401b0316613981565b92506101000a8154816001600160401b0302191690836001600160401b031602179055508383604051611b779291906139a1565b6040518091039020611b87612830565b6001600160a01b03167f540cd34f06460fd67aeca9d19e0a56cd3a7c1cde8dc2263f265b68b2ef3495d260405160405180910390a350505050565b6001606955565b6000611bd3612910565b905090565b8115611d425773eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeed196001600160a01b03861601611d3657306001600160a01b03851603611c7d57604051632e1a7d4d60e01b8152600481018390526001600160a01b03821690632e1a7d4d90602401600060405180830381600087803b158015611c5557600080fd5b505af1158015611c69573d6000803e3d6000fd5b50505050611c78838383612932565b611d42565b306001600160a01b03841603611d2b57348214611cd25760405162461bcd60e51b81526020600482015260136024820152721b5cd9cb9d985b1d5948084f48185b5bdd5b9d606a1b604482015260640161022c565b806001600160a01b031663d0e30db0836040518263ffffffff1660e01b81526004016000604051808303818588803b158015611d0d57600080fd5b505af1158015611d21573d6000803e3d6000fd5b5050505050611d42565b611c78838383612932565b611d42858585856129fd565b5050505050565b6000611bd381610520611bc9565b81600003611d9e5760405162461bcd60e51b8152602060048201526014602482015273074696d652d756e69742063616e277420626520360641b604482015260640161022c565b609b8054600160a81b90046001600160401b0316906001906015611dc28385613981565b82546001600160401b039182166101009390930a9283029190920219909116179055506040805160808101825284815260208082018581524283850190815260006060850181815287825260a190945294909420925183555160018301559151600282015590516003909101558015611e5a574260a16000611e45600185613886565b81526020810191909152604001600020600301555b505050565b60008281526002602090815260408083206001600160a01b038516845290915290205460ff1661081c57611e9d816001600160a01b03166014612a55565b611ea8836020612a55565b604051602001611eb99291906139ca565b60408051601f198184030181529082905262461bcd60e51b825261022c916004016137f5565b611ee98282612bf0565b61081c8282612c4b565b611efd8282612cb8565b60008281526004602090815260408083206001600160a01b03851680855260028201808552838620805487526001909301855292852080546001600160a01b031916905584529152555050565b6000611f5c611f57612830565b612d1a565b609f6000611f68612830565b6001600160a01b03166001600160a01b0316815260200190815260200160002060010154611f969190613899565b905080600003611fd55760405162461bcd60e51b815260206004820152600a6024820152694e6f207265776172647360b01b604482015260640161022c565b42609f6000611fe2612830565b6001600160a01b031681526020810191909152604001600090812080546001600160801b03938416600160801b02931692909217909155609f81612024612830565b6001600160a01b031681526020810191909152604001600020600190810191909155609b546120639190600160a81b90046001600160401b031661381e565b609f600061206f612830565b6001600160a01b03168152602081019190915260400160002080546001600160401b0392909216600160401b02600160401b600160801b03199092169190911790556120c26120bc612830565b82612ea8565b6120ca612830565b6001600160a01b03167ffc30cddea38e2bf4d6ea7d3f9ed3b6ad7f176419f4963bd81318067a4aee73fe8260405161210491815260200190565b60405180910390a250565b6001600160a01b03163b151590565b600054610100900460ff166121455760405162461bcd60e51b815260040161022c90613a37565b60005b815181101561081c57600160376000848481518110612169576121696138ac565b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff1916911515919091179055600101612148565b600054610100900460ff166121ca5760405162461bcd60e51b815260040161022c90613a37565b6121d2612f45565b6001600160a01b03811661221f5760405162461bcd60e51b81526020600482015260146024820152730636f6c6c656374696f6e206164647265737320360641b604482015260640161022c565b609b80546001600160a01b0319166001600160a01b0392909216919091179055565b60006001805461225090613929565b80601f016020809104026020016040519081016040528092919081815260200182805461227c90613929565b80156122c95780601f1061229e576101008083540402835291602001916122c9565b820191906000526020600020905b8154815290600101906020018083116122ac57829003601f168201915b5050505050905081600190816122df9190613ad2565b507fc9c7c3fe08b88b4df9d4d47ef47d2c43d55c025a0ba88ca442580ed9e7348a168183604051610bb5929190613b91565b6000609f600061231f612830565b6001600160a01b0316815260208101919091526040016000908120546001600160401b039081169250839190821690036123925760405162461bcd60e51b81526020600482015260146024820152735769746864726177696e67203020746f6b656e7360601b604482015260640161022c565b806001600160401b03168210156123ea5760405162461bcd60e51b815260206004820152601c60248201527b15da5d1a191c985dda5b99c81b5bdc99481d1a185b881cdd185ad95960221b604482015260640161022c565b609b546001600160a01b0316612401611840612830565b816001600160401b03168303612560576000609d80548060200260200160405190810160405280929190818152602001828054801561246957602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831161244b575b5050505050905060005b815181101561255d57612484612830565b6001600160a01b031682828151811061249f5761249f6138ac565b60200260200101516001600160a01b0316036125555781600183516124c49190613886565b815181106124d4576124d46138ac565b6020026020010151609d82815481106124ef576124ef6138ac565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550609d80548061252e5761252e613bbf565b600082815260209020810160001990810180546001600160a01b031916905501905561255d565b600101612473565b50505b81609f600061256d612830565b6001600160a01b031681526020810191909152604001600090812080549091906125a19084906001600160401b031661381e565b92506101000a8154816001600160401b0302191690836001600160401b0316021790555060005b826001600160401b031681101561272c576125e1612830565b6001600160a01b031660a06000888885818110612600576126006138ac565b60209081029290920135835250810191909152604001600020546001600160a01b03161461265d5760405162461bcd60e51b815260206004820152600a6024820152692737ba1039ba30b5b2b960b11b604482015260640161022c565b600060a06000888885818110612675576126756138ac565b6020908102929092013583525081019190915260400160002080546001600160a01b0319166001600160a01b0392831617905582166342842e0e306126b8612830565b8989868181106126ca576126ca6138ac565b905060200201356040518463ffffffff1660e01b81526004016126ef9392919061395d565b600060405180830381600087803b15801561270957600080fd5b505af115801561271d573d6000803e3d6000fd5b505050508060010190506125c8565b50848460405161273d9291906139a1565b604051809103902061274d612830565b6001600160a01b03167f09ba0ae49142860d7eec1f3ce54722d70b60910facbe018cccb1099e4e84755c60405160405180910390a35050505050565b60606127ae8383604051806060016040528060278152602001613c7a60279139612f74565b9392505050565b6001600160a01b0381166000908152609f60205260408120546001600160401b031681036127fc57506001600160a01b03166000908152609f602052604090206001015490565b61280582612d1a565b6001600160a01b0383166000908152609f60205260409020600101546107b29190613899565b919050565b6000611bd3611bc9565b600061284582612d1a565b6001600160a01b0383166000908152609f6020526040812060010180549293508392909190612875908490613899565b90915550506001600160a01b0382166000908152609f6020526040902080546001600160801b03428116600160801b029116179055609b546128ca906001906001600160401b03600160a81b9091041661381e565b6001600160a01b039092166000908152609f6020526040902080546001600160401b0393909316600160401b02600160401b600160801b03199093169290921790915550565b600061291b33610cfc565b1561292d575060131936013560601c90565b503390565b6000836001600160a01b03168360405160006040518083038185875af1925050503d806000811461297f576040519150601f19603f3d011682016040523d82523d6000602084013e612984565b606091505b50509050806129f757816001600160a01b031663d0e30db0846040518263ffffffff1660e01b81526004016000604051808303818588803b1580156129c857600080fd5b505af11580156129dc573d6000803e3d6000fd5b506129f7935050506001600160a01b03841690508585612fec565b50505050565b816001600160a01b0316836001600160a01b031603156129f757306001600160a01b03841603612a4057612a3b6001600160a01b0385168383612fec565b6129f7565b6129f76001600160a01b03851684848461304f565b60606000612a64836002613bd5565b612a6f906002613899565b6001600160401b03811115612a8657612a866134d1565b6040519080825280601f01601f191660200182016040528015612ab0576020820181803683370190505b509050600360fc1b81600081518110612acb57612acb6138ac565b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110612afa57612afa6138ac565b60200101906001600160f81b031916908160001a9053506000612b1e846002613bd5565b612b29906001613899565b90505b6001811115612ba1576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110612b5d57612b5d6138ac565b1a60f81b828281518110612b7357612b736138ac565b60200101906001600160f81b031916908160001a90535060049490941c93612b9a81613bec565b9050612b2c565b5083156127ae5760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e74604482015260640161022c565b60008281526002602090815260408083206001600160a01b0385168085529252808320805460ff1916600117905551339285917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9190a45050565b600082815260046020526040812080549160019190612c6a8385613899565b9091555050600092835260046020908152604080852083865260018101835281862080546001600160a01b039096166001600160a01b03199096168617905593855260029093019052912055565b612cc28282611e5f565b60008281526002602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6001600160a01b0381166000908152609f60209081526040808320815160808101835281546001600160401b038082168352600160401b82048116958301869052600160801b9091046001600160801b0316938201939093526001909101546060820152609b54909291600160a81b90910416815b81811015612e9f57600081815260a16020908152604080832081516080810183528154815260018201549381019390935260028101549183019190915260030154606082015290848303612df05785604001516001600160801b0316612df6565b81604001515b905060008260600151600003612e0c5742612e12565b82606001515b9050600080612e4889600001516001600160401b03168585612e349190613886565b612e3e9190613bd5565b8660200151613070565b91509150600080612e688c886000015185612e639190613c19565b6130bb565b91509150838015612e765750815b612e80578b612e82565b805b9b5050505050505050600181612e989190613899565b9050612d8f565b50505050919050565b60d554811115612ef55760405162461bcd60e51b81526020600482015260186024820152774e6f7420656e6f7567682072657761726420746f6b656e7360401b604482015260640161022c565b8060d56000828254612f079190613886565b909155505060d45461081c906001600160a01b03163084847f000000000000000000000000d23e77b7e1726577006799b7194b6ae31958a839611bd8565b600054610100900460ff16612f6c5760405162461bcd60e51b815260040161022c90613a37565b610cd06130d6565b6060600080856001600160a01b031685604051612f919190613c3b565b600060405180830381855af49150503d8060008114612fcc576040519150601f19603f3d011682016040523d82523d6000602084013e612fd1565b606091505b5091509150612fe2868383876130fd565b9695505050505050565b6040516001600160a01b038316602482015260448101829052611e5a90849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261317c565b6129f7846323b872dd60e01b8585856040516024016130189392919061395d565b6000808360000361308757506001905060006130b4565b8383028385828161309a5761309a613c03565b04146130ad5760008092509250506130b4565b6001925090505b9250929050565b600080838301848110156130ad5760008092509250506130b4565b600054610100900460ff16611bc25760405162461bcd60e51b815260040161022c90613a37565b6060831561316a578251600003613163576131178561210f565b6131635760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161022c565b5081613174565b613174838361324e565b949350505050565b60006131d1826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166132789092919063ffffffff16565b805190915015611e5a57808060200190518101906131ef9190613c57565b611e5a5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161022c565b81511561325e5781518083602001fd5b8060405162461bcd60e51b815260040161022c91906137f5565b6060613174848460008585600080866001600160a01b0316858760405161329f9190613c3b565b60006040518083038185875af1925050503d80600081146132dc576040519150601f19603f3d011682016040523d82523d6000602084013e6132e1565b606091505b50915091506132f2878383876130fd565b979650505050505050565b60006020828403121561330f57600080fd5b81356001600160e01b0319811681146127ae57600080fd5b60008083601f84011261333957600080fd5b5081356001600160401b0381111561335057600080fd5b6020830191508360208260051b85010111156130b457600080fd5b6000806020838503121561337e57600080fd5b82356001600160401b0381111561339457600080fd5b6133a085828601613327565b90969095509350505050565b80356001600160a01b038116811461282b57600080fd5b6000806000806000608086880312156133db57600080fd5b6133e4866133ac565b94506133f2602087016133ac565b93506040860135925060608601356001600160401b038082111561341557600080fd5b818801915088601f83011261342957600080fd5b81358181111561343857600080fd5b89602082850101111561344a57600080fd5b9699959850939650602001949392505050565b60006020828403121561346f57600080fd5b5035919050565b6000806040838503121561348957600080fd5b82359150613499602084016133ac565b90509250929050565b6001600160a01b0391909116815260200190565b6000602082840312156134c857600080fd5b6127ae826133ac565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b038111828210171561350f5761350f6134d1565b604052919050565b600082601f83011261352857600080fd5b81356001600160401b03811115613541576135416134d1565b613554601f8201601f19166020016134e7565b81815284602083860101111561356957600080fd5b816020850160208301376000918101602001919091529392505050565b600080600080600080600060e0888a0312156135a157600080fd5b6135aa886133ac565b96506020808901356001600160401b03808211156135c757600080fd5b6135d38c838d01613517565b985060408b01359150808211156135e957600080fd5b818b0191508b601f8301126135fd57600080fd5b81358181111561360f5761360f6134d1565b8060051b91506136208483016134e7565b818152918301840191848101908e84111561363a57600080fd5b938501935b8385101561365f57613650856133ac565b8252938501939085019061363f565b809a50505050505050613674606089016133ac565b9350613682608089016133ac565b925060a0880135915060c0880135905092959891949750929550565b600080604083850312156136b157600080fd5b50508035926020909101359150565b6000602082840312156136d257600080fd5b81356001600160401b038111156136e857600080fd5b61317484828501613517565b60005b8381101561370f5781810151838201526020016136f7565b50506000910152565b600081518084526137308160208601602086016136f4565b601f01601f19169290920160200192915050565b600060208083016020845280855180835260408601915060408160051b87010192506020870160005b8281101561379b57603f19888603018452613789858351613718565b9450928501929085019060010161376d565b5092979650505050505050565b604080825283519082018190526000906020906060840190828701845b828110156137e1578151845292840192908401906001016137c5565b505050602093909301939093525092915050565b6020815260006127ae6020830184613718565b634e487b7160e01b600052601160045260246000fd5b6001600160401b0382811682821603908082111561383e5761383e613808565b5092915050565b6020808252600e908201526d139bdd08185d5d1a1bdc9a5e995960921b604082015260600190565b60006020828403121561387f57600080fd5b5051919050565b818103818111156107b2576107b2613808565b808201808211156107b2576107b2613808565b634e487b7160e01b600052603260045260246000fd5b6000808335601e198436030181126138d957600080fd5b8301803591506001600160401b038211156138f357600080fd5b6020019150368190038213156130b457600080fd5b8284823760609190911b6001600160601b0319169101908152601401919050565b600181811c9082168061393d57607f821691505b60208210810361159757634e487b7160e01b600052602260045260246000fd5b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160401b0381811683821601908082111561383e5761383e613808565b60006001600160fb1b038311156139b757600080fd5b8260051b80858437919091019392505050565b7402832b936b4b9b9b4b7b7399d1030b1b1b7bab73a1605d1b8152600083516139fa8160158501602088016136f4565b7001034b99036b4b9b9b4b733903937b6329607d1b6015918401918201528351613a2b8160268401602088016136f4565b01602601949350505050565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b601f821115611e5a576000816000526020600020601f850160051c81016020861015613aab5750805b601f850160051c820191505b81811015613aca57828155600101613ab7565b505050505050565b81516001600160401b03811115613aeb57613aeb6134d1565b613aff81613af98454613929565b84613a82565b602080601f831160018114613b345760008415613b1c5750858301515b600019600386901b1c1916600185901b178555613aca565b600085815260208120601f198616915b82811015613b6357888601518255948401946001909101908401613b44565b5085821015613b815787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b604081526000613ba46040830185613718565b8281036020840152613bb68185613718565b95945050505050565b634e487b7160e01b600052603160045260246000fd5b80820281158282048414176107b2576107b2613808565b600081613bfb57613bfb613808565b506000190190565b634e487b7160e01b600052601260045260246000fd5b600082613c3657634e487b7160e01b600052601260045260246000fd5b500490565b60008251613c4d8184602087016136f4565b9190910192915050565b600060208284031215613c6957600080fd5b815180151581146127ae57600080fdfe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212200cb939b9ce70f4a3eb2d950044e2c16fe44aecf5fa30ff90f0e351824d02dc2a64736f6c63430008170033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000d23e77b7e1726577006799b7194b6ae31958a839
-----Decoded View---------------
Arg [0] : _nativeTokenWrapper (address): 0xD23e77b7e1726577006799B7194b6Ae31958a839
-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 000000000000000000000000d23e77b7e1726577006799b7194b6ae31958a839
Loading...
Loading
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in ETH
0
Multichain Portfolio | 35 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.