Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
- Contract name:
- TokenStake
- Optimization enabled
- true
- Compiler version
- v0.8.23+commit.f704f362
- Optimization runs
- 20
- EVM Version
- london
- Verified at
- 2024-05-21T18:33:59.429757Z
Constructor Arguments
0x000000000000000000000000d23e77b7e1726577006799b7194b6ae31958a839
Arg [0] (address) : 0xd23e77b7e1726577006799b7194b6ae31958a839
contracts/prebuilts/staking/TokenStake.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.11; /// @author thirdweb // $$\ $$\ $$\ $$\ $$\ // $$ | $$ | \__| $$ | $$ | // $$$$$$\ $$$$$$$\ $$\ $$$$$$\ $$$$$$$ |$$\ $$\ $$\ $$$$$$\ $$$$$$$\ // \_$$ _| $$ __$$\ $$ |$$ __$$\ $$ __$$ |$$ | $$ | $$ |$$ __$$\ $$ __$$\ // $$ | $$ | $$ |$$ |$$ | \__|$$ / $$ |$$ | $$ | $$ |$$$$$$$$ |$$ | $$ | // $$ |$$\ $$ | $$ |$$ |$$ | $$ | $$ |$$ | $$ | $$ |$$ ____|$$ | $$ | // \$$$$ |$$ | $$ |$$ |$$ | \$$$$$$$ |\$$$$$\$$$$ |\$$$$$$$\ $$$$$$$ | // \____/ \__| \__|\__|\__| \_______| \_____\____/ \_______|\_______/ // Token import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; // Meta transactions import "../../external-deps/openzeppelin/metatx/ERC2771ContextUpgradeable.sol"; // Utils import "../../extension/Multicall.sol"; import { CurrencyTransferLib } from "../../lib/CurrencyTransferLib.sol"; import "../../eip/interface/IERC20Metadata.sol"; // ========== Features ========== import "../../extension/ContractMetadata.sol"; import "../../extension/PermissionsEnumerable.sol"; import { Staking20Upgradeable } from "../../extension/Staking20Upgradeable.sol"; import "../interface/staking/ITokenStake.sol"; contract TokenStake is Initializable, ContractMetadata, PermissionsEnumerable, ERC2771ContextUpgradeable, Multicall, Staking20Upgradeable, ITokenStake { bytes32 private constant MODULE_TYPE = bytes32("TokenStake"); uint256 private constant VERSION = 1; /// @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 Staking20Upgradeable(_nativeTokenWrapper) {} /// @dev Initializes the contract, like a constructor. function initialize( address _defaultAdmin, string memory _contractURI, address[] memory _trustedForwarders, address _rewardToken, address _stakingToken, uint80 _timeUnit, uint256 _rewardRatioNumerator, uint256 _rewardRatioDenominator ) external initializer { __ERC2771Context_init_unchained(_trustedForwarders); require(_rewardToken != _stakingToken, "Reward Token and Staking Token can't be same."); rewardToken = _rewardToken; uint16 _stakingTokenDecimals = _stakingToken == CurrencyTransferLib.NATIVE_TOKEN ? 18 : IERC20Metadata(_stakingToken).decimals(); uint16 _rewardTokenDecimals = _rewardToken == CurrencyTransferLib.NATIVE_TOKEN ? 18 : IERC20Metadata(_rewardToken).decimals(); __Staking20_init(_stakingToken, _stakingTokenDecimals, _rewardTokenDecimals); _setStakingCondition(_timeUnit, _rewardRatioNumerator, _rewardRatioDenominator); _setupContractURI(_contractURI); _setupRole(DEFAULT_ADMIN_ROLE, _defaultAdmin); } /// @dev Returns the module type of the contract. function contractType() external pure virtual returns (bytes32) { return MODULE_TYPE; } /// @dev Returns the version of the contract. function contractVersion() external pure virtual returns (uint8) { return uint8(VERSION); } /// @dev Lets the contract receive ether to unwrap native tokens. receive() external payable { require(msg.sender == nativeTokenWrapper, "caller not native token wrapper."); } /// @dev Admin deposits reward tokens. function depositRewardTokens(uint256 _amount) external payable nonReentrant { require(hasRole(DEFAULT_ADMIN_ROLE, _msgSender()), "Not authorized"); address _rewardToken = rewardToken == CurrencyTransferLib.NATIVE_TOKEN ? nativeTokenWrapper : rewardToken; uint256 balanceBefore = IERC20(_rewardToken).balanceOf(address(this)); CurrencyTransferLib.transferCurrencyWithWrapper( rewardToken, _msgSender(), address(this), _amount, nativeTokenWrapper ); uint256 actualAmount = IERC20(_rewardToken).balanceOf(address(this)) - balanceBefore; rewardTokenBalance += actualAmount; emit RewardTokensDepositedByAdmin(actualAmount); } /// @dev Admin can withdraw excess reward tokens. function withdrawRewardTokens(uint256 _amount) external nonReentrant { require(hasRole(DEFAULT_ADMIN_ROLE, _msgSender()), "Not authorized"); // to prevent locking of direct-transferred tokens rewardTokenBalance = _amount > rewardTokenBalance ? 0 : rewardTokenBalance - _amount; CurrencyTransferLib.transferCurrencyWithWrapper( rewardToken, address(this), _msgSender(), _amount, nativeTokenWrapper ); // The withdrawal shouldn't reduce staking token balance. `>=` accounts for any accidental transfers. address _stakingToken = stakingToken == CurrencyTransferLib.NATIVE_TOKEN ? nativeTokenWrapper : stakingToken; require( IERC20(_stakingToken).balanceOf(address(this)) >= stakingTokenBalance, "Staking token balance reduced." ); emit RewardTokensWithdrawnByAdmin(_amount); } /// @notice View total rewards available in the staking contract. function getRewardTokenBalance() external view override returns (uint256) { return rewardTokenBalance; } /*/////////////////////////////////////////////////////////////// Transfer Staking Rewards //////////////////////////////////////////////////////////////*/ /// @dev Mint/Transfer ERC20 rewards to the staker. function _mintRewards(address _staker, uint256 _rewards) internal override { require(_rewards <= rewardTokenBalance, "Not enough reward tokens"); rewardTokenBalance -= _rewards; CurrencyTransferLib.transferCurrencyWithWrapper( rewardToken, address(this), _staker, _rewards, nativeTokenWrapper ); } /*/////////////////////////////////////////////////////////////// Internal functions //////////////////////////////////////////////////////////////*/ /// @dev Returns whether staking related restrictions can be set in the given execution context. function _canSetStakeConditions() internal view override returns (bool) { return hasRole(DEFAULT_ADMIN_ROLE, _msgSender()); } /// @dev Checks whether contract metadata can be set in the given execution context. function _canSetContractURI() internal view override returns (bool) { return hasRole(DEFAULT_ADMIN_ROLE, _msgSender()); } /*/////////////////////////////////////////////////////////////// Miscellaneous //////////////////////////////////////////////////////////////*/ function _stakeMsgSender() internal view virtual override returns (address) { return _msgSender(); } function _msgSender() internal view virtual override(ERC2771ContextUpgradeable, Multicall) returns (address sender) { return ERC2771ContextUpgradeable._msgSender(); } }
contracts/eip/interface/IERC20Metadata.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; /** * @title ERC20Metadata interface * @dev see https://github.com/ethereum/EIPs/issues/20 */ interface IERC20Metadata { function name() external view returns (string memory); function symbol() external view returns (string memory); function decimals() external view returns (uint8); }
contracts/extension/interface/IMulticall.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @author thirdweb /** * @dev Provides a function to batch together multiple calls in a single external call. * * _Available since v4.1._ */ interface IMulticall { /** * @dev Receives and executes a batch of function calls on this contract. */ function multicall(bytes[] calldata data) external returns (bytes[] memory results); }
contracts/eip/interface/IERC20.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; /** * @title ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/20 */ interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address who) external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); function transfer(address to, uint256 value) external returns (bool); function approve(address spender, uint256 value) external returns (bool); function transferFrom(address from, address to, uint256 value) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); }
contracts/extension/ContractMetadata.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; /// @author thirdweb import "./interface/IContractMetadata.sol"; /** * @title Contract Metadata * @notice Thirdweb's `ContractMetadata` is a contract extension for any base contracts. It lets you set a metadata URI * for you contract. * Additionally, `ContractMetadata` is necessary for NFT contracts that want royalties to get distributed on OpenSea. */ abstract contract ContractMetadata is IContractMetadata { /// @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); }
contracts/extension/Multicall.sol
// SPDX-License-Identifier: Apache 2.0 pragma solidity ^0.8.0; /// @author thirdweb import "../lib/Address.sol"; import "./interface/IMulticall.sol"; /** * @dev Provides a function to batch together multiple calls in a single external call. * * _Available since v4.1._ */ contract Multicall is IMulticall { /** * @notice Receives and executes a batch of function calls on this contract. * @dev Receives and executes a batch of function calls on this contract. * * @param data The bytes data that makes up the batch of function calls to execute. * @return results The bytes data that makes up the result of the batch of function calls executed. */ function multicall(bytes[] calldata data) external returns (bytes[] memory results) { results = new bytes[](data.length); address sender = _msgSender(); bool isForwarder = msg.sender != sender; for (uint256 i = 0; i < data.length; i++) { if (isForwarder) { results[i] = Address.functionDelegateCall(address(this), abi.encodePacked(data[i], sender)); } else { results[i] = Address.functionDelegateCall(address(this), data[i]); } } return results; } /// @notice Returns the sender in the given execution context. function _msgSender() internal view virtual returns (address) { return msg.sender; } }
contracts/extension/Permissions.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; /// @author thirdweb import "./interface/IPermissions.sol"; import "../lib/Strings.sol"; /** * @title Permissions * @dev This contracts provides extending-contracts with role-based access control mechanisms */ contract Permissions is IPermissions { /// @dev 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) ) ) ); } } }
contracts/extension/PermissionsEnumerable.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; /// @author thirdweb import "./interface/IPermissionsEnumerable.sol"; import "./Permissions.sol"; /** * @title PermissionsEnumerable * @dev This contracts provides extending-contracts with role-based access control mechanisms. * Also provides interfaces to view all members with a given role, and total count of members. */ contract PermissionsEnumerable is IPermissionsEnumerable, Permissions { /** * @notice A data structure to store data of members for a given role. * * @param index Current index in the list of accounts that have a role. * @param members map from index => address of account that has a role * @param indexOf map from address => index which the account has. */ struct RoleMembers { uint256 index; mapping(uint256 => address) members; mapping(address => uint256) indexOf; } /// @dev map from keccak256 hash of a role to its members' data. See {RoleMembers}. mapping(bytes32 => RoleMembers) private roleMembers; /** * @notice Returns the role-member from a list of members for a role, * at a given index. * @dev Returns `member` who has `role`, at `index` of role-members list. * See struct {RoleMembers}, and mapping {roleMembers} * * @param role keccak256 hash of the role. e.g. keccak256("TRANSFER_ROLE") * @param index Index in list of current members for the role. * * @return member Address of account that has `role` */ function getRoleMember(bytes32 role, uint256 index) external view override returns (address member) { uint256 currentIndex = roleMembers[role].index; uint256 check; for (uint256 i = 0; i < currentIndex; i += 1) { if (roleMembers[role].members[i] != address(0)) { if (check == index) { member = roleMembers[role].members[i]; return member; } check += 1; } else if (hasRole(role, address(0)) && i == roleMembers[role].indexOf[address(0)]) { check += 1; } } } /** * @notice Returns total number of accounts that have a role. * @dev Returns `count` of accounts that have `role`. * See struct {RoleMembers}, and mapping {roleMembers} * * @param role keccak256 hash of the role. e.g. keccak256("TRANSFER_ROLE") * * @return count Total number of accounts that have `role` */ function getRoleMemberCount(bytes32 role) external view override returns (uint256 count) { uint256 currentIndex = roleMembers[role].index; for (uint256 i = 0; i < currentIndex; i += 1) { if (roleMembers[role].members[i] != address(0)) { count += 1; } } if (hasRole(role, address(0))) { count += 1; } } /// @dev Revokes `role` from `account`, and removes `account` from {roleMembers} /// See {_removeMember} function _revokeRole(bytes32 role, address account) internal override { super._revokeRole(role, account); _removeMember(role, account); } /// @dev Grants `role` to `account`, and adds `account` to {roleMembers} /// See {_addMember} function _setupRole(bytes32 role, address account) internal override { super._setupRole(role, account); _addMember(role, account); } /// @dev adds `account` to {roleMembers}, for `role` function _addMember(bytes32 role, address account) internal { uint256 idx = roleMembers[role].index; roleMembers[role].index += 1; roleMembers[role].members[idx] = account; roleMembers[role].indexOf[account] = idx; } /// @dev removes `account` from {roleMembers}, for `role` function _removeMember(bytes32 role, address account) internal { uint256 idx = roleMembers[role].indexOf[account]; delete roleMembers[role].members[idx]; delete roleMembers[role].indexOf[account]; } }
contracts/extension/Staking20Upgradeable.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.11; /// @author thirdweb import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol"; import "../external-deps/openzeppelin/utils/math/SafeMath.sol"; import "../eip/interface/IERC20.sol"; import { CurrencyTransferLib } from "../lib/CurrencyTransferLib.sol"; import "./interface/IStaking20.sol"; abstract contract Staking20Upgradeable is ReentrancyGuardUpgradeable, IStaking20 { /*/////////////////////////////////////////////////////////////// State variables / Mappings //////////////////////////////////////////////////////////////*/ /// @dev The address of the native token wrapper contract. address internal immutable nativeTokenWrapper; ///@dev Address of ERC20 contract -- staked tokens belong to this contract. address public stakingToken; /// @dev Decimals of staking token. uint16 public stakingTokenDecimals; /// @dev Decimals of reward token. uint16 public rewardTokenDecimals; ///@dev Next staking condition Id. Tracks number of conditon updates so far. uint64 private nextConditionId; /// @dev Total amount of tokens staked in the contract. uint256 public stakingTokenBalance; /// @dev List of accounts that have staked that token-id. address[] public stakersArray; ///@dev Mapping staker address to Staker struct. See {struct IStaking20.Staker}. mapping(address => Staker) public stakers; ///@dev Mapping from condition Id to staking condition. See {struct IStaking721.StakingCondition} mapping(uint256 => StakingCondition) private stakingConditions; constructor(address _nativeTokenWrapper) { require(_nativeTokenWrapper != address(0), "address 0"); nativeTokenWrapper = _nativeTokenWrapper; } function __Staking20_init( address _stakingToken, uint16 _stakingTokenDecimals, uint16 _rewardTokenDecimals ) internal onlyInitializing { __ReentrancyGuard_init(); require(address(_stakingToken) != address(0), "token address 0"); require(_stakingTokenDecimals != 0 && _rewardTokenDecimals != 0, "decimals 0"); stakingToken = _stakingToken; stakingTokenDecimals = _stakingTokenDecimals; rewardTokenDecimals = _rewardTokenDecimals; } /*/////////////////////////////////////////////////////////////// External/Public Functions //////////////////////////////////////////////////////////////*/ /** * @notice Stake ERC20 Tokens. * * @dev See {_stake}. Override that to implement custom logic. * * @param _amount Amount to stake. */ function stake(uint256 _amount) external payable nonReentrant { _stake(_amount); } /** * @notice Withdraw staked ERC20 tokens. * * @dev See {_withdraw}. Override that to implement custom logic. * * @param _amount Amount to withdraw. */ function withdraw(uint256 _amount) external nonReentrant { _withdraw(_amount); } /** * @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(uint80 _timeUnit) external virtual { if (!_canSetStakeConditions()) { revert("Not authorized"); } StakingCondition memory condition = stakingConditions[nextConditionId - 1]; require(_timeUnit != condition.timeUnit, "Time-unit unchanged."); _setStakingCondition(_timeUnit, condition.rewardRatioNumerator, condition.rewardRatioDenominator); emit UpdatedTimeUnit(condition.timeUnit, _timeUnit); } /** * @notice Set rewards per unit of time. * Interpreted as (numerator/denominator) rewards per second/per day/etc based on time-unit. * * For e.g., ratio of 1/20 would mean 1 reward token for every 20 tokens staked. * * @dev Only admin/authorized-account can call it. * * @param _numerator Reward ratio numerator. * @param _denominator Reward ratio denominator. */ function setRewardRatio(uint256 _numerator, uint256 _denominator) external virtual { if (!_canSetStakeConditions()) { revert("Not authorized"); } StakingCondition memory condition = stakingConditions[nextConditionId - 1]; require( _numerator != condition.rewardRatioNumerator || _denominator != condition.rewardRatioDenominator, "Reward ratio unchanged." ); _setStakingCondition(condition.timeUnit, _numerator, _denominator); emit UpdatedRewardRatio( condition.rewardRatioNumerator, _numerator, condition.rewardRatioDenominator, _denominator ); } /** * @notice View amount staked and rewards for a user. * * @param _staker Address for which to calculated rewards. * @return _tokensStaked Amount of tokens staked. * @return _rewards Available reward amount. */ function getStakeInfo(address _staker) external view virtual returns (uint256 _tokensStaked, uint256 _rewards) { _tokensStaked = stakers[_staker].amountStaked; _rewards = _availableRewards(_staker); } function getTimeUnit() public view returns (uint80 _timeUnit) { _timeUnit = stakingConditions[nextConditionId - 1].timeUnit; } function getRewardRatio() public view returns (uint256 _numerator, uint256 _denominator) { _numerator = stakingConditions[nextConditionId - 1].rewardRatioNumerator; _denominator = stakingConditions[nextConditionId - 1].rewardRatioDenominator; } /*/////////////////////////////////////////////////////////////// Internal Functions //////////////////////////////////////////////////////////////*/ /// @dev Staking logic. Override to add custom logic. function _stake(uint256 _amount) internal virtual { require(_amount != 0, "Staking 0 tokens"); address _stakingToken; if (stakingToken == CurrencyTransferLib.NATIVE_TOKEN) { _stakingToken = nativeTokenWrapper; } else { require(msg.value == 0, "Value not 0"); _stakingToken = stakingToken; } if (stakers[_stakeMsgSender()].amountStaked > 0) { _updateUnclaimedRewardsForStaker(_stakeMsgSender()); } else { stakersArray.push(_stakeMsgSender()); stakers[_stakeMsgSender()].timeOfLastUpdate = uint80(block.timestamp); stakers[_stakeMsgSender()].conditionIdOflastUpdate = nextConditionId - 1; } uint256 balanceBefore = IERC20(_stakingToken).balanceOf(address(this)); CurrencyTransferLib.transferCurrencyWithWrapper( stakingToken, _stakeMsgSender(), address(this), _amount, nativeTokenWrapper ); uint256 actualAmount = IERC20(_stakingToken).balanceOf(address(this)) - balanceBefore; stakers[_stakeMsgSender()].amountStaked += actualAmount; stakingTokenBalance += actualAmount; emit TokensStaked(_stakeMsgSender(), actualAmount); } /// @dev Withdraw logic. Override to add custom logic. function _withdraw(uint256 _amount) internal virtual { uint256 _amountStaked = stakers[_stakeMsgSender()].amountStaked; require(_amount != 0, "Withdrawing 0 tokens"); require(_amountStaked >= _amount, "Withdrawing more than staked"); _updateUnclaimedRewardsForStaker(_stakeMsgSender()); if (_amountStaked == _amount) { 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 -= _amount; stakingTokenBalance -= _amount; CurrencyTransferLib.transferCurrencyWithWrapper( stakingToken, address(this), _stakeMsgSender(), _amount, nativeTokenWrapper ); emit TokensWithdrawn(_stakeMsgSender(), _amount); } /// @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 = uint80(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 _staker) internal view virtual returns (uint256 _rewards) { if (stakers[_staker].amountStaked == 0) { _rewards = stakers[_staker].unclaimedRewards; } else { _rewards = stakers[_staker].unclaimedRewards + _calculateRewards(_staker); } } /// @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 = uint80(block.timestamp); stakers[_staker].conditionIdOflastUpdate = nextConditionId - 1; } /// @dev Set staking conditions. function _setStakingCondition(uint80 _timeUnit, uint256 _numerator, uint256 _denominator) internal virtual { require(_denominator != 0, "divide by 0"); require(_timeUnit != 0, "time-unit can't be 0"); uint256 conditionId = nextConditionId; nextConditionId += 1; stakingConditions[conditionId] = StakingCondition({ timeUnit: _timeUnit, rewardRatioNumerator: _numerator, rewardRatioDenominator: _denominator, startTimestamp: uint80(block.timestamp), endTimestamp: 0 }); if (conditionId > 0) { stakingConditions[conditionId - 1].endTimestamp = uint80(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.rewardRatioNumerator ); (bool noOverflowSum, uint256 rewardsSum) = SafeMath.tryAdd( _rewards, (rewardsProduct / condition.timeUnit) / condition.rewardRatioDenominator ); _rewards = noOverflowProduct && noOverflowSum ? rewardsSum : _rewards; } (, _rewards) = SafeMath.tryMul(_rewards, 10 ** rewardTokenDecimals); _rewards /= (10 ** stakingTokenDecimals); } /*//////////////////////////////////////////////////////////////////// Optional hooks that can be implemented in the derived contract ///////////////////////////////////////////////////////////////////*/ /// @dev Exposes the ability to override the msg sender -- support ERC2771. function _stakeMsgSender() internal virtual returns (address) { return msg.sender; } /*/////////////////////////////////////////////////////////////// Virtual functions to be implemented in derived contract //////////////////////////////////////////////////////////////*/ /** * @notice View total rewards available in the staking contract. * */ function getRewardTokenBalance() external view virtual returns (uint256 _rewardsAvailableInContract); /** * @dev Mint/Transfer ERC20 rewards to the staker. Must override. * * @param _staker Address for which to calculated rewards. * @param _rewards Amount of tokens to be given out as reward. * * For example, override as below to mint ERC20 rewards: * * ``` * function _mintRewards(address _staker, uint256 _rewards) internal override { * * TokenERC20(rewardTokenAddress).mintTo(_staker, _rewards); * * } * ``` */ function _mintRewards(address _staker, uint256 _rewards) internal virtual; /** * @dev Returns whether staking restrictions can be set in given execution context. * Must override. * * * For example, override as below to restrict access to admin: * * ``` * function _canSetStakeConditions() internal override { * * return msg.sender == adminAddress; * * } * ``` */ function _canSetStakeConditions() internal view virtual returns (bool); }
contracts/extension/interface/IContractMetadata.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; /// @author thirdweb /** * Thirdweb's `ContractMetadata` is a contract extension for any base contracts. It lets you set a metadata URI * for you contract. * * Additionally, `ContractMetadata` is necessary for NFT contracts that want royalties to get distributed on OpenSea. */ interface IContractMetadata { /// @dev Returns the metadata URI of the contract. function contractURI() external view returns (string memory); /** * @dev Sets contract URI for the storefront-level metadata of the contract. * Only module admin can call this function. */ function setContractURI(string calldata _uri) external; /// @dev Emitted when the contract URI is updated. event ContractURIUpdated(string prevURI, string newURI); }
contracts/extension/interface/IPermissions.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; /// @author thirdweb /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IPermissions { /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {AccessControl-_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) external view returns (bool); /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {AccessControl-_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) external view returns (bytes32); /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) external; /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) external; /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) external; }
contracts/extension/interface/IPermissionsEnumerable.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; /// @author thirdweb import "./IPermissions.sol"; /** * @dev External interface of AccessControlEnumerable declared to support ERC165 detection. */ interface IPermissionsEnumerable is IPermissions { /** * @dev Returns one of the accounts that have `role`. `index` must be a * value between 0 and {getRoleMemberCount}, non-inclusive. * * Role bearers are not sorted in any particular way, and their ordering may * change at any point. * * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure * you perform all queries on the same block. See the following * [forum post](https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296) * for more information. */ function getRoleMember(bytes32 role, uint256 index) external view returns (address); /** * @dev Returns the number of accounts that have `role`. Can be used * together with {getRoleMember} to enumerate all bearers of a role. */ function getRoleMemberCount(bytes32 role) external view returns (uint256); }
contracts/extension/interface/IStaking20.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.11; /// @author thirdweb interface IStaking20 { /// @dev Emitted when tokens are staked. event TokensStaked(address indexed staker, uint256 amount); /// @dev Emitted when a tokens are withdrawn. event TokensWithdrawn(address indexed staker, uint256 amount); /// @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 UpdatedRewardRatio( uint256 oldNumerator, uint256 newNumerator, uint256 oldDenominator, uint256 newDenominator ); /// @dev Emitted when contract admin updates minimum staking amount. event UpdatedMinStakeAmount(uint256 oldAmount, uint256 newAmount); /** * @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 { uint128 timeOfLastUpdate; uint64 conditionIdOflastUpdate; uint256 amountStaked; 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 rewardRatioNumerator Rewards ratio is the number of reward tokens for a number of staked tokens, * per unit of time. * * @param rewardRatioDenominator Rewards ratio is the number of reward tokens for a number of staked tokens, * per unit of time. * * @param startTimestamp Condition start timestamp. * * @param endTimestamp Condition end timestamp. */ struct StakingCondition { uint80 timeUnit; uint80 startTimestamp; uint80 endTimestamp; uint256 rewardRatioNumerator; uint256 rewardRatioDenominator; } /** * @notice Stake ERC721 Tokens. * * @param amount Amount to stake. */ function stake(uint256 amount) external payable; /** * @notice Withdraw staked tokens. * * @param amount Amount to withdraw. */ function withdraw(uint256 amount) 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 _tokensStaked, uint256 _rewards); }
contracts/external-deps/openzeppelin/metatx/ERC2771ContextUpgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (metatx/ERC2771Context.sol) pragma solidity ^0.8.11; import "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; /** * @dev Context variant with ERC2771 support. */ abstract contract ERC2771ContextUpgradeable is Initializable, ContextUpgradeable { mapping(address => bool) private _trustedForwarder; function __ERC2771Context_init(address[] memory trustedForwarder) internal onlyInitializing { __Context_init_unchained(); __ERC2771Context_init_unchained(trustedForwarder); } function __ERC2771Context_init_unchained(address[] memory trustedForwarder) internal onlyInitializing { for (uint256 i = 0; i < trustedForwarder.length; i++) { _trustedForwarder[trustedForwarder[i]] = true; } } function isTrustedForwarder(address forwarder) public view virtual returns (bool) { return _trustedForwarder[forwarder]; } function _msgSender() internal view virtual override returns (address sender) { if (isTrustedForwarder(msg.sender)) { // The assembly code is more direct than the Solidity version using `abi.decode`. assembly { sender := shr(96, calldataload(sub(calldatasize(), 20))) } } else { return super._msgSender(); } } function _msgData() internal view virtual override returns (bytes calldata) { if (isTrustedForwarder(msg.sender)) { return msg.data[:msg.data.length - 20]; } else { return super._msgData(); } } uint256[49] private __gap; }
contracts/external-deps/openzeppelin/token/ERC20/utils/SafeERC20.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "../../../../../eip/interface/IERC20.sol"; import { Address } from "@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"); } } }
contracts/external-deps/openzeppelin/utils/math/SafeMath.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (utils/math/SafeMath.sol) pragma solidity ^0.8.0; // CAUTION // This version of SafeMath should only be used with Solidity 0.8 or later, // because it relies on the compiler's built in overflow checks. /** * @dev Wrappers over Solidity's arithmetic operations. * * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler * now has built in overflow checking. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the subtraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { return a + b; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { return a * b; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b <= a, errorMessage); return a - b; } } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a / b; } } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a % b; } } }
contracts/infra/interface/IWETH.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; interface IWETH { function deposit() external payable; function withdraw(uint256 amount) external; function transfer(address to, uint256 value) external returns (bool); }
contracts/lib/Address.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.1; /// @author thirdweb, OpenZeppelin Contracts (v4.9.0) /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * * Furthermore, `isContract` will also return true if the target contract within * the same transaction is already scheduled for destruction by `SELFDESTRUCT`, * which only has an effect at the end of a transaction. * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); (bool success, bytes memory returndata) = target.call{ value: value }(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } }
contracts/lib/CurrencyTransferLib.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; /// @author thirdweb // Helper interfaces import { IWETH } from "../infra/interface/IWETH.sol"; import { SafeERC20, IERC20 } from "../external-deps/openzeppelin/token/ERC20/utils/SafeERC20.sol"; library CurrencyTransferLib { using SafeERC20 for IERC20; /// @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); } } }
contracts/lib/Strings.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; /// @author thirdweb /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } /// @dev Returns the hexadecimal representation of `value`. /// The output is prefixed with "0x", encoded using 2 hexadecimal digits per byte, /// and the alphabets are capitalized conditionally according to /// https://eips.ethereum.org/EIPS/eip-55 function toHexStringChecksummed(address value) internal pure returns (string memory str) { str = toHexString(value); /// @solidity memory-safe-assembly assembly { let mask := shl(6, div(not(0), 255)) // `0b010000000100000000 ...` let o := add(str, 0x22) let hashed := and(keccak256(o, 40), mul(34, mask)) // `0b10001000 ... ` let t := shl(240, 136) // `0b10001000 << 240` for { let i := 0 } 1 { } { mstore(add(i, i), mul(t, byte(i, hashed))) i := add(i, 1) if eq(i, 20) { break } } mstore(o, xor(mload(o), shr(1, and(mload(0x00), and(mload(o), mask))))) o := add(o, 0x20) mstore(o, xor(mload(o), shr(1, and(mload(0x20), and(mload(o), mask))))) } } /// @dev Returns the hexadecimal representation of `value`. /// The output is prefixed with "0x" and encoded using 2 hexadecimal digits per byte. function toHexString(address value) internal pure returns (string memory str) { str = toHexStringNoPrefix(value); /// @solidity memory-safe-assembly assembly { let strLength := add(mload(str), 2) // Compute the length. mstore(str, 0x3078) // Write the "0x" prefix. str := sub(str, 2) // Move the pointer. mstore(str, strLength) // Write the length. } } /// @dev Returns the hexadecimal representation of `value`. /// The output is encoded using 2 hexadecimal digits per byte. function toHexStringNoPrefix(address value) internal pure returns (string memory str) { /// @solidity memory-safe-assembly assembly { str := mload(0x40) // Allocate the memory. // We need 0x20 bytes for the trailing zeros padding, 0x20 bytes for the length, // 0x02 bytes for the prefix, and 0x28 bytes for the digits. // The next multiple of 0x20 above (0x20 + 0x20 + 0x02 + 0x28) is 0x80. mstore(0x40, add(str, 0x80)) // Store "0123456789abcdef" in scratch space. mstore(0x0f, 0x30313233343536373839616263646566) str := add(str, 2) mstore(str, 40) let o := add(str, 0x20) mstore(add(o, 40), 0) value := shl(96, value) // We write the string from rightmost digit to leftmost digit. // The following is essentially a do-while loop that also handles the zero case. for { let i := 0 } 1 { } { let p := add(o, add(i, i)) let temp := byte(i, value) mstore8(add(p, 1), mload(and(temp, 15))) mstore8(p, mload(shr(4, temp))) i := add(i, 1) if eq(i, 20) { break } } } } /// @dev Returns the hex encoded string from the raw bytes. /// The output is encoded using 2 hexadecimal digits per byte. function toHexString(bytes memory raw) internal pure returns (string memory str) { str = toHexStringNoPrefix(raw); /// @solidity memory-safe-assembly assembly { let strLength := add(mload(str), 2) // Compute the length. mstore(str, 0x3078) // Write the "0x" prefix. str := sub(str, 2) // Move the pointer. mstore(str, strLength) // Write the length. } } /// @dev Returns the hex encoded string from the raw bytes. /// The output is encoded using 2 hexadecimal digits per byte. function toHexStringNoPrefix(bytes memory raw) internal pure returns (string memory str) { /// @solidity memory-safe-assembly assembly { let length := mload(raw) str := add(mload(0x40), 2) // Skip 2 bytes for the optional prefix. mstore(str, add(length, length)) // Store the length of the output. // Store "0123456789abcdef" in scratch space. mstore(0x0f, 0x30313233343536373839616263646566) let o := add(str, 0x20) let end := add(raw, length) for { } iszero(eq(raw, end)) { } { raw := add(raw, 1) mstore8(add(o, 1), mload(and(mload(raw), 15))) mstore8(o, mload(and(shr(4, mload(raw)), 15))) o := add(o, 2) } mstore(o, 0) // Zeroize the slot after the string. mstore(0x40, add(o, 0x20)) // Allocate the memory. } } }
contracts/prebuilts/interface/staking/ITokenStake.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.11; /** * Thirdweb's TokenStake smart contract allows users to stake their ERC-20 Tokens * and earn rewards in form of a different ERC-20 token. * * note: * - Reward token and staking token can't be changed after deployment. * Reward token contract can't be same as the staking token contract. * * - ERC20 tokens from only the specified contract can be staked. * * - All token transfers require approval on their respective token-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 tokens using the `stake` function only. * Any direct transfers may cause unintended consequences, such as locking of tokens. */ interface ITokenStake { /// @dev Emitted when contract admin withdraws reward tokens. event RewardTokensWithdrawnByAdmin(uint256 _amount); /// @dev Emitted when contract admin deposits reward tokens. event RewardTokensDepositedByAdmin(uint256 _amount); /** * @notice Lets a contract admin (account with `DEFAULT_ADMIN_ROLE`) deposit reward-tokens. * * note: Tokens should be approved on the reward-token contract before depositing. * * @param _amount Amount of tokens to deposit. */ function depositRewardTokens(uint256 _amount) external payable; /** * @notice Lets a contract admin (account with `DEFAULT_ADMIN_ROLE`) withdraw reward-tokens. * Useful for removing excess balance, thus preventing locking of tokens. * * @param _amount Amount of tokens to deposit. */ function withdrawRewardTokens(uint256 _amount) external; }
lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol) pragma solidity ^0.8.2; import "../../utils/AddressUpgradeable.sol"; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in * case an upgrade adds a module that needs to be initialized. * * For example: * * [.hljs-theme-light.nopadding] * ```solidity * contract MyToken is ERC20Upgradeable { * function initialize() initializer public { * __ERC20_init("MyToken", "MTK"); * } * } * * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable { * function initializeV2() reinitializer(2) public { * __ERC20Permit_init("MyToken"); * } * } * ``` * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() { * _disableInitializers(); * } * ``` * ==== */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. * @custom:oz-retyped-from bool */ uint8 private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Triggered when the contract has been initialized or reinitialized. */ event Initialized(uint8 version); /** * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope, * `onlyInitializing` functions can be used to initialize parent contracts. * * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a * constructor. * * Emits an {Initialized} event. */ modifier initializer() { bool isTopLevelCall = !_initializing; require( (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1), "Initializable: contract is already initialized" ); _initialized = 1; if (isTopLevelCall) { _initializing = true; } _; if (isTopLevelCall) { _initializing = false; emit Initialized(1); } } /** * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be * used to initialize parent contracts. * * A reinitializer may be used after the original initialization step. This is essential to configure modules that * are added through upgrades and that require initialization. * * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer` * cannot be nested. If one is invoked in the context of another, execution will revert. * * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in * a contract, executing them in the right order is up to the developer or operator. * * WARNING: setting the version to 255 will prevent any future reinitialization. * * Emits an {Initialized} event. */ modifier reinitializer(uint8 version) { require(!_initializing && _initialized < version, "Initializable: contract is already initialized"); _initialized = version; _initializing = true; _; _initializing = false; emit Initialized(version); } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} and {reinitializer} modifiers, directly or indirectly. */ modifier onlyInitializing() { require(_initializing, "Initializable: contract is not initializing"); _; } /** * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call. * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized * to any version. It is recommended to use this to lock implementation contracts that are designed to be called * through proxies. * * Emits an {Initialized} event the first time it is successfully executed. */ function _disableInitializers() internal virtual { require(!_initializing, "Initializable: contract is initializing"); if (_initialized != type(uint8).max) { _initialized = type(uint8).max; emit Initialized(type(uint8).max); } } /** * @dev Returns the highest version that has been initialized. See {reinitializer}. */ function _getInitializedVersion() internal view returns (uint8) { return _initialized; } /** * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}. */ function _isInitializing() internal view returns (bool) { return _initializing; } }
lib/openzeppelin-contracts-upgradeable/contracts/security/ReentrancyGuardUpgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol) pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuardUpgradeable is Initializable { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; function __ReentrancyGuard_init() internal onlyInitializing { __ReentrancyGuard_init_unchained(); } function __ReentrancyGuard_init_unchained() internal onlyInitializing { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { _nonReentrantBefore(); _; _nonReentrantAfter(); } function _nonReentrantBefore() private { // On the first call to nonReentrant, _status will be _NOT_ENTERED require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; } function _nonReentrantAfter() private { // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } /** * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a * `nonReentrant` function in the call stack. */ function _reentrancyGuardEntered() internal view returns (bool) { return _status == _ENTERED; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; }
lib/openzeppelin-contracts-upgradeable/contracts/utils/AddressUpgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library AddressUpgradeable { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * * Furthermore, `isContract` will also return true if the target contract within * the same transaction is already scheduled for destruction by `SELFDESTRUCT`, * which only has an effect at the end of a transaction. * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } }
lib/openzeppelin-contracts-upgradeable/contracts/utils/ContextUpgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract ContextUpgradeable is Initializable { function __Context_init() internal onlyInitializing { } function __Context_init_unchained() internal onlyInitializing { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 amount) external returns (bool); }
lib/openzeppelin-contracts/contracts/utils/Address.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library 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); } } }
Compiler Settings
{"remappings":["@chainlink/=lib/chainlink/","@ds-test/=lib/ds-test/src/","@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/","@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/","@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":{"*":{"*":["*"],"":["*"]}},"optimizer":{"runs":20,"enabled":true},"libraries":{},"evmVersion":"london"}
Contract ABI
[{"type":"constructor","stateMutability":"nonpayable","inputs":[{"type":"address","name":"_nativeTokenWrapper","internalType":"address"}]},{"type":"event","name":"ContractURIUpdated","inputs":[{"type":"string","name":"prevURI","internalType":"string","indexed":false},{"type":"string","name":"newURI","internalType":"string","indexed":false}],"anonymous":false},{"type":"event","name":"Initialized","inputs":[{"type":"uint8","name":"version","internalType":"uint8","indexed":false}],"anonymous":false},{"type":"event","name":"RewardTokensDepositedByAdmin","inputs":[{"type":"uint256","name":"_amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"RewardTokensWithdrawnByAdmin","inputs":[{"type":"uint256","name":"_amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"RewardsClaimed","inputs":[{"type":"address","name":"staker","internalType":"address","indexed":true},{"type":"uint256","name":"rewardAmount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"RoleAdminChanged","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32","indexed":true},{"type":"bytes32","name":"previousAdminRole","internalType":"bytes32","indexed":true},{"type":"bytes32","name":"newAdminRole","internalType":"bytes32","indexed":true}],"anonymous":false},{"type":"event","name":"RoleGranted","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32","indexed":true},{"type":"address","name":"account","internalType":"address","indexed":true},{"type":"address","name":"sender","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"RoleRevoked","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32","indexed":true},{"type":"address","name":"account","internalType":"address","indexed":true},{"type":"address","name":"sender","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"TokensStaked","inputs":[{"type":"address","name":"staker","internalType":"address","indexed":true},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"TokensWithdrawn","inputs":[{"type":"address","name":"staker","internalType":"address","indexed":true},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"UpdatedMinStakeAmount","inputs":[{"type":"uint256","name":"oldAmount","internalType":"uint256","indexed":false},{"type":"uint256","name":"newAmount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"UpdatedRewardRatio","inputs":[{"type":"uint256","name":"oldNumerator","internalType":"uint256","indexed":false},{"type":"uint256","name":"newNumerator","internalType":"uint256","indexed":false},{"type":"uint256","name":"oldDenominator","internalType":"uint256","indexed":false},{"type":"uint256","name":"newDenominator","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"UpdatedTimeUnit","inputs":[{"type":"uint256","name":"oldTimeUnit","internalType":"uint256","indexed":false},{"type":"uint256","name":"newTimeUnit","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"DEFAULT_ADMIN_ROLE","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"claimRewards","inputs":[]},{"type":"function","stateMutability":"pure","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"contractType","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"contractURI","inputs":[]},{"type":"function","stateMutability":"pure","outputs":[{"type":"uint8","name":"","internalType":"uint8"}],"name":"contractVersion","inputs":[]},{"type":"function","stateMutability":"payable","outputs":[],"name":"depositRewardTokens","inputs":[{"type":"uint256","name":"_amount","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"_numerator","internalType":"uint256"},{"type":"uint256","name":"_denominator","internalType":"uint256"}],"name":"getRewardRatio","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getRewardTokenBalance","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"getRoleAdmin","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"member","internalType":"address"}],"name":"getRoleMember","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"uint256","name":"index","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"count","internalType":"uint256"}],"name":"getRoleMemberCount","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"_tokensStaked","internalType":"uint256"},{"type":"uint256","name":"_rewards","internalType":"uint256"}],"name":"getStakeInfo","inputs":[{"type":"address","name":"_staker","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint80","name":"_timeUnit","internalType":"uint80"}],"name":"getTimeUnit","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"grantRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"hasRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"hasRoleWithSwitch","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"initialize","inputs":[{"type":"address","name":"_defaultAdmin","internalType":"address"},{"type":"string","name":"_contractURI","internalType":"string"},{"type":"address[]","name":"_trustedForwarders","internalType":"address[]"},{"type":"address","name":"_rewardToken","internalType":"address"},{"type":"address","name":"_stakingToken","internalType":"address"},{"type":"uint80","name":"_timeUnit","internalType":"uint80"},{"type":"uint256","name":"_rewardRatioNumerator","internalType":"uint256"},{"type":"uint256","name":"_rewardRatioDenominator","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isTrustedForwarder","inputs":[{"type":"address","name":"forwarder","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bytes[]","name":"results","internalType":"bytes[]"}],"name":"multicall","inputs":[{"type":"bytes[]","name":"data","internalType":"bytes[]"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"revokeRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"rewardToken","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint16","name":"","internalType":"uint16"}],"name":"rewardTokenDecimals","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setContractURI","inputs":[{"type":"string","name":"_uri","internalType":"string"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setRewardRatio","inputs":[{"type":"uint256","name":"_numerator","internalType":"uint256"},{"type":"uint256","name":"_denominator","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setTimeUnit","inputs":[{"type":"uint80","name":"_timeUnit","internalType":"uint80"}]},{"type":"function","stateMutability":"payable","outputs":[],"name":"stake","inputs":[{"type":"uint256","name":"_amount","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint128","name":"timeOfLastUpdate","internalType":"uint128"},{"type":"uint64","name":"conditionIdOflastUpdate","internalType":"uint64"},{"type":"uint256","name":"amountStaked","internalType":"uint256"},{"type":"uint256","name":"unclaimedRewards","internalType":"uint256"}],"name":"stakers","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"stakersArray","inputs":[{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"stakingToken","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"stakingTokenBalance","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint16","name":"","internalType":"uint16"}],"name":"stakingTokenDecimals","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"withdraw","inputs":[{"type":"uint256","name":"_amount","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"withdrawRewardTokens","inputs":[{"type":"uint256","name":"_amount","internalType":"uint256"}]},{"type":"receive","stateMutability":"payable"}]
Contract Creation Code
0x60a06040523480156200001157600080fd5b5060405162003f5738038062003f5783398101604081905262000034916200019e565b806001600160a01b0381166200007d5760405162461bcd60e51b815260206004820152600960248201526806164647265737320360bc1b60448201526064015b60405180910390fd5b6001600160a01b0316608052600054610100900460ff1615808015620000aa5750600054600160ff909116105b80620000c65750303b158015620000c6575060005460ff166001145b6200012b5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b606482015260840162000074565b6000805460ff1916600117905580156200014f576000805461ff0019166101001790555b801562000196576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5050620001d0565b600060208284031215620001b157600080fd5b81516001600160a01b0381168114620001c957600080fd5b9392505050565b608051613d3a6200021d600039600081816101ac015281816108de0152818161098e0152818161122f0152818161128f01528181611e010152818161226c0152612f870152613d3a6000f3fe60806040526004361061019c5760003560e01c80639bdcecd1116100dd5780639bdcecd1146104c8578063a0a8e460146104fd578063a217fddf14610519578063a32fa5b31461052e578063a694fc3a1461054e578063ac9650d814610561578063b218f0691461058e578063b9f7a7b5146105ae578063c3453153146105d0578063ca15c873146105f0578063cb2ef6f714610610578063cb43b2dd14610630578063d547741f14610650578063d68124c714610670578063df6543761461069d578063e8a3d485146106bd578063f7c618c1146106df57600080fd5b80621b79341461022557806316c621e014610245578063248a9ca3146102585780632e1a7d4d146102985780632f2ff15d146102b857806336568abe146102d8578063372500ab146102f85780635357e9161461030d578063572b6c051461033a57806372f702f31461036a5780638caaa2711461038a5780639010d07c146103a05780639168ae72146103c057806391d1485414610449578063938e3d7b1461046957806393ce53431461048957806397e1b4bc1461049e57600080fd5b3661022057336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161461021e5760405162461bcd60e51b815260206004820181905260248201527f63616c6c6572206e6f74206e617469766520746f6b656e20777261707065722e60448201526064015b60405180910390fd5b005b600080fd5b34801561023157600080fd5b5061021e61024036600461337f565b6106ff565b61021e6102533660046133a1565b610871565b34801561026457600080fd5b506102856102733660046133a1565b60009081526003602052604090205490565b6040519081526020015b60405180910390f35b3480156102a457600080fd5b5061021e6102b33660046133a1565b610a88565b3480156102c457600080fd5b5061021e6102d33660046133d1565b610aa3565b3480156102e457600080fd5b5061021e6102f33660046133d1565b610b3d565b34801561030457600080fd5b5061021e610b9c565b34801561031957600080fd5b5061032d6103283660046133a1565b610bb8565b60405161028f91906133fd565b34801561034657600080fd5b5061035a610355366004613411565b610be2565b604051901515815260200161028f565b34801561037657600080fd5b50609b5461032d906001600160a01b031681565b34801561039657600080fd5b50610285609c5481565b3480156103ac57600080fd5b5061032d6103bb36600461337f565b610c00565b3480156103cc57600080fd5b506104176103db366004613411565b609e602052600090815260409020805460018201546002909201546001600160801b03821692600160801b9092046001600160401b0316919084565b604080516001600160801b0390951685526001600160401b03909316602085015291830152606082015260800161028f565b34801561045557600080fd5b5061035a6104643660046133d1565b610cef565b34801561047557600080fd5b5061021e6104843660046134e1565b610d1a565b34801561049557600080fd5b5060a154610285565b3480156104aa57600080fd5b506104b3610d47565b6040805192835260208301919091520161028f565b3480156104d457600080fd5b50609b546104ea90600160b01b900461ffff1681565b60405161ffff909116815260200161028f565b34801561050957600080fd5b506040516001815260200161028f565b34801561052557600080fd5b50610285600081565b34801561053a57600080fd5b5061035a6105493660046133d1565b610dd4565b61021e61055c3660046133a1565b610e2a565b34801561056d57600080fd5b5061058161057c366004613515565b610e3b565b60405161028f91906135d9565b34801561059a57600080fd5b5061021e6105a9366004613654565b610fae565b3480156105ba57600080fd5b50609b546104ea90600160a01b900461ffff1681565b3480156105dc57600080fd5b506104b36105eb366004613411565b61110a565b3480156105fc57600080fd5b5061028561060b3660046133a1565b611137565b34801561061c57600080fd5b5069546f6b656e5374616b6560b01b610285565b34801561063c57600080fd5b5061021e61064b3660046133a1565b6111c0565b34801561065c57600080fd5b5061021e61066b3660046133d1565b6113ad565b34801561067c57600080fd5b506106856113c6565b6040516001600160501b03909116815260200161028f565b3480156106a957600080fd5b5061021e6106b836600461366f565b611416565b3480156106c957600080fd5b506106d261171e565b60405161028f9190613798565b3480156106eb57600080fd5b5060a05461032d906001600160a01b031681565b6107076117ac565b6107235760405162461bcd60e51b8152600401610215906137ab565b6000609f60006001609b60189054906101000a90046001600160401b031661074b91906137e9565b6001600160401b031681526020808201929092526040908101600020815160a08101835281546001600160501b038082168352600160501b8204811695830195909552600160a01b9004909316918301919091526001810154606083018190526002909101546080830152909150831415806107cb575080608001518214155b6108115760405162461bcd60e51b81526020600482015260176024820152762932bbb0b932103930ba34b7903ab731b430b733b2b21760491b6044820152606401610215565b805161081e9084846117bf565b60608082015160808084015160408051938452602084018890528301529181018490527feb6684a1e7c9bd2adc792fb253558f022bcbef39fb6ad31dc58cdfefdd5b5190910160405180910390a1505050565b61087961197d565b61088660006104646119d6565b6108a25760405162461bcd60e51b8152600401610215906137ab565b60a0546000906001600160a01b031673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee146108dc5760a0546001600160a01b03166108fe565b7f00000000000000000000000000000000000000000000000000000000000000005b90506000816001600160a01b03166370a08231306040518263ffffffff1660e01b815260040161092e91906133fd565b602060405180830381865afa15801561094b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061096f9190613810565b60a0549091506109b2906001600160a01b031661098a6119d6565b30867f00000000000000000000000000000000000000000000000000000000000000006119e0565b600081836001600160a01b03166370a08231306040518263ffffffff1660e01b81526004016109e191906133fd565b602060405180830381865afa1580156109fe573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a229190613810565b610a2c9190613829565b90508060a16000828254610a40919061383c565b90915550506040518181527ff9d14e57815939d300bc94720ede00c8c8e08d254ab28e2917ea46e149aa119b9060200160405180910390a1505050610a856001606955565b50565b610a9061197d565b610a9981611b58565b610a856001606955565b600082815260036020526040902054610abc9033611e73565b60008281526002602090815260408083206001600160a01b038516845290915290205460ff1615610b2f5760405162461bcd60e51b815260206004820152601d60248201527f43616e206f6e6c79206772616e7420746f206e6f6e20686f6c646572730000006044820152606401610215565b610b398282611ef3565b5050565b336001600160a01b03821614610b925760405162461bcd60e51b815260206004820152601a60248201527921b0b71037b7363c903932b737bab731b2903337b91039b2b63360311b6044820152606401610215565b610b398282611f07565b610ba461197d565b610bac611f5e565b610bb66001606955565b565b609d8181548110610bc857600080fd5b6000918252602090912001546001600160a01b0316905081565b6001600160a01b031660009081526037602052604090205460ff1690565b60008281526004602052604081205481805b82811015610ce55760008681526004602090815260408083208484526001019091529020546001600160a01b031615610c8e57848203610c7c5760008681526004602090815260408083209383526001909301905220546001600160a01b03169250610ce9915050565b610c8760018361383c565b9150610cd3565b610c99866000610cef565b8015610cc05750600086815260046020908152604080832083805260020190915290205481145b15610cd357610cd060018361383c565b91505b610cde60018261383c565b9050610c12565b5050505b92915050565b60009182526002602090815260408084206001600160a01b0393909316845291905290205460ff1690565b610d226117ac565b610d3e5760405162461bcd60e51b8152600401610215906137ab565b610a858161212c565b600080609f60006001609b60189054906101000a90046001600160401b0316610d7091906137e9565b6001600160401b03168152602001908152602001600020600101549150609f60006001609b60189054906101000a90046001600160401b0316610db391906137e9565b6001600160401b031681526020019081526020016000206002015490509091565b600082815260026020908152604080832083805290915281205460ff16610e21575060008281526002602090815260408083206001600160a01b038516845290915290205460ff16610ce9565b50600192915050565b610e3261197d565b610a99816121fc565b6060816001600160401b03811115610e5557610e5561342c565b604051908082528060200260200182016040528015610e8857816020015b6060815260200190600190039081610e735790505b5090506000610e956119d6565b9050336001600160a01b038216141560005b84811015610ce5578115610f2657610f0430878784818110610ecb57610ecb61384f565b9050602002810190610edd9190613865565b86604051602001610ef0939291906138ab565b6040516020818303038152906040526125cc565b848281518110610f1657610f1661384f565b6020026020010181905250610fa6565b610f8830878784818110610f3c57610f3c61384f565b9050602002810190610f4e9190613865565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506125cc92505050565b848281518110610f9a57610f9a61384f565b60200260200101819052505b600101610ea7565b610fb66117ac565b610fd25760405162461bcd60e51b8152600401610215906137ab565b6000609f60006001609b60189054906101000a90046001600160401b0316610ffa91906137e9565b6001600160401b031681526020808201929092526040908101600020815160a08101835281546001600160501b03808216808452600160501b8304821696840196909652600160a01b90910481169382019390935260018201546060820152600290910154608082015292508316036110ac5760405162461bcd60e51b81526020600482015260146024820152732a34b6b296bab734ba103ab731b430b733b2b21760611b6044820152606401610215565b6110bf82826060015183608001516117bf565b8051604080516001600160501b03928316815291841660208301527fd968de290ed68f978b9e4816f7d4be9ef46189fe8eeb3eeb86199e7229cf2de091015b60405180910390a15050565b6001600160a01b0381166000908152609e602052604081206001015490611130836125f8565b9050915091565b600081815260046020526040812054815b8181101561119b5760008481526004602090815260408083208484526001019091529020546001600160a01b0316156111895761118660018461383c565b92505b61119460018261383c565b9050611148565b506111a7836000610cef565b156111ba576111b760018361383c565b91505b50919050565b6111c861197d565b6111d560006104646119d6565b6111f15760405162461bcd60e51b8152600401610215906137ab565b60a154811161120d578060a1546112089190613829565b611210565b60005b60a15560a054611253906001600160a01b03163061122c6119d6565b847f00000000000000000000000000000000000000000000000000000000000000006119e0565b609b546000906001600160a01b031673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee1461128d57609b546001600160a01b03166112af565b7f00000000000000000000000000000000000000000000000000000000000000005b9050609c54816001600160a01b03166370a08231306040518263ffffffff1660e01b81526004016112e091906133fd565b602060405180830381865afa1580156112fd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113219190613810565b101561136f5760405162461bcd60e51b815260206004820152601e60248201527f5374616b696e6720746f6b656e2062616c616e636520726564756365642e00006044820152606401610215565b6040518281527f37ff8766c704931c4283e470feb7c20ddcd8aa492746f74b30503709a0452acd9060200160405180910390a150610a856001606955565b600082815260036020526040902054610b929033611e73565b6000609f60006001609b60189054906101000a90046001600160401b03166113ee91906137e9565b6001600160401b031681526020810191909152604001600020546001600160501b0316919050565b600054610100900460ff16158080156114365750600054600160ff909116105b80611457575061144530612670565b158015611457575060005460ff166001145b6114ba5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610215565b6000805460ff1916600117905580156114dd576000805461ff0019166101001790555b6114e68761267f565b846001600160a01b0316866001600160a01b03160361155d5760405162461bcd60e51b815260206004820152602d60248201527f52657761726420546f6b656e20616e64205374616b696e6720546f6b656e206360448201526c30b713ba1031329039b0b6b29760991b6064820152608401610215565b60a080546001600160a01b0319166001600160a01b038881169190911790915560009073eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee9087161461160457856001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156115db573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115ff91906138cc565b611607565b60125b60ff16905060006001600160a01b03881673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee1461169957876001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015611670573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061169491906138cc565b61169c565b60125b60ff1690506116ac878383612704565b6116b78686866117bf565b6116c08a61212c565b6116cb60008c611ef3565b50508015611713576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b505050505050505050565b6001805461172b906138ef565b80601f0160208091040260200160405190810160405280929190818152602001828054611757906138ef565b80156117a45780601f10611779576101008083540402835291602001916117a4565b820191906000526020600020905b81548152906001019060200180831161178757829003601f168201915b505050505081565b60006117ba816104646119d6565b905090565b806000036117fd5760405162461bcd60e51b815260206004820152600b60248201526a064697669646520627920360ac1b6044820152606401610215565b826001600160501b031660000361184d5760405162461bcd60e51b8152602060048201526014602482015273074696d652d756e69742063616e277420626520360641b6044820152606401610215565b609b8054600160c01b90046001600160401b03169060019060186118718385613923565b82546001600160401b039182166101009390930a9283029190920219909116179055506040805160a0810182526001600160501b03808716825242811660208084019182526000848601818152606086018a8152608087018a8152898452609f9094529690912094518554935191518516600160a01b02600160a01b600160f01b0319928616600160501b026001600160a01b03199095169190951617929092179190911691909117825591516001820155905160029091015580156119775742609f6000611941600185613829565b815260200190815260200160002060000160146101000a8154816001600160501b0302191690836001600160501b031602179055505b50505050565b6002606954036119cf5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610215565b6002606955565b60006117ba61280e565b8115611b4a5773eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeed196001600160a01b03861601611b3e57306001600160a01b03851603611a8557604051632e1a7d4d60e01b8152600481018390526001600160a01b03821690632e1a7d4d90602401600060405180830381600087803b158015611a5d57600080fd5b505af1158015611a71573d6000803e3d6000fd5b50505050611a80838383612830565b611b4a565b306001600160a01b03841603611b3357348214611ada5760405162461bcd60e51b81526020600482015260136024820152721b5cd9cb9d985b1d5948084f48185b5bdd5b9d606a1b6044820152606401610215565b806001600160a01b031663d0e30db0836040518263ffffffff1660e01b81526004016000604051808303818588803b158015611b1557600080fd5b505af1158015611b29573d6000803e3d6000fd5b5050505050611b4a565b611a80838383612830565b611b4a858585856128f5565b5050505050565b6001606955565b6000609e6000611b6661294d565b6001600160a01b03166001600160a01b0316815260200190815260200160002060010154905081600003611bd35760405162461bcd60e51b81526020600482015260146024820152735769746864726177696e67203020746f6b656e7360601b6044820152606401610215565b81811015611c225760405162461bcd60e51b815260206004820152601c60248201527b15da5d1a191c985dda5b99c81b5bdc99481d1a185b881cdd185ad95960221b6044820152606401610215565b611c32611c2d61294d565b612957565b818103611d88576000609d805480602002602001604051908101604052809291908181526020018280548015611c9157602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611c73575b5050505050905060005b8151811015611d8557611cac61294d565b6001600160a01b0316828281518110611cc757611cc761384f565b60200260200101516001600160a01b031603611d7d578160018351611cec9190613829565b81518110611cfc57611cfc61384f565b6020026020010151609d8281548110611d1757611d1761384f565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550609d805480611d5657611d56613943565b600082815260209020810160001990810180546001600160a01b0319169055019055611d85565b600101611c9b565b50505b81609e6000611d9561294d565b6001600160a01b03166001600160a01b031681526020019081526020016000206001016000828254611dc79190613829565b9250508190555081609c6000828254611de09190613829565b9091555050609b54611e25906001600160a01b031630611dfe61294d565b857f00000000000000000000000000000000000000000000000000000000000000006119e0565b611e2d61294d565b6001600160a01b03167f6352c5382c4a4578e712449ca65e83cdb392d045dfcf1cad9615189db2da244b83604051611e6791815260200190565b60405180910390a25050565b60008281526002602090815260408083206001600160a01b038516845290915290205460ff16610b3957611eb1816001600160a01b03166014612a2e565b611ebc836020612a2e565b604051602001611ecd929190613959565b60408051601f198184030181529082905262461bcd60e51b825261021591600401613798565b611efd8282612bc9565b610b398282612c24565b611f118282612c91565b60008281526004602090815260408083206001600160a01b03851680855260028201808552838620805487526001909301855292852080546001600160a01b031916905584529152555050565b6000611f70611f6b61294d565b612cf3565b609e6000611f7c61294d565b6001600160a01b03166001600160a01b0316815260200190815260200160002060020154611faa919061383c565b905080600003611fe95760405162461bcd60e51b815260206004820152600a6024820152694e6f207265776172647360b01b6044820152606401610215565b426001600160501b0316609e6000611fff61294d565b6001600160a01b031681526020810191909152604001600090812080546001600160801b0319166001600160801b039390931692909217909155609e8161204461294d565b6001600160a01b03168152602081019190915260400160002060020155609b5461208090600190600160c01b90046001600160401b03166137e9565b609e600061208c61294d565b6001600160a01b03168152602081019190915260400160002080546001600160401b0392909216600160801b02600160801b600160c01b03199092169190911790556120df6120d961294d565b82612f0e565b6120e761294d565b6001600160a01b03167ffc30cddea38e2bf4d6ea7d3f9ed3b6ad7f176419f4963bd81318067a4aee73fe8260405161212191815260200190565b60405180910390a250565b60006001805461213b906138ef565b80601f0160208091040260200160405190810160405280929190818152602001828054612167906138ef565b80156121b45780601f10612189576101008083540402835291602001916121b4565b820191906000526020600020905b81548152906001019060200180831161219757829003601f168201915b5050505050905081600190816121ca9190613a16565b507fc9c7c3fe08b88b4df9d4d47ef47d2c43d55c025a0ba88ca442580ed9e7348a1681836040516110fe929190613ad5565b8060000361223f5760405162461bcd60e51b815260206004820152601060248201526f5374616b696e67203020746f6b656e7360801b6044820152606401610215565b609b546000906001600160a01b031673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeed190161229057507f00000000000000000000000000000000000000000000000000000000000000006122da565b34156122cc5760405162461bcd60e51b815260206004820152600b60248201526a056616c7565206e6f7420360ac1b6044820152606401610215565b50609b546001600160a01b03165b6000609e60006122e861294d565b6001600160a01b03166001600160a01b031681526020019081526020016000206001015411156123225761231d611c2d61294d565b612417565b609d61232c61294d565b81546001810183556000928352602083200180546001600160a01b0319166001600160a01b0392909216919091179055426001600160501b031690609e9061237261294d565b6001600160a01b03168152602081019190915260400160002080546001600160801b0319166001600160801b0392909216919091179055609b546123c890600190600160c01b90046001600160401b03166137e9565b609e60006123d461294d565b6001600160a01b03168152602081019190915260400160002080546001600160401b0392909216600160801b02600160801b600160c01b03199092169190911790555b6040516370a0823160e01b81526000906001600160a01b038316906370a08231906124469030906004016133fd565b602060405180830381865afa158015612463573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124879190613810565b609b549091506124a2906001600160a01b031661098a61294d565b600081836001600160a01b03166370a08231306040518263ffffffff1660e01b81526004016124d191906133fd565b602060405180830381865afa1580156124ee573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125129190613810565b61251c9190613829565b905080609e600061252b61294d565b6001600160a01b03166001600160a01b03168152602001908152602001600020600101600082825461255d919061383c565b9250508190555080609c6000828254612576919061383c565b90915550612584905061294d565b6001600160a01b03167fb539ca1e5c8d398ddf1c41c30166f33404941683be4683319b57669a93dad4ef826040516125be91815260200190565b60405180910390a250505050565b60606125f18383604051806060016040528060278152602001613cde60279139612fab565b9392505050565b6001600160a01b0381166000908152609e6020526040812060010154810361263957506001600160a01b03166000908152609e602052604090206002015490565b61264282612cf3565b6001600160a01b0383166000908152609e6020526040902060020154612668919061383c565b90505b919050565b6001600160a01b03163b151590565b600054610100900460ff166126a65760405162461bcd60e51b815260040161021590613afa565b60005b8151811015610b39576001603760008484815181106126ca576126ca61384f565b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff19169115159190911790556001016126a9565b600054610100900460ff1661272b5760405162461bcd60e51b815260040161021590613afa565b612733613023565b6001600160a01b03831661277b5760405162461bcd60e51b815260206004820152600f60248201526e0746f6b656e2061646472657373203608c1b6044820152606401610215565b61ffff821615801590612791575061ffff811615155b6127ca5760405162461bcd60e51b815260206004820152600a6024820152690646563696d616c7320360b41b6044820152606401610215565b609b80546001600160a01b03949094166001600160b01b031990941693909317600160a01b61ffff938416021761ffff60b01b1916600160b01b9190921602179055565b600061281933610be2565b1561282b575060131936013560601c90565b503390565b6000836001600160a01b03168360405160006040518083038185875af1925050503d806000811461287d576040519150601f19603f3d011682016040523d82523d6000602084013e612882565b606091505b505090508061197757816001600160a01b031663d0e30db0846040518263ffffffff1660e01b81526004016000604051808303818588803b1580156128c657600080fd5b505af11580156128da573d6000803e3d6000fd5b50611977935050506001600160a01b03841690508585613052565b816001600160a01b0316836001600160a01b0316031561197757306001600160a01b03841603612938576129336001600160a01b0385168383613052565b611977565b6119776001600160a01b0385168484846130ba565b60006117ba6119d6565b600061296282612cf3565b6001600160a01b0383166000908152609e602052604081206002018054929350839290919061299290849061383c565b90915550506001600160a01b0382166000908152609e6020526040902080546001600160801b0319166001600160501b034216179055609b546129e8906001906001600160401b03600160c01b909104166137e9565b6001600160a01b039092166000908152609e6020526040902080546001600160401b0393909316600160801b02600160801b600160c01b03199093169290921790915550565b60606000612a3d836002613b45565b612a4890600261383c565b6001600160401b03811115612a5f57612a5f61342c565b6040519080825280601f01601f191660200182016040528015612a89576020820181803683370190505b509050600360fc1b81600081518110612aa457612aa461384f565b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110612ad357612ad361384f565b60200101906001600160f81b031916908160001a9053506000612af7846002613b45565b612b0290600161383c565b90505b6001811115612b7a576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110612b3657612b3661384f565b1a60f81b828281518110612b4c57612b4c61384f565b60200101906001600160f81b031916908160001a90535060049490941c93612b7381613b5c565b9050612b05565b5083156125f15760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610215565b60008281526002602090815260408083206001600160a01b0385168085529252808320805460ff1916600117905551339285917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9190a45050565b600082815260046020526040812080549160019190612c43838561383c565b9091555050600092835260046020908152604080852083865260018101835281862080546001600160a01b039096166001600160a01b03199096168617905593855260029093019052912055565b612c9b8282611e73565b60008281526002602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6001600160a01b0381166000908152609e60209081526040808320815160808101835281546001600160801b03811682526001600160401b03600160801b90910481169482018590526001830154938201939093526002909101546060820152609b54909291600160c01b90910416815b81811015612eb9576000818152609f60209081526040808320815160a08101835281546001600160501b038082168352600160501b8204811695830195909552600160a01b9004909316918301919091526001810154606083015260020154608082015290848303612dd7578551612de6565b81602001516001600160501b03165b6001600160801b03169050600082604001516001600160501b0316600003612e0e5742612e1d565b82604001516001600160501b03165b9050600080612e4a89604001518585612e369190613829565b612e409190613b45565b86606001516130f2565b91509150600080612e828c886080015189600001516001600160501b031686612e739190613b89565b612e7d9190613b89565b61313d565b91509150838015612e905750815b612e9a578b612e9c565b805b9b5050505050505050600181612eb2919061383c565b9050612d64565b50609b54612ede908590612ed990600160b01b900461ffff16600a613c8f565b6130f2565b609b54909550612efb9150600160a01b900461ffff16600a613c8f565b612f059085613b89565b95945050505050565b60a154811115612f5b5760405162461bcd60e51b81526020600482015260186024820152774e6f7420656e6f7567682072657761726420746f6b656e7360401b6044820152606401610215565b8060a16000828254612f6d9190613829565b909155505060a054610b39906001600160a01b03163084847f00000000000000000000000000000000000000000000000000000000000000006119e0565b6060600080856001600160a01b031685604051612fc89190613c9f565b600060405180830381855af49150503d8060008114613003576040519150601f19603f3d011682016040523d82523d6000602084013e613008565b606091505b509150915061301986838387613158565b9695505050505050565b600054610100900460ff1661304a5760405162461bcd60e51b815260040161021590613afa565b610bb66131d7565b6040516001600160a01b0383166024820152604481018290526130b590849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091526131fe565b505050565b6040516001600160a01b03808516602483015283166044820152606481018290526119779085906323b872dd60e01b9060840161307e565b600080836000036131095750600190506000613136565b8383028385828161311c5761311c613b73565b041461312f576000809250925050613136565b6001925090505b9250929050565b6000808383018481101561312f576000809250925050613136565b606083156131c55782516000036131be5761317285612670565b6131be5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610215565b50816131cf565b6131cf83836132d0565b949350505050565b600054610100900460ff16611b515760405162461bcd60e51b815260040161021590613afa565b6000613253826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166132fa9092919063ffffffff16565b8051909150156130b557808060200190518101906132719190613cbb565b6130b55760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610215565b8151156132e05781518083602001fd5b8060405162461bcd60e51b81526004016102159190613798565b60606131cf848460008585600080866001600160a01b031685876040516133219190613c9f565b60006040518083038185875af1925050503d806000811461335e576040519150601f19603f3d011682016040523d82523d6000602084013e613363565b606091505b509150915061337487838387613158565b979650505050505050565b6000806040838503121561339257600080fd5b50508035926020909101359150565b6000602082840312156133b357600080fd5b5035919050565b80356001600160a01b038116811461266b57600080fd5b600080604083850312156133e457600080fd5b823591506133f4602084016133ba565b90509250929050565b6001600160a01b0391909116815260200190565b60006020828403121561342357600080fd5b6125f1826133ba565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b038111828210171561346a5761346a61342c565b604052919050565b600082601f83011261348357600080fd5b81356001600160401b0381111561349c5761349c61342c565b6134af601f8201601f1916602001613442565b8181528460208386010111156134c457600080fd5b816020850160208301376000918101602001919091529392505050565b6000602082840312156134f357600080fd5b81356001600160401b0381111561350957600080fd5b6131cf84828501613472565b6000806020838503121561352857600080fd5b82356001600160401b038082111561353f57600080fd5b818501915085601f83011261355357600080fd5b81358181111561356257600080fd5b8660208260051b850101111561357757600080fd5b60209290920196919550909350505050565b60005b838110156135a457818101518382015260200161358c565b50506000910152565b600081518084526135c5816020860160208601613589565b601f01601f19169290920160200192915050565b600060208083016020845280855180835260408601915060408160051b87010192506020870160005b8281101561363057603f1988860301845261361e8583516135ad565b94509285019290850190600101613602565b5092979650505050505050565b80356001600160501b038116811461266b57600080fd5b60006020828403121561366657600080fd5b6125f18261363d565b600080600080600080600080610100898b03121561368c57600080fd5b613695896133ba565b97506020808a01356001600160401b03808211156136b257600080fd5b6136be8d838e01613472565b995060408c01359150808211156136d457600080fd5b818c0191508c601f8301126136e857600080fd5b8135818111156136fa576136fa61342c565b8060051b915061370b848301613442565b818152918301840191848101908f84111561372557600080fd5b938501935b8385101561374a5761373b856133ba565b8252938501939085019061372a565b809b5050505050505061375f60608a016133ba565b945061376d60808a016133ba565b935061377b60a08a0161363d565b925060c0890135915060e089013590509295985092959890939650565b6020815260006125f160208301846135ad565b6020808252600e908201526d139bdd08185d5d1a1bdc9a5e995960921b604082015260600190565b634e487b7160e01b600052601160045260246000fd5b6001600160401b03828116828216039080821115613809576138096137d3565b5092915050565b60006020828403121561382257600080fd5b5051919050565b81810381811115610ce957610ce96137d3565b80820180821115610ce957610ce96137d3565b634e487b7160e01b600052603260045260246000fd5b6000808335601e1984360301811261387c57600080fd5b8301803591506001600160401b0382111561389657600080fd5b60200191503681900382131561313657600080fd5b8284823760609190911b6001600160601b0319169101908152601401919050565b6000602082840312156138de57600080fd5b815160ff811681146125f157600080fd5b600181811c9082168061390357607f821691505b6020821081036111ba57634e487b7160e01b600052602260045260246000fd5b6001600160401b03818116838216019080821115613809576138096137d3565b634e487b7160e01b600052603160045260246000fd5b7402832b936b4b9b9b4b7b7399d1030b1b1b7bab73a1605d1b815260008351613989816015850160208801613589565b7001034b99036b4b9b9b4b733903937b6329607d1b60159184019182015283516139ba816026840160208801613589565b01602601949350505050565b601f8211156130b5576000816000526020600020601f850160051c810160208610156139ef5750805b601f850160051c820191505b81811015613a0e578281556001016139fb565b505050505050565b81516001600160401b03811115613a2f57613a2f61342c565b613a4381613a3d84546138ef565b846139c6565b602080601f831160018114613a785760008415613a605750858301515b600019600386901b1c1916600185901b178555613a0e565b600085815260208120601f198616915b82811015613aa757888601518255948401946001909101908401613a88565b5085821015613ac55787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b604081526000613ae860408301856135ad565b8281036020840152612f0581856135ad565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b8082028115828204841417610ce957610ce96137d3565b600081613b6b57613b6b6137d3565b506000190190565b634e487b7160e01b600052601260045260246000fd5b600082613ba657634e487b7160e01b600052601260045260246000fd5b500490565b600181815b80851115613be6578160001904821115613bcc57613bcc6137d3565b80851615613bd957918102915b93841c9390800290613bb0565b509250929050565b600082613bfd57506001610ce9565b81613c0a57506000610ce9565b8160018114613c205760028114613c2a57613c46565b6001915050610ce9565b60ff841115613c3b57613c3b6137d3565b50506001821b610ce9565b5060208310610133831016604e8410600b8410161715613c69575081810a610ce9565b613c738383613bab565b8060001904821115613c8757613c876137d3565b029392505050565b60006125f161ffff841683613bee565b60008251613cb1818460208701613589565b9190910192915050565b600060208284031215613ccd57600080fd5b815180151581146125f157600080fdfe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212208a05a45507e2c645ea742e1dde2361088156136845f3eb865a9b1cebc4ef909c64736f6c63430008170033000000000000000000000000d23e77b7e1726577006799b7194b6ae31958a839
Deployed ByteCode
0x60806040526004361061019c5760003560e01c80639bdcecd1116100dd5780639bdcecd1146104c8578063a0a8e460146104fd578063a217fddf14610519578063a32fa5b31461052e578063a694fc3a1461054e578063ac9650d814610561578063b218f0691461058e578063b9f7a7b5146105ae578063c3453153146105d0578063ca15c873146105f0578063cb2ef6f714610610578063cb43b2dd14610630578063d547741f14610650578063d68124c714610670578063df6543761461069d578063e8a3d485146106bd578063f7c618c1146106df57600080fd5b80621b79341461022557806316c621e014610245578063248a9ca3146102585780632e1a7d4d146102985780632f2ff15d146102b857806336568abe146102d8578063372500ab146102f85780635357e9161461030d578063572b6c051461033a57806372f702f31461036a5780638caaa2711461038a5780639010d07c146103a05780639168ae72146103c057806391d1485414610449578063938e3d7b1461046957806393ce53431461048957806397e1b4bc1461049e57600080fd5b3661022057336001600160a01b037f000000000000000000000000d23e77b7e1726577006799b7194b6ae31958a839161461021e5760405162461bcd60e51b815260206004820181905260248201527f63616c6c6572206e6f74206e617469766520746f6b656e20777261707065722e60448201526064015b60405180910390fd5b005b600080fd5b34801561023157600080fd5b5061021e61024036600461337f565b6106ff565b61021e6102533660046133a1565b610871565b34801561026457600080fd5b506102856102733660046133a1565b60009081526003602052604090205490565b6040519081526020015b60405180910390f35b3480156102a457600080fd5b5061021e6102b33660046133a1565b610a88565b3480156102c457600080fd5b5061021e6102d33660046133d1565b610aa3565b3480156102e457600080fd5b5061021e6102f33660046133d1565b610b3d565b34801561030457600080fd5b5061021e610b9c565b34801561031957600080fd5b5061032d6103283660046133a1565b610bb8565b60405161028f91906133fd565b34801561034657600080fd5b5061035a610355366004613411565b610be2565b604051901515815260200161028f565b34801561037657600080fd5b50609b5461032d906001600160a01b031681565b34801561039657600080fd5b50610285609c5481565b3480156103ac57600080fd5b5061032d6103bb36600461337f565b610c00565b3480156103cc57600080fd5b506104176103db366004613411565b609e602052600090815260409020805460018201546002909201546001600160801b03821692600160801b9092046001600160401b0316919084565b604080516001600160801b0390951685526001600160401b03909316602085015291830152606082015260800161028f565b34801561045557600080fd5b5061035a6104643660046133d1565b610cef565b34801561047557600080fd5b5061021e6104843660046134e1565b610d1a565b34801561049557600080fd5b5060a154610285565b3480156104aa57600080fd5b506104b3610d47565b6040805192835260208301919091520161028f565b3480156104d457600080fd5b50609b546104ea90600160b01b900461ffff1681565b60405161ffff909116815260200161028f565b34801561050957600080fd5b506040516001815260200161028f565b34801561052557600080fd5b50610285600081565b34801561053a57600080fd5b5061035a6105493660046133d1565b610dd4565b61021e61055c3660046133a1565b610e2a565b34801561056d57600080fd5b5061058161057c366004613515565b610e3b565b60405161028f91906135d9565b34801561059a57600080fd5b5061021e6105a9366004613654565b610fae565b3480156105ba57600080fd5b50609b546104ea90600160a01b900461ffff1681565b3480156105dc57600080fd5b506104b36105eb366004613411565b61110a565b3480156105fc57600080fd5b5061028561060b3660046133a1565b611137565b34801561061c57600080fd5b5069546f6b656e5374616b6560b01b610285565b34801561063c57600080fd5b5061021e61064b3660046133a1565b6111c0565b34801561065c57600080fd5b5061021e61066b3660046133d1565b6113ad565b34801561067c57600080fd5b506106856113c6565b6040516001600160501b03909116815260200161028f565b3480156106a957600080fd5b5061021e6106b836600461366f565b611416565b3480156106c957600080fd5b506106d261171e565b60405161028f9190613798565b3480156106eb57600080fd5b5060a05461032d906001600160a01b031681565b6107076117ac565b6107235760405162461bcd60e51b8152600401610215906137ab565b6000609f60006001609b60189054906101000a90046001600160401b031661074b91906137e9565b6001600160401b031681526020808201929092526040908101600020815160a08101835281546001600160501b038082168352600160501b8204811695830195909552600160a01b9004909316918301919091526001810154606083018190526002909101546080830152909150831415806107cb575080608001518214155b6108115760405162461bcd60e51b81526020600482015260176024820152762932bbb0b932103930ba34b7903ab731b430b733b2b21760491b6044820152606401610215565b805161081e9084846117bf565b60608082015160808084015160408051938452602084018890528301529181018490527feb6684a1e7c9bd2adc792fb253558f022bcbef39fb6ad31dc58cdfefdd5b5190910160405180910390a1505050565b61087961197d565b61088660006104646119d6565b6108a25760405162461bcd60e51b8152600401610215906137ab565b60a0546000906001600160a01b031673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee146108dc5760a0546001600160a01b03166108fe565b7f000000000000000000000000d23e77b7e1726577006799b7194b6ae31958a8395b90506000816001600160a01b03166370a08231306040518263ffffffff1660e01b815260040161092e91906133fd565b602060405180830381865afa15801561094b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061096f9190613810565b60a0549091506109b2906001600160a01b031661098a6119d6565b30867f000000000000000000000000d23e77b7e1726577006799b7194b6ae31958a8396119e0565b600081836001600160a01b03166370a08231306040518263ffffffff1660e01b81526004016109e191906133fd565b602060405180830381865afa1580156109fe573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a229190613810565b610a2c9190613829565b90508060a16000828254610a40919061383c565b90915550506040518181527ff9d14e57815939d300bc94720ede00c8c8e08d254ab28e2917ea46e149aa119b9060200160405180910390a1505050610a856001606955565b50565b610a9061197d565b610a9981611b58565b610a856001606955565b600082815260036020526040902054610abc9033611e73565b60008281526002602090815260408083206001600160a01b038516845290915290205460ff1615610b2f5760405162461bcd60e51b815260206004820152601d60248201527f43616e206f6e6c79206772616e7420746f206e6f6e20686f6c646572730000006044820152606401610215565b610b398282611ef3565b5050565b336001600160a01b03821614610b925760405162461bcd60e51b815260206004820152601a60248201527921b0b71037b7363c903932b737bab731b2903337b91039b2b63360311b6044820152606401610215565b610b398282611f07565b610ba461197d565b610bac611f5e565b610bb66001606955565b565b609d8181548110610bc857600080fd5b6000918252602090912001546001600160a01b0316905081565b6001600160a01b031660009081526037602052604090205460ff1690565b60008281526004602052604081205481805b82811015610ce55760008681526004602090815260408083208484526001019091529020546001600160a01b031615610c8e57848203610c7c5760008681526004602090815260408083209383526001909301905220546001600160a01b03169250610ce9915050565b610c8760018361383c565b9150610cd3565b610c99866000610cef565b8015610cc05750600086815260046020908152604080832083805260020190915290205481145b15610cd357610cd060018361383c565b91505b610cde60018261383c565b9050610c12565b5050505b92915050565b60009182526002602090815260408084206001600160a01b0393909316845291905290205460ff1690565b610d226117ac565b610d3e5760405162461bcd60e51b8152600401610215906137ab565b610a858161212c565b600080609f60006001609b60189054906101000a90046001600160401b0316610d7091906137e9565b6001600160401b03168152602001908152602001600020600101549150609f60006001609b60189054906101000a90046001600160401b0316610db391906137e9565b6001600160401b031681526020019081526020016000206002015490509091565b600082815260026020908152604080832083805290915281205460ff16610e21575060008281526002602090815260408083206001600160a01b038516845290915290205460ff16610ce9565b50600192915050565b610e3261197d565b610a99816121fc565b6060816001600160401b03811115610e5557610e5561342c565b604051908082528060200260200182016040528015610e8857816020015b6060815260200190600190039081610e735790505b5090506000610e956119d6565b9050336001600160a01b038216141560005b84811015610ce5578115610f2657610f0430878784818110610ecb57610ecb61384f565b9050602002810190610edd9190613865565b86604051602001610ef0939291906138ab565b6040516020818303038152906040526125cc565b848281518110610f1657610f1661384f565b6020026020010181905250610fa6565b610f8830878784818110610f3c57610f3c61384f565b9050602002810190610f4e9190613865565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506125cc92505050565b848281518110610f9a57610f9a61384f565b60200260200101819052505b600101610ea7565b610fb66117ac565b610fd25760405162461bcd60e51b8152600401610215906137ab565b6000609f60006001609b60189054906101000a90046001600160401b0316610ffa91906137e9565b6001600160401b031681526020808201929092526040908101600020815160a08101835281546001600160501b03808216808452600160501b8304821696840196909652600160a01b90910481169382019390935260018201546060820152600290910154608082015292508316036110ac5760405162461bcd60e51b81526020600482015260146024820152732a34b6b296bab734ba103ab731b430b733b2b21760611b6044820152606401610215565b6110bf82826060015183608001516117bf565b8051604080516001600160501b03928316815291841660208301527fd968de290ed68f978b9e4816f7d4be9ef46189fe8eeb3eeb86199e7229cf2de091015b60405180910390a15050565b6001600160a01b0381166000908152609e602052604081206001015490611130836125f8565b9050915091565b600081815260046020526040812054815b8181101561119b5760008481526004602090815260408083208484526001019091529020546001600160a01b0316156111895761118660018461383c565b92505b61119460018261383c565b9050611148565b506111a7836000610cef565b156111ba576111b760018361383c565b91505b50919050565b6111c861197d565b6111d560006104646119d6565b6111f15760405162461bcd60e51b8152600401610215906137ab565b60a154811161120d578060a1546112089190613829565b611210565b60005b60a15560a054611253906001600160a01b03163061122c6119d6565b847f000000000000000000000000d23e77b7e1726577006799b7194b6ae31958a8396119e0565b609b546000906001600160a01b031673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee1461128d57609b546001600160a01b03166112af565b7f000000000000000000000000d23e77b7e1726577006799b7194b6ae31958a8395b9050609c54816001600160a01b03166370a08231306040518263ffffffff1660e01b81526004016112e091906133fd565b602060405180830381865afa1580156112fd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113219190613810565b101561136f5760405162461bcd60e51b815260206004820152601e60248201527f5374616b696e6720746f6b656e2062616c616e636520726564756365642e00006044820152606401610215565b6040518281527f37ff8766c704931c4283e470feb7c20ddcd8aa492746f74b30503709a0452acd9060200160405180910390a150610a856001606955565b600082815260036020526040902054610b929033611e73565b6000609f60006001609b60189054906101000a90046001600160401b03166113ee91906137e9565b6001600160401b031681526020810191909152604001600020546001600160501b0316919050565b600054610100900460ff16158080156114365750600054600160ff909116105b80611457575061144530612670565b158015611457575060005460ff166001145b6114ba5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610215565b6000805460ff1916600117905580156114dd576000805461ff0019166101001790555b6114e68761267f565b846001600160a01b0316866001600160a01b03160361155d5760405162461bcd60e51b815260206004820152602d60248201527f52657761726420546f6b656e20616e64205374616b696e6720546f6b656e206360448201526c30b713ba1031329039b0b6b29760991b6064820152608401610215565b60a080546001600160a01b0319166001600160a01b038881169190911790915560009073eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee9087161461160457856001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156115db573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115ff91906138cc565b611607565b60125b60ff16905060006001600160a01b03881673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee1461169957876001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015611670573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061169491906138cc565b61169c565b60125b60ff1690506116ac878383612704565b6116b78686866117bf565b6116c08a61212c565b6116cb60008c611ef3565b50508015611713576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b505050505050505050565b6001805461172b906138ef565b80601f0160208091040260200160405190810160405280929190818152602001828054611757906138ef565b80156117a45780601f10611779576101008083540402835291602001916117a4565b820191906000526020600020905b81548152906001019060200180831161178757829003601f168201915b505050505081565b60006117ba816104646119d6565b905090565b806000036117fd5760405162461bcd60e51b815260206004820152600b60248201526a064697669646520627920360ac1b6044820152606401610215565b826001600160501b031660000361184d5760405162461bcd60e51b8152602060048201526014602482015273074696d652d756e69742063616e277420626520360641b6044820152606401610215565b609b8054600160c01b90046001600160401b03169060019060186118718385613923565b82546001600160401b039182166101009390930a9283029190920219909116179055506040805160a0810182526001600160501b03808716825242811660208084019182526000848601818152606086018a8152608087018a8152898452609f9094529690912094518554935191518516600160a01b02600160a01b600160f01b0319928616600160501b026001600160a01b03199095169190951617929092179190911691909117825591516001820155905160029091015580156119775742609f6000611941600185613829565b815260200190815260200160002060000160146101000a8154816001600160501b0302191690836001600160501b031602179055505b50505050565b6002606954036119cf5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610215565b6002606955565b60006117ba61280e565b8115611b4a5773eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeed196001600160a01b03861601611b3e57306001600160a01b03851603611a8557604051632e1a7d4d60e01b8152600481018390526001600160a01b03821690632e1a7d4d90602401600060405180830381600087803b158015611a5d57600080fd5b505af1158015611a71573d6000803e3d6000fd5b50505050611a80838383612830565b611b4a565b306001600160a01b03841603611b3357348214611ada5760405162461bcd60e51b81526020600482015260136024820152721b5cd9cb9d985b1d5948084f48185b5bdd5b9d606a1b6044820152606401610215565b806001600160a01b031663d0e30db0836040518263ffffffff1660e01b81526004016000604051808303818588803b158015611b1557600080fd5b505af1158015611b29573d6000803e3d6000fd5b5050505050611b4a565b611a80838383612830565b611b4a858585856128f5565b5050505050565b6001606955565b6000609e6000611b6661294d565b6001600160a01b03166001600160a01b0316815260200190815260200160002060010154905081600003611bd35760405162461bcd60e51b81526020600482015260146024820152735769746864726177696e67203020746f6b656e7360601b6044820152606401610215565b81811015611c225760405162461bcd60e51b815260206004820152601c60248201527b15da5d1a191c985dda5b99c81b5bdc99481d1a185b881cdd185ad95960221b6044820152606401610215565b611c32611c2d61294d565b612957565b818103611d88576000609d805480602002602001604051908101604052809291908181526020018280548015611c9157602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611c73575b5050505050905060005b8151811015611d8557611cac61294d565b6001600160a01b0316828281518110611cc757611cc761384f565b60200260200101516001600160a01b031603611d7d578160018351611cec9190613829565b81518110611cfc57611cfc61384f565b6020026020010151609d8281548110611d1757611d1761384f565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550609d805480611d5657611d56613943565b600082815260209020810160001990810180546001600160a01b0319169055019055611d85565b600101611c9b565b50505b81609e6000611d9561294d565b6001600160a01b03166001600160a01b031681526020019081526020016000206001016000828254611dc79190613829565b9250508190555081609c6000828254611de09190613829565b9091555050609b54611e25906001600160a01b031630611dfe61294d565b857f000000000000000000000000d23e77b7e1726577006799b7194b6ae31958a8396119e0565b611e2d61294d565b6001600160a01b03167f6352c5382c4a4578e712449ca65e83cdb392d045dfcf1cad9615189db2da244b83604051611e6791815260200190565b60405180910390a25050565b60008281526002602090815260408083206001600160a01b038516845290915290205460ff16610b3957611eb1816001600160a01b03166014612a2e565b611ebc836020612a2e565b604051602001611ecd929190613959565b60408051601f198184030181529082905262461bcd60e51b825261021591600401613798565b611efd8282612bc9565b610b398282612c24565b611f118282612c91565b60008281526004602090815260408083206001600160a01b03851680855260028201808552838620805487526001909301855292852080546001600160a01b031916905584529152555050565b6000611f70611f6b61294d565b612cf3565b609e6000611f7c61294d565b6001600160a01b03166001600160a01b0316815260200190815260200160002060020154611faa919061383c565b905080600003611fe95760405162461bcd60e51b815260206004820152600a6024820152694e6f207265776172647360b01b6044820152606401610215565b426001600160501b0316609e6000611fff61294d565b6001600160a01b031681526020810191909152604001600090812080546001600160801b0319166001600160801b039390931692909217909155609e8161204461294d565b6001600160a01b03168152602081019190915260400160002060020155609b5461208090600190600160c01b90046001600160401b03166137e9565b609e600061208c61294d565b6001600160a01b03168152602081019190915260400160002080546001600160401b0392909216600160801b02600160801b600160c01b03199092169190911790556120df6120d961294d565b82612f0e565b6120e761294d565b6001600160a01b03167ffc30cddea38e2bf4d6ea7d3f9ed3b6ad7f176419f4963bd81318067a4aee73fe8260405161212191815260200190565b60405180910390a250565b60006001805461213b906138ef565b80601f0160208091040260200160405190810160405280929190818152602001828054612167906138ef565b80156121b45780601f10612189576101008083540402835291602001916121b4565b820191906000526020600020905b81548152906001019060200180831161219757829003601f168201915b5050505050905081600190816121ca9190613a16565b507fc9c7c3fe08b88b4df9d4d47ef47d2c43d55c025a0ba88ca442580ed9e7348a1681836040516110fe929190613ad5565b8060000361223f5760405162461bcd60e51b815260206004820152601060248201526f5374616b696e67203020746f6b656e7360801b6044820152606401610215565b609b546000906001600160a01b031673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeed190161229057507f000000000000000000000000d23e77b7e1726577006799b7194b6ae31958a8396122da565b34156122cc5760405162461bcd60e51b815260206004820152600b60248201526a056616c7565206e6f7420360ac1b6044820152606401610215565b50609b546001600160a01b03165b6000609e60006122e861294d565b6001600160a01b03166001600160a01b031681526020019081526020016000206001015411156123225761231d611c2d61294d565b612417565b609d61232c61294d565b81546001810183556000928352602083200180546001600160a01b0319166001600160a01b0392909216919091179055426001600160501b031690609e9061237261294d565b6001600160a01b03168152602081019190915260400160002080546001600160801b0319166001600160801b0392909216919091179055609b546123c890600190600160c01b90046001600160401b03166137e9565b609e60006123d461294d565b6001600160a01b03168152602081019190915260400160002080546001600160401b0392909216600160801b02600160801b600160c01b03199092169190911790555b6040516370a0823160e01b81526000906001600160a01b038316906370a08231906124469030906004016133fd565b602060405180830381865afa158015612463573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124879190613810565b609b549091506124a2906001600160a01b031661098a61294d565b600081836001600160a01b03166370a08231306040518263ffffffff1660e01b81526004016124d191906133fd565b602060405180830381865afa1580156124ee573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125129190613810565b61251c9190613829565b905080609e600061252b61294d565b6001600160a01b03166001600160a01b03168152602001908152602001600020600101600082825461255d919061383c565b9250508190555080609c6000828254612576919061383c565b90915550612584905061294d565b6001600160a01b03167fb539ca1e5c8d398ddf1c41c30166f33404941683be4683319b57669a93dad4ef826040516125be91815260200190565b60405180910390a250505050565b60606125f18383604051806060016040528060278152602001613cde60279139612fab565b9392505050565b6001600160a01b0381166000908152609e6020526040812060010154810361263957506001600160a01b03166000908152609e602052604090206002015490565b61264282612cf3565b6001600160a01b0383166000908152609e6020526040902060020154612668919061383c565b90505b919050565b6001600160a01b03163b151590565b600054610100900460ff166126a65760405162461bcd60e51b815260040161021590613afa565b60005b8151811015610b39576001603760008484815181106126ca576126ca61384f565b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff19169115159190911790556001016126a9565b600054610100900460ff1661272b5760405162461bcd60e51b815260040161021590613afa565b612733613023565b6001600160a01b03831661277b5760405162461bcd60e51b815260206004820152600f60248201526e0746f6b656e2061646472657373203608c1b6044820152606401610215565b61ffff821615801590612791575061ffff811615155b6127ca5760405162461bcd60e51b815260206004820152600a6024820152690646563696d616c7320360b41b6044820152606401610215565b609b80546001600160a01b03949094166001600160b01b031990941693909317600160a01b61ffff938416021761ffff60b01b1916600160b01b9190921602179055565b600061281933610be2565b1561282b575060131936013560601c90565b503390565b6000836001600160a01b03168360405160006040518083038185875af1925050503d806000811461287d576040519150601f19603f3d011682016040523d82523d6000602084013e612882565b606091505b505090508061197757816001600160a01b031663d0e30db0846040518263ffffffff1660e01b81526004016000604051808303818588803b1580156128c657600080fd5b505af11580156128da573d6000803e3d6000fd5b50611977935050506001600160a01b03841690508585613052565b816001600160a01b0316836001600160a01b0316031561197757306001600160a01b03841603612938576129336001600160a01b0385168383613052565b611977565b6119776001600160a01b0385168484846130ba565b60006117ba6119d6565b600061296282612cf3565b6001600160a01b0383166000908152609e602052604081206002018054929350839290919061299290849061383c565b90915550506001600160a01b0382166000908152609e6020526040902080546001600160801b0319166001600160501b034216179055609b546129e8906001906001600160401b03600160c01b909104166137e9565b6001600160a01b039092166000908152609e6020526040902080546001600160401b0393909316600160801b02600160801b600160c01b03199093169290921790915550565b60606000612a3d836002613b45565b612a4890600261383c565b6001600160401b03811115612a5f57612a5f61342c565b6040519080825280601f01601f191660200182016040528015612a89576020820181803683370190505b509050600360fc1b81600081518110612aa457612aa461384f565b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110612ad357612ad361384f565b60200101906001600160f81b031916908160001a9053506000612af7846002613b45565b612b0290600161383c565b90505b6001811115612b7a576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110612b3657612b3661384f565b1a60f81b828281518110612b4c57612b4c61384f565b60200101906001600160f81b031916908160001a90535060049490941c93612b7381613b5c565b9050612b05565b5083156125f15760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610215565b60008281526002602090815260408083206001600160a01b0385168085529252808320805460ff1916600117905551339285917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9190a45050565b600082815260046020526040812080549160019190612c43838561383c565b9091555050600092835260046020908152604080852083865260018101835281862080546001600160a01b039096166001600160a01b03199096168617905593855260029093019052912055565b612c9b8282611e73565b60008281526002602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6001600160a01b0381166000908152609e60209081526040808320815160808101835281546001600160801b03811682526001600160401b03600160801b90910481169482018590526001830154938201939093526002909101546060820152609b54909291600160c01b90910416815b81811015612eb9576000818152609f60209081526040808320815160a08101835281546001600160501b038082168352600160501b8204811695830195909552600160a01b9004909316918301919091526001810154606083015260020154608082015290848303612dd7578551612de6565b81602001516001600160501b03165b6001600160801b03169050600082604001516001600160501b0316600003612e0e5742612e1d565b82604001516001600160501b03165b9050600080612e4a89604001518585612e369190613829565b612e409190613b45565b86606001516130f2565b91509150600080612e828c886080015189600001516001600160501b031686612e739190613b89565b612e7d9190613b89565b61313d565b91509150838015612e905750815b612e9a578b612e9c565b805b9b5050505050505050600181612eb2919061383c565b9050612d64565b50609b54612ede908590612ed990600160b01b900461ffff16600a613c8f565b6130f2565b609b54909550612efb9150600160a01b900461ffff16600a613c8f565b612f059085613b89565b95945050505050565b60a154811115612f5b5760405162461bcd60e51b81526020600482015260186024820152774e6f7420656e6f7567682072657761726420746f6b656e7360401b6044820152606401610215565b8060a16000828254612f6d9190613829565b909155505060a054610b39906001600160a01b03163084847f000000000000000000000000d23e77b7e1726577006799b7194b6ae31958a8396119e0565b6060600080856001600160a01b031685604051612fc89190613c9f565b600060405180830381855af49150503d8060008114613003576040519150601f19603f3d011682016040523d82523d6000602084013e613008565b606091505b509150915061301986838387613158565b9695505050505050565b600054610100900460ff1661304a5760405162461bcd60e51b815260040161021590613afa565b610bb66131d7565b6040516001600160a01b0383166024820152604481018290526130b590849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091526131fe565b505050565b6040516001600160a01b03808516602483015283166044820152606481018290526119779085906323b872dd60e01b9060840161307e565b600080836000036131095750600190506000613136565b8383028385828161311c5761311c613b73565b041461312f576000809250925050613136565b6001925090505b9250929050565b6000808383018481101561312f576000809250925050613136565b606083156131c55782516000036131be5761317285612670565b6131be5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610215565b50816131cf565b6131cf83836132d0565b949350505050565b600054610100900460ff16611b515760405162461bcd60e51b815260040161021590613afa565b6000613253826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166132fa9092919063ffffffff16565b8051909150156130b557808060200190518101906132719190613cbb565b6130b55760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610215565b8151156132e05781518083602001fd5b8060405162461bcd60e51b81526004016102159190613798565b60606131cf848460008585600080866001600160a01b031685876040516133219190613c9f565b60006040518083038185875af1925050503d806000811461335e576040519150601f19603f3d011682016040523d82523d6000602084013e613363565b606091505b509150915061337487838387613158565b979650505050505050565b6000806040838503121561339257600080fd5b50508035926020909101359150565b6000602082840312156133b357600080fd5b5035919050565b80356001600160a01b038116811461266b57600080fd5b600080604083850312156133e457600080fd5b823591506133f4602084016133ba565b90509250929050565b6001600160a01b0391909116815260200190565b60006020828403121561342357600080fd5b6125f1826133ba565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b038111828210171561346a5761346a61342c565b604052919050565b600082601f83011261348357600080fd5b81356001600160401b0381111561349c5761349c61342c565b6134af601f8201601f1916602001613442565b8181528460208386010111156134c457600080fd5b816020850160208301376000918101602001919091529392505050565b6000602082840312156134f357600080fd5b81356001600160401b0381111561350957600080fd5b6131cf84828501613472565b6000806020838503121561352857600080fd5b82356001600160401b038082111561353f57600080fd5b818501915085601f83011261355357600080fd5b81358181111561356257600080fd5b8660208260051b850101111561357757600080fd5b60209290920196919550909350505050565b60005b838110156135a457818101518382015260200161358c565b50506000910152565b600081518084526135c5816020860160208601613589565b601f01601f19169290920160200192915050565b600060208083016020845280855180835260408601915060408160051b87010192506020870160005b8281101561363057603f1988860301845261361e8583516135ad565b94509285019290850190600101613602565b5092979650505050505050565b80356001600160501b038116811461266b57600080fd5b60006020828403121561366657600080fd5b6125f18261363d565b600080600080600080600080610100898b03121561368c57600080fd5b613695896133ba565b97506020808a01356001600160401b03808211156136b257600080fd5b6136be8d838e01613472565b995060408c01359150808211156136d457600080fd5b818c0191508c601f8301126136e857600080fd5b8135818111156136fa576136fa61342c565b8060051b915061370b848301613442565b818152918301840191848101908f84111561372557600080fd5b938501935b8385101561374a5761373b856133ba565b8252938501939085019061372a565b809b5050505050505061375f60608a016133ba565b945061376d60808a016133ba565b935061377b60a08a0161363d565b925060c0890135915060e089013590509295985092959890939650565b6020815260006125f160208301846135ad565b6020808252600e908201526d139bdd08185d5d1a1bdc9a5e995960921b604082015260600190565b634e487b7160e01b600052601160045260246000fd5b6001600160401b03828116828216039080821115613809576138096137d3565b5092915050565b60006020828403121561382257600080fd5b5051919050565b81810381811115610ce957610ce96137d3565b80820180821115610ce957610ce96137d3565b634e487b7160e01b600052603260045260246000fd5b6000808335601e1984360301811261387c57600080fd5b8301803591506001600160401b0382111561389657600080fd5b60200191503681900382131561313657600080fd5b8284823760609190911b6001600160601b0319169101908152601401919050565b6000602082840312156138de57600080fd5b815160ff811681146125f157600080fd5b600181811c9082168061390357607f821691505b6020821081036111ba57634e487b7160e01b600052602260045260246000fd5b6001600160401b03818116838216019080821115613809576138096137d3565b634e487b7160e01b600052603160045260246000fd5b7402832b936b4b9b9b4b7b7399d1030b1b1b7bab73a1605d1b815260008351613989816015850160208801613589565b7001034b99036b4b9b9b4b733903937b6329607d1b60159184019182015283516139ba816026840160208801613589565b01602601949350505050565b601f8211156130b5576000816000526020600020601f850160051c810160208610156139ef5750805b601f850160051c820191505b81811015613a0e578281556001016139fb565b505050505050565b81516001600160401b03811115613a2f57613a2f61342c565b613a4381613a3d84546138ef565b846139c6565b602080601f831160018114613a785760008415613a605750858301515b600019600386901b1c1916600185901b178555613a0e565b600085815260208120601f198616915b82811015613aa757888601518255948401946001909101908401613a88565b5085821015613ac55787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b604081526000613ae860408301856135ad565b8281036020840152612f0581856135ad565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b8082028115828204841417610ce957610ce96137d3565b600081613b6b57613b6b6137d3565b506000190190565b634e487b7160e01b600052601260045260246000fd5b600082613ba657634e487b7160e01b600052601260045260246000fd5b500490565b600181815b80851115613be6578160001904821115613bcc57613bcc6137d3565b80851615613bd957918102915b93841c9390800290613bb0565b509250929050565b600082613bfd57506001610ce9565b81613c0a57506000610ce9565b8160018114613c205760028114613c2a57613c46565b6001915050610ce9565b60ff841115613c3b57613c3b6137d3565b50506001821b610ce9565b5060208310610133831016604e8410600b8410161715613c69575081810a610ce9565b613c738383613bab565b8060001904821115613c8757613c876137d3565b029392505050565b60006125f161ffff841683613bee565b60008251613cb1818460208701613589565b9190910192915050565b600060208284031215613ccd57600080fd5b815180151581146125f157600080fdfe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212208a05a45507e2c645ea742e1dde2361088156136845f3eb865a9b1cebc4ef909c64736f6c63430008170033