Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
- Contract name:
- Staking
- Optimization enabled
- true
- Compiler version
- v0.8.18+commit.87f61d96
- Optimization runs
- 200
- EVM Version
- default
- Verified at
- 2024-12-21T17:18:14.691837Z
Staking.sol
// Sources flattened with hardhat v2.19.2 https://hardhat.org // SPDX-License-Identifier: MIT // File @openzeppelin/contracts-upgradeable/utils/[email protected] // Original license: 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); } } } // File @openzeppelin/contracts-upgradeable/proxy/utils/[email protected] // Original license: SPDX_License_Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol) pragma solidity ^0.8.2; /** * @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; } } // File @openzeppelin/contracts-upgradeable/utils/[email protected] // Original license: SPDX_License_Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.4) (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract 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; } function _contextSuffixLength() internal view virtual returns (uint256) { return 0; } /** * @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; } // File @openzeppelin/contracts-upgradeable/access/[email protected] // Original license: SPDX_License_Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol) pragma solidity ^0.8.0; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ function __Ownable_init() internal onlyInitializing { __Ownable_init_unchained(); } function __Ownable_init_unchained() internal onlyInitializing { _transferOwnership(_msgSender()); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { _checkOwner(); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { require(owner() == _msgSender(), "Ownable: caller is not the owner"); } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby disabling any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } /** * @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; } // File @openzeppelin/contracts-upgradeable/security/[email protected] // Original license: SPDX_License_Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol) pragma solidity ^0.8.0; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract PausableUpgradeable is Initializable, ContextUpgradeable { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ function __Pausable_init() internal onlyInitializing { __Pausable_init_unchained(); } function __Pausable_init_unchained() internal onlyInitializing { _paused = false; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { _requireNotPaused(); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { _requirePaused(); _; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Throws if the contract is paused. */ function _requireNotPaused() internal view virtual { require(!paused(), "Pausable: paused"); } /** * @dev Throws if the contract is not paused. */ function _requirePaused() internal view virtual { require(paused(), "Pausable: not paused"); } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } /** * @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; } // File @openzeppelin/contracts-upgradeable/token/ERC20/extensions/[email protected] // Original license: SPDX_License_Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.4) (token/ERC20/extensions/IERC20Permit.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. * * ==== Security Considerations * * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be * considered as an intention to spend the allowance in any specific way. The second is that because permits have * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be * generally recommended is: * * ```solidity * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public { * try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {} * doThing(..., value); * } * * function doThing(..., uint256 value) public { * token.safeTransferFrom(msg.sender, address(this), value); * ... * } * ``` * * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also * {SafeERC20-safeTransferFrom}). * * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so * contracts should have entry points that don't rely on permit. */ interface IERC20PermitUpgradeable { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. * * CAUTION: See Security Considerations above. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); } // File @openzeppelin/contracts-upgradeable/token/ERC20/[email protected] // Original license: 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 IERC20Upgradeable { /** * @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); } // File @openzeppelin/contracts-upgradeable/token/ERC20/utils/[email protected] // Original license: SPDX_License_Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; /** * @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 SafeERC20Upgradeable { using AddressUpgradeable for address; /** * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeTransfer(IERC20Upgradeable token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } /** * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful. */ function safeTransferFrom(IERC20Upgradeable 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(IERC20Upgradeable token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } /** * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeIncreaseAllowance(IERC20Upgradeable token, address spender, uint256 value) internal { uint256 oldAllowance = token.allowance(address(this), spender); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value)); } /** * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeDecreaseAllowance(IERC20Upgradeable token, address spender, uint256 value) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value)); } } /** * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval * to be set to zero before setting it to a non-zero value, such as USDT. */ function forceApprove(IERC20Upgradeable token, address spender, uint256 value) internal { bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value); if (!_callOptionalReturnBool(token, approvalCall)) { _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0)); _callOptionalReturn(token, approvalCall); } } /** * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`. * Revert on invalid signature. */ function safePermit( IERC20PermitUpgradeable token, address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) internal { uint256 nonceBefore = token.nonces(owner); token.permit(owner, spender, value, deadline, v, r, s); uint256 nonceAfter = token.nonces(owner); require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed"); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). * * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead. */ function _callOptionalReturnBool(IERC20Upgradeable token, bytes memory data) private returns (bool) { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false // and not revert is the subcall reverts. (bool success, bytes memory returndata) = address(token).call(data); return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && AddressUpgradeable.isContract(address(token)); } } // File @openzeppelin/contracts-upgradeable/utils/structs/[email protected] // Original license: SPDX_License_Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/structs/EnumerableSet.sol) // This file was procedurally generated from scripts/generate/templates/EnumerableSet.js. pragma solidity ^0.8.0; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ```solidity * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. * * [WARNING] * ==== * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure * unusable. * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info. * * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an * array of EnumerableSet. * ==== */ library EnumerableSetUpgradeable { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping(bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; if (lastIndex != toDeleteIndex) { bytes32 lastValue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastValue; // Update the index for the moved value set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex } // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { return set._values[index]; } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function _values(Set storage set) private view returns (bytes32[] memory) { return set._values; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(Bytes32Set storage set) internal view returns (bytes32[] memory) { bytes32[] memory store = _values(set._inner); bytes32[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(AddressSet storage set) internal view returns (address[] memory) { bytes32[] memory store = _values(set._inner); address[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values in the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(UintSet storage set) internal view returns (uint256[] memory) { bytes32[] memory store = _values(set._inner); uint256[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } } // File contracts/Staking/Staking.sol // Original license: SPDX_License_Identifier: MIT pragma solidity =0.8.18; /** * @title Staking * @author gotbit * @notice Contract for staking tokens in order to earn rewards. * Any user can make multiple stakes. Reward earn period is practically unlimited. */ contract Staking is OwnableUpgradeable, PausableUpgradeable { using SafeERC20Upgradeable for IERC20Upgradeable; using EnumerableSetUpgradeable for EnumerableSetUpgradeable.UintSet; using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet; // TYPES struct Stake { uint256 id; uint256 amount; uint256 earned; uint256 claimed; uint256 userRewardPerTokenPaid; address owner; uint32 timestamp; uint32 unstakedAtBlockNumber; uint32 unstakedAtBlockTimestamp; } // CONSTANTS uint256 public constant ACCURACY = 1e18; uint256 public constant TREASURY_STAKE_AMOUNT = 1; // 1 wei (to simplify calculations) uint256 public constant MIN_REWARDS_DURATION = 1 minutes; // 1 min uint256 public constant MAX_STAKE = 10 ** 30; // reward rate will not fall into overflow // even if reward is being added during 1000 min possible reward periods in a row uint256 public constant MAX_RATE = type(uint128).max / (1000 * MIN_REWARDS_DURATION); uint256 public constant MAX_REWARDS_DURATION = 10 * 365 days; // 10 years (to prevent overflow) // STATE VARIABLES IERC20Upgradeable public stakingToken; IERC20Upgradeable public rewardToken; uint128 public rewardRate; uint128 public rewardsRemaining; uint256 public rewardPerTokenStored; uint64 public periodFinish; // rewardsDuration is not always equal to periodFinish - periodStart uint64 public rewardsDuration; uint64 public lastUpdateTime; // variable for correct reward calculations in case of rewardsDuration changes uint64 public periodStart; // sum of all rewards distributed to users in all periods uint256 public cumulativeDistributedReward; // sum of claimed reawards in one current reward period uint256 public currentRewardPaid; // sum of claimed reawards in all reward periods uint256 public cumulativeRewardPaid; // sum of unused rewards by all users in all owner locks in the current period // unused reward is set = 0 in each notify uint256 public currentPeriodUnusedRewardsSum; uint256 public unusedRewardsExtracted; mapping(uint256 => Stake) public stakes; mapping(address => uint256[]) public userInactiveStakes; mapping(address => EnumerableSetUpgradeable.UintSet) private idsByUser; mapping(address => uint256) public userBalances; uint256 public globalId; // hide real total supply uint256 private totalSupplyInternal; // number of currenlty active stakes uint128 private numOfActiveStakesInternal; // first reward period creation timestamp uint128 public firstRewardPeriodStart; // active stake holder EnumerableSetUpgradeable.AddressSet private holders; bool public finished; // EVENTS event RewardAdded(uint256 reward); event Staked( address indexed user, uint256 indexed id, uint256 amount, uint256 totalSupply ); event Withdrawn( address indexed user, uint256 indexed id, uint256 amount, uint256 totalSupply ); event RewardPaid(address indexed user, uint256 indexed id, uint256 reward); event RewardsDurationUpdated(uint256 indexed newDuration); event Finished(address indexed recepient); event WithdrawnTokens(address indexed recepient, uint256 indexed amount); // FUNCTIONS constructor() { _disableInitializers(); } // external /// @notice Inits a new contract /// @param stakingToken_ staking token address /// @param rewardToken_ reward token address /// @param owner_ owner address function init( IERC20Upgradeable stakingToken_, IERC20Upgradeable rewardToken_, address owner_ ) external initializer { require(address(stakingToken_) != address(0), 'Invalid address'); require(address(rewardToken_) != address(0), 'Invalid address'); require(owner_ != address(0), 'Invalid address'); stakingToken = stakingToken_; rewardToken = rewardToken_; rewardsDuration = 365 days; _transferOwnership(owner_); } /// @dev Allows user to stake tokens /// @param amount of token to stake function stake(uint256 amount) external whenNotPaused { require(amount > 0, 'Cannot stake 0'); require(amount <= MAX_STAKE, 'Stake amount too high'); require(periodFinish > block.timestamp, 'Reward period not activated'); // if no active stakers were previously => unstake owner stake to stop accumulating unused rewards if (totalSupply() == 0) { // change stakes[0].earned _updateReward(0, true); (, uint256 unusedRewards) = _withdrawInternal(0, address(this)); currentPeriodUnusedRewardsSum += unusedRewards; } else { // do not change stakes[0] _updateReward(0, false); } // execute stake _stakeInternal(amount, msg.sender); emit Staked(msg.sender, globalId, amount, totalSupply()); stakingToken.safeTransferFrom(msg.sender, address(this), amount); } /// @dev Allows user to withdraw staked tokens + claim earned rewards /// @param id Stake id function withdraw(uint256 id) external { _updateReward(id, true); // CHANGE STATE & EXECUTE ALL CHECKS (uint256 amount, uint256 reward) = _withdrawInternal(id, msg.sender); // if no active stakers left => create a owner stake to accumulate unused rewards if (totalSupply() == 0) { _stakeInternal(TREASURY_STAKE_AMOUNT, address(this)); } emit Withdrawn(msg.sender, id, amount, totalSupply()); // ALL TOKENS TRANSFERS ------------------------------------------------------- // REWARDS emit RewardPaid(msg.sender, id, reward); if (reward != 0) { rewardToken.safeTransfer(msg.sender, reward); } // PRINCIPAL stakingToken.safeTransfer(msg.sender, amount); } /// @dev Allows user to claim earned rewards without unstaking the position /// @param id Stake id function claim(uint256 id) external { _updateReward(id, true); // CHANGE STATE & EXECUTE ALL CHECKS uint256 reward = _claimInternal(id, msg.sender); require(reward != 0, 'Nothing to claim'); // ALL TOKENS TRANSFERS ------------------------------------------------------- // REWARDS emit RewardPaid(msg.sender, id, reward); // reward != 0 due to technical design rewardToken.safeTransfer(msg.sender, reward); } /// @dev Allows owner to set new reward rate /// @param newRewardRate is amount of token weis will be distributed per second (rewards / rewardsDuration) function notifyRewardAmount(uint128 newRewardRate) external onlyOwner { _updateReward(0, false); _notifyRewardAmount(newRewardRate); } /// @dev Allows owner to set previous reward rate function notifyRewardAmountPrevious() external onlyOwner { _updateReward(0, false); uint128 rate = rewardRate; require(rate != 0, 'Previous reward rate is too low'); _notifyRewardAmount(rate); } /// @dev Allows owner to stop staking and extract extra liquidity /// @param recepient is the extra liquidity recepient function finish(address recepient) external onlyOwner { require(!finished, 'Finished'); require(recepient != address(0), 'Zero recepient'); uint256 periodFinishLocal = periodFinish; require( block.timestamp > periodFinishLocal && periodFinishLocal != 0, 'Only after period end' ); // lastTimeRewardApplicable == periodFinish (period is already over) uint256 previousPeriodRewardDuration = periodFinishLocal - periodStart; // no need to unstake owner stake (no active reward period + all rewards are counted in getUnusedRewards()) // update cumulative variables // use REAL previous period rewards duration here uint256 currentRewardDistributed = rewardRate * previousPeriodRewardDuration; cumulativeDistributedReward += currentRewardDistributed; cumulativeRewardPaid += currentRewardPaid; currentRewardPaid = 0; uint256 unusedReward = getUnusedRewards(); uint256 unclaimedReward = cumulativeDistributedReward - cumulativeRewardPaid - unusedReward - unusedRewardsExtracted; IERC20Upgradeable rewardTokenLocal = rewardToken; IERC20Upgradeable stakingTokenLocal = stakingToken; uint256 rewardTokenBalance = rewardTokenLocal.balanceOf(address(this)); uint256 stakingTokenBalance = stakingTokenLocal.balanceOf(address(this)); finished = true; // unusedRewards - from contract // unclaimed rewards - on contract emit Finished(recepient); if (rewardTokenLocal == stakingTokenLocal) { uint256 supply = totalSupply(); if (rewardTokenBalance - (supply + unclaimedReward) != 0) { rewardTokenLocal.safeTransfer( recepient, rewardTokenBalance - (supply + unclaimedReward) ); } } else { if (rewardTokenBalance - unclaimedReward != 0) { rewardTokenLocal.safeTransfer( recepient, rewardTokenBalance - unclaimedReward ); } uint256 supply = totalSupply(); if (stakingTokenBalance - supply != 0) { stakingTokenLocal.safeTransfer(recepient, stakingTokenBalance - supply); } } } /// @dev Allows owner to stop staking and extract extra liquidity /// @param recepient is the extra liquidity recepient function withdrawOtherTokens(address token, address recepient) external onlyOwner { require(token != address(0), 'Invalid token'); require(recepient != address(0), 'Zero recepient'); require(token != address(stakingToken), 'Token == staking token'); require(token != address(rewardToken), 'Token == reward token'); uint256 balance = IERC20Upgradeable(token).balanceOf(address(this)); require(balance != 0, 'Zero balance'); emit WithdrawnTokens(recepient, balance); IERC20Upgradeable(token).safeTransfer(recepient, balance); } /// @dev Allows owner to set period of rewards distribution /// @param rewardsDuration_ is new rewardsDuration amount function setRewardsDuration(uint64 rewardsDuration_) external onlyOwner { require(block.timestamp > periodFinish, 'Previous period not complete'); require( rewardsDuration_ >= MIN_REWARDS_DURATION, 'Rewards duration is too short' ); require(rewardsDuration_ <= MAX_REWARDS_DURATION, 'Rewards duration is too long'); require(rewardsDuration_ != rewardsDuration, 'Rewards duration duplicate'); rewardsDuration = rewardsDuration_; emit RewardsDurationUpdated(rewardsDuration_); } /// @dev Sets paused state for the contract (can be called by the owner only) /// @param state paused flag function setPaused(bool state) external onlyOwner { if (state) { _pause(); } else { _unpause(); } } // external view /// @dev Allows to view staking amount of selected user /// @param account to view balance /// @return balance of staking tokens for selected account function balanceOf(address account) external view returns (uint256) { return userBalances[account]; } /// @dev Allows to view user`s stake ids quantity /// @param user user account /// @return length of user ids array function getUserStakeIdsLength(address user) external view returns (uint256) { return idsByUser[user].length(); } /// @dev Allows to view if a user has a stake with specific id /// @param user user account /// @param id stake id /// @return bool flag (true if a user has owns the id) function hasStakeId(address user, uint256 id) external view returns (bool) { return idsByUser[user].contains(id); } /// @dev Allows to get a slice user stakes array /// @param user user account /// @param startIndex Starting index in user ids array /// @param length return array length /// @return Array-slice of user stakes function getUserStakesSlice( address user, uint256 startIndex, uint256 length ) external view returns (Stake[] memory) { require(length != 0, 'Zero length'); require( startIndex + length <= idsByUser[user].length(), 'Invalid startIndex + length' ); Stake[] memory userStakes = new Stake[](length); for (uint256 i; i < length; ) { uint256 stakeId = idsByUser[user].at(i + startIndex); userStakes[i] = stakes[stakeId]; userStakes[i].earned = earned(stakeId); unchecked { ++i; } } return userStakes; } /// @dev Allows to get a slice user stakes history array /// @param user user account /// @param startIndex Starting index in user ids array /// @param length return array length /// @return Array-slice of user stakes history function getUserInactiveStakesSlice( address user, uint256 startIndex, uint256 length ) external view returns (Stake[] memory) { require(length != 0, 'Zero length'); require( startIndex + length <= userInactiveStakes[user].length, 'Invalid startIndex + length' ); Stake[] memory userStakes = new Stake[](length); for (uint256 i; i < length; ) { uint256 stakeId = userInactiveStakes[user][i + startIndex]; userStakes[i] = stakes[stakeId]; unchecked { ++i; } } return userStakes; } /// @dev Allows to view user`s closed stakes quantity /// @param user user account /// @return length of user closed stakes array function getUserInactiveStakesLength(address user) external view returns (uint256) { return userInactiveStakes[user].length; } /// @dev Allows to view total cumulative unclaimed rewards (earned by all users) /// @return rewards (nominated in token weis) function getTotalRewards() external view returns (uint256) { if (totalSupply() != 0) { uint256 timePassed = lastTimeRewardApplicable() - periodStart; uint256 totalDistributedRewards = cumulativeDistributedReward; if (!finished) { totalDistributedRewards += rewardRate * timePassed; } uint256 totalClaimedRewards = cumulativeRewardPaid + currentRewardPaid; return totalDistributedRewards - totalClaimedRewards - getUnusedRewards() - unusedRewardsExtracted; } else { return 0; } } /// @dev Returns the approximate APR for a specific stake position not including penalties /// @return APR value multiplied by 10**18 function getPotentialAPR() external view returns (uint256) { uint256 _tvl = totalSupply(); if (_tvl == 0) return 0; // earned user value in tokens for one second including share (1e18 for accuracy) return (uint256(rewardRate) * ACCURACY * 365 days * 100) / (_tvl); } /// @dev Allows to view the number of stake holders /// @return length of stake holders array function getHoldersLength() external view returns (uint256) { return holders.length(); } /// @dev Allows to get a slice of stake holders array /// @param startIndex Starting index in stake holders array /// @param length return array length /// @return Array-slice of stake holders function getHoldersSlice( uint256 startIndex, uint256 length ) external view returns (address[] memory) { require(length != 0, 'Zero length'); require(startIndex + length <= holders.length(), 'Invalid startIndex + length'); address[] memory holdersArray = new address[](length); for (uint256 i = 0; i < length; ) { holdersArray[i] = holders.at(i + startIndex); unchecked { ++i; } } return holdersArray; } /// @notice Returns the number of currently active stakes /// @dev Excludes the number of owner`s active stakes /// @return numOfActiveStakesInternal - number of active stakes, made by users function numOfActiveStakes() external view returns (uint256) { return numOfActiveStakesInternal - idsByUser[address(this)].length(); } // public /// @notice Returns the user`s stakes total supply /// @dev Excludes reward owner stake supply /// @return totalSupplyInternal - total amount of staked tokens (in weis) function totalSupply() public view returns (uint256) { return totalSupplyInternal - userBalances[address(this)]; } /// @dev Allows to view last action time in the contract /// @return timestamp of last action function lastTimeRewardApplicable() public view returns (uint64) { return block.timestamp < periodFinish ? uint64(block.timestamp) : periodFinish; } /// @dev Allows to view already distributed rewards /// @return rewardPerTokenStored for current moment function rewardPerToken() public view returns (uint256) { uint256 totalSupplyInternalLocal = totalSupplyInternal; // can be == 0 before the first owner stake in made if (totalSupplyInternalLocal == 0) { return rewardPerTokenStored; } // can not overflow here, rewardRate * duration * ACCURACY <= uint128_max * 10 ** 18 << uint256 max return rewardPerTokenStored + (((lastTimeRewardApplicable() - lastUpdateTime) * uint256(rewardRate) * ACCURACY) / totalSupplyInternalLocal); } /// @dev Allows to view current user earned rewards /// @param id to view rewards /// @return earnedAmount of rewards for selected user function earned(uint256 id) public view returns (uint256) { Stake storage _stake = stakes[id]; if (_stake.unstakedAtBlockNumber == 0) { // ACTIVE STAKE => calculate amount + increase reward per token // can not overflow here, amount * (rewardRate * duration * ACCURACY / total supply) uint256 amount = _stake.amount; uint256 rewardPerTokenLocal = rewardPerToken(); uint256 rewardPerTokenPaid = _stake.userRewardPerTokenPaid; uint256 reward = uint256( (amount * (rewardPerTokenLocal - rewardPerTokenPaid)) / ACCURACY + _stake.earned ); return reward; } // INACTIVE STAKE return 0; } /// @notice Returns the amount of unused reward tokens /// @return reward tokens amount in weis function getUnusedRewards() public view returns (uint256) { // makes return amount always updated real time return earned(0) + currentPeriodUnusedRewardsSum; } // private /// @dev Allows to set reward rate /// @param newRewardRate is amount of token weis will be distributed per second (rewards / rewardsDuration) function _notifyRewardAmount(uint128 newRewardRate) private { require(!finished, 'Finished'); require(newRewardRate <= MAX_RATE, 'Reward rate too high'); // reward for the incoming period => use the new rewardsDuration uint64 rewardsDurationLocal = rewardsDuration; uint256 rewardRateOld = uint256(rewardRate); uint256 reward = uint256(newRewardRate) * uint256(rewardsDurationLocal); uint256 periodFinishOld = periodFinish; bool restakeOwnerPosition = true; if (firstRewardPeriodStart == 0) { // open owner stake in the first reward period (stake 1 wei to to accumulate unused rewards) _stakeInternal(TREASURY_STAKE_AMOUNT, address(this)); firstRewardPeriodStart = uint128(block.timestamp); restakeOwnerPosition = false; } // update cumulative variables // add rewards from teh previous period => use previous reward period start uint256 currentRewardDistributed = periodFinishOld == 0 ? 0 : rewardRateOld * (lastTimeRewardApplicable() - periodStart); cumulativeDistributedReward += currentRewardDistributed; cumulativeRewardPaid += currentRewardPaid; currentRewardPaid = 0; // update rate with the reward from the incoming period => use the updated rewards duration if (block.timestamp >= periodFinishOld) { // can not overflow here (MAX Numerator = Const * uint128_max * uint64), // Const < 100 <= num of reward periods, min period = 1 year rewardRate = uint128((reward + rewardsRemaining) / rewardsDurationLocal); // can not overfow here => MAX value = uint64_max - 1 rewardsRemaining = uint128( (reward + rewardsRemaining) % rewardsDurationLocal ); } else { uint64 remaining = uint64(periodFinishOld) - uint64(block.timestamp); uint256 leftover = remaining * rewardRateOld + rewardsRemaining; // can not overflow here (MAX Numerator = Const * uint128_max * uint64), // Const < 100 <= num of reward periods, min period = 1 year rewardRate = uint128((reward + leftover) / rewardsDurationLocal); // can not overfow here => MAX value = uint64_max - 1 rewardsRemaining = uint128((reward + leftover) % rewardsDurationLocal); } uint256 rewardRateNew = rewardRate; require(rewardRateNew != 0, 'Actual reward rate is too low'); // Ensure the provided reward amount is not more than the balance in the contract. // This keeps the reward rate in the right range, preventing overflows due to // very high values of rewardRate in the earned and rewardsPerToken functions; uint256 balance = address(rewardToken) == address(stakingToken) ? rewardToken.balanceOf(address(this)) - totalSupply() : rewardToken.balanceOf(address(this)); bool updateUnusedReward = (totalSupply() == 0); uint256 unusedReward = getUnusedRewards(); uint256 unclaimedReward = cumulativeDistributedReward - cumulativeRewardPaid - unusedReward - unusedRewardsExtracted; // unusedRewards are transferred to the owner in each notify currentPeriodUnusedRewardsSum = 0; // increase total unused rewards extracted after each period unusedRewardsExtracted += unusedReward; // if no active stakers were previously => unstake owner stake to stop accumulating unused rewards if (updateUnusedReward && restakeOwnerPosition) { _updateReward(0, true); // no update for cumulative unused reward here (already called getUnusedRewards() before, using earned()) _withdrawInternal(0, address(this)); } // Ensure the balance in the contract is more than the maximum reward + unclaimedRewards require( rewardRateNew * rewardsDurationLocal + unclaimedReward + unusedReward <= balance, 'Provided reward too high' ); lastUpdateTime = uint64(block.timestamp); periodFinish = uint64(block.timestamp) + rewardsDurationLocal; periodStart = uint64(block.timestamp); if (updateUnusedReward && restakeOwnerPosition) { _stakeInternal(TREASURY_STAKE_AMOUNT, address(this)); } if (unusedReward != 0) IERC20Upgradeable(rewardToken).safeTransfer(owner(), unusedReward); emit RewardAdded(reward); } /// @dev Internal function for staking tokens /// @param amount of token to stake function _stakeInternal(uint256 amount, address interractor) private { totalSupplyInternal += amount; ++numOfActiveStakesInternal; uint256 newId; if (interractor != address(this)) { newId = ++globalId; } // else owner stake => newId = 0 (not to affect other stakes) stakes[newId] = Stake({ id: newId, amount: amount, earned: 0, claimed: 0, userRewardPerTokenPaid: rewardPerTokenStored, owner: interractor, timestamp: uint32(block.timestamp), unstakedAtBlockNumber: 0, unstakedAtBlockTimestamp: 0 }); // add new holder if needed (address(this) should not be displayed in holders) if (userBalances[interractor] == 0 && interractor != address(this)) holders.add(interractor); userBalances[interractor] += amount; idsByUser[interractor].add(newId); } /// @dev Internal function for withdrawing staked tokens + claim earned rewards /// @param id Stake id /// @param interractor Address which is supposed to be the stake owner /// @return amount - principal token amount, reward - reward token amount function _withdrawInternal( uint256 id, address interractor ) private returns (uint256 amount, uint256 reward) { Stake storage _stake = stakes[id]; amount = _stake.amount; require(_stake.unstakedAtBlockNumber == 0, 'Already unstaked'); require(_stake.owner == interractor, 'Called not by stake owner'); totalSupplyInternal -= amount; userBalances[interractor] -= amount; --numOfActiveStakesInternal; // calculate the available rewards // increase the currentRewardPaid // earned = 0, increase claimed reward = _claimInternal(id, interractor); // address(this) should not be displayed in holders if (userBalances[interractor] == 0 && interractor != address(this)) holders.remove(interractor); idsByUser[interractor].remove(id); if (interractor != address(this)) userInactiveStakes[interractor].push(id); stakes[id].unstakedAtBlockNumber = uint32(block.number); stakes[id].unstakedAtBlockTimestamp = uint32(block.timestamp); } function _claimInternal( uint256 id, address interractor ) private returns (uint256 reward) { Stake storage _stake = stakes[id]; require(_stake.unstakedAtBlockNumber == 0, 'Already unstaked'); require(_stake.owner == interractor, 'Called not by stake owner'); // reward already updated reward = _stake.earned; if (reward != 0 && interractor != address(this)) { // CLAIM ALL EARNED REWARDS // update var only if claim by real user currentRewardPaid += reward; } if (reward != 0) { stakes[id].earned = 0; stakes[id].claimed += reward; } } /// @dev Update rewards pool information to correct rewards calculation for global varialbes and current stake /// @param id stake to update info for /// @param updateId flag, true when update stake struct function _updateReward(uint256 id, bool updateId) private { rewardPerTokenStored = rewardPerToken(); lastUpdateTime = lastTimeRewardApplicable(); if (updateId) { stakes[id].earned = earned(id); stakes[id].userRewardPerTokenPaid = rewardPerTokenStored; } } }
Compiler Settings
{"outputSelection":{"*":{"*":["abi","evm.bytecode","evm.deployedBytecode","evm.methodIdentifiers"],"":["ast"]}},"optimizer":{"runs":200,"enabled":true},"metadata":{"bytecodeHash":"ipfs"},"libraries":{"Staking.sol":{}}}
Contract ABI
[{"type":"constructor","stateMutability":"nonpayable","inputs":[]},{"type":"event","name":"Finished","inputs":[{"type":"address","name":"recepient","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"Initialized","inputs":[{"type":"uint8","name":"version","internalType":"uint8","indexed":false}],"anonymous":false},{"type":"event","name":"OwnershipTransferred","inputs":[{"type":"address","name":"previousOwner","internalType":"address","indexed":true},{"type":"address","name":"newOwner","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"Paused","inputs":[{"type":"address","name":"account","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"RewardAdded","inputs":[{"type":"uint256","name":"reward","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"RewardPaid","inputs":[{"type":"address","name":"user","internalType":"address","indexed":true},{"type":"uint256","name":"id","internalType":"uint256","indexed":true},{"type":"uint256","name":"reward","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"RewardsDurationUpdated","inputs":[{"type":"uint256","name":"newDuration","internalType":"uint256","indexed":true}],"anonymous":false},{"type":"event","name":"Staked","inputs":[{"type":"address","name":"user","internalType":"address","indexed":true},{"type":"uint256","name":"id","internalType":"uint256","indexed":true},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false},{"type":"uint256","name":"totalSupply","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"Unpaused","inputs":[{"type":"address","name":"account","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"Withdrawn","inputs":[{"type":"address","name":"user","internalType":"address","indexed":true},{"type":"uint256","name":"id","internalType":"uint256","indexed":true},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false},{"type":"uint256","name":"totalSupply","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"WithdrawnTokens","inputs":[{"type":"address","name":"recepient","internalType":"address","indexed":true},{"type":"uint256","name":"amount","internalType":"uint256","indexed":true}],"anonymous":false},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"ACCURACY","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"MAX_RATE","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"MAX_REWARDS_DURATION","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"MAX_STAKE","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"MIN_REWARDS_DURATION","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"TREASURY_STAKE_AMOUNT","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"balanceOf","inputs":[{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"claim","inputs":[{"type":"uint256","name":"id","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"cumulativeDistributedReward","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"cumulativeRewardPaid","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"currentPeriodUnusedRewardsSum","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"currentRewardPaid","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"earned","inputs":[{"type":"uint256","name":"id","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"finish","inputs":[{"type":"address","name":"recepient","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"finished","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint128","name":"","internalType":"uint128"}],"name":"firstRewardPeriodStart","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getHoldersLength","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address[]","name":"","internalType":"address[]"}],"name":"getHoldersSlice","inputs":[{"type":"uint256","name":"startIndex","internalType":"uint256"},{"type":"uint256","name":"length","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getPotentialAPR","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getTotalRewards","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getUnusedRewards","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getUserInactiveStakesLength","inputs":[{"type":"address","name":"user","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"tuple[]","name":"","internalType":"struct Staking.Stake[]","components":[{"type":"uint256","name":"id","internalType":"uint256"},{"type":"uint256","name":"amount","internalType":"uint256"},{"type":"uint256","name":"earned","internalType":"uint256"},{"type":"uint256","name":"claimed","internalType":"uint256"},{"type":"uint256","name":"userRewardPerTokenPaid","internalType":"uint256"},{"type":"address","name":"owner","internalType":"address"},{"type":"uint32","name":"timestamp","internalType":"uint32"},{"type":"uint32","name":"unstakedAtBlockNumber","internalType":"uint32"},{"type":"uint32","name":"unstakedAtBlockTimestamp","internalType":"uint32"}]}],"name":"getUserInactiveStakesSlice","inputs":[{"type":"address","name":"user","internalType":"address"},{"type":"uint256","name":"startIndex","internalType":"uint256"},{"type":"uint256","name":"length","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getUserStakeIdsLength","inputs":[{"type":"address","name":"user","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"tuple[]","name":"","internalType":"struct Staking.Stake[]","components":[{"type":"uint256","name":"id","internalType":"uint256"},{"type":"uint256","name":"amount","internalType":"uint256"},{"type":"uint256","name":"earned","internalType":"uint256"},{"type":"uint256","name":"claimed","internalType":"uint256"},{"type":"uint256","name":"userRewardPerTokenPaid","internalType":"uint256"},{"type":"address","name":"owner","internalType":"address"},{"type":"uint32","name":"timestamp","internalType":"uint32"},{"type":"uint32","name":"unstakedAtBlockNumber","internalType":"uint32"},{"type":"uint32","name":"unstakedAtBlockTimestamp","internalType":"uint32"}]}],"name":"getUserStakesSlice","inputs":[{"type":"address","name":"user","internalType":"address"},{"type":"uint256","name":"startIndex","internalType":"uint256"},{"type":"uint256","name":"length","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"globalId","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"hasStakeId","inputs":[{"type":"address","name":"user","internalType":"address"},{"type":"uint256","name":"id","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"init","inputs":[{"type":"address","name":"stakingToken_","internalType":"contract IERC20Upgradeable"},{"type":"address","name":"rewardToken_","internalType":"contract IERC20Upgradeable"},{"type":"address","name":"owner_","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint64","name":"","internalType":"uint64"}],"name":"lastTimeRewardApplicable","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint64","name":"","internalType":"uint64"}],"name":"lastUpdateTime","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"notifyRewardAmount","inputs":[{"type":"uint128","name":"newRewardRate","internalType":"uint128"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"notifyRewardAmountPrevious","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"numOfActiveStakes","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"owner","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"paused","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint64","name":"","internalType":"uint64"}],"name":"periodFinish","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint64","name":"","internalType":"uint64"}],"name":"periodStart","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceOwnership","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"rewardPerToken","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"rewardPerTokenStored","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint128","name":"","internalType":"uint128"}],"name":"rewardRate","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract IERC20Upgradeable"}],"name":"rewardToken","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint64","name":"","internalType":"uint64"}],"name":"rewardsDuration","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint128","name":"","internalType":"uint128"}],"name":"rewardsRemaining","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setPaused","inputs":[{"type":"bool","name":"state","internalType":"bool"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setRewardsDuration","inputs":[{"type":"uint64","name":"rewardsDuration_","internalType":"uint64"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"stake","inputs":[{"type":"uint256","name":"amount","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"id","internalType":"uint256"},{"type":"uint256","name":"amount","internalType":"uint256"},{"type":"uint256","name":"earned","internalType":"uint256"},{"type":"uint256","name":"claimed","internalType":"uint256"},{"type":"uint256","name":"userRewardPerTokenPaid","internalType":"uint256"},{"type":"address","name":"owner","internalType":"address"},{"type":"uint32","name":"timestamp","internalType":"uint32"},{"type":"uint32","name":"unstakedAtBlockNumber","internalType":"uint32"},{"type":"uint32","name":"unstakedAtBlockTimestamp","internalType":"uint32"}],"name":"stakes","inputs":[{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract IERC20Upgradeable"}],"name":"stakingToken","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"totalSupply","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferOwnership","inputs":[{"type":"address","name":"newOwner","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"unusedRewardsExtracted","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"userBalances","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"userInactiveStakes","inputs":[{"type":"address","name":"","internalType":"address"},{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"withdraw","inputs":[{"type":"uint256","name":"id","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"withdrawOtherTokens","inputs":[{"type":"address","name":"token","internalType":"address"},{"type":"address","name":"recepient","internalType":"address"}]}]
Contract Creation Code
0x60806040523480156200001157600080fd5b506200001c62000022565b620000e3565b600054610100900460ff16156200008f5760405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b606482015260840160405180910390fd5b60005460ff90811614620000e1576000805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b61376e80620000f36000396000f3fe608060405234801561001057600080fd5b50600436106103785760003560e01c80638446f31a116101d3578063db04aef411610104578063ebe2b12b116100a2578063f27890061161007c578063f27890061461080c578063f2fde38b14610815578063f7c618c114610828578063fbcd9b051461083b57600080fd5b8063ebe2b12b146107d7578063eda4e6d6146107ea578063f1752ec51461080457600080fd5b8063df136d65116100de578063df136d6514610794578063e627f2db1461079d578063e6d8aa94146107a5578063eb8af21a146107ae57600080fd5b8063db04aef414610763578063db3924211461076b578063dd5c6d471461077457600080fd5b8063c214048a11610171578063c98517c51161014b578063c98517c514610675578063ca66682314610689578063cd3daf9d14610692578063d5a44f861461069a57600080fd5b8063c214048a1461064b578063c24dbebd14610653578063c8f33c911461065b57600080fd5b8063a182dd13116101ad578063a182dd131461060d578063a694fc3a14610620578063bef4876b14610633578063bf21a8aa1461064057600080fd5b80638446f31a146105ec5780638da5cb5b146105f45780639a2f055f1461060557600080fd5b80634d6ed8c4116102ad578063715018a61161024b57806378c196f31161022557806378c196f3146105af5780637b0a47ee146105c957806380faa57d146105dc578063829ba2f2146105e457600080fd5b8063715018a6146105695780637180e5901461057157806372f702f31461058457600080fd5b80635fe8301b116102875780635fe8301b146104fa57806360eb8a2e1461050d5780636a89beb71461052057806370a082311461054057600080fd5b80634d6ed8c4146104bd5780635709632b146104d05780635c975abb146104e357600080fd5b8063379607f51161031a5780633a5dd35f116102f45780633a5dd35f146104675780634054c5c91461047a57806348c7d182146104825780634a1cc82b1461048b57600080fd5b8063379607f51461040f578063381b1d5714610422578063386a95251461043557600080fd5b80632503aea2116103565780632503aea2146103c057806326224c64146103c95780632e1a7d4d146103e9578063305ec69e146103fc57600080fd5b806316c38b3c1461037d57806318160ddd14610392578063184b9559146103ad575b600080fd5b61039061038b3660046131cb565b61084a565b005b61039a61086b565b6040519081526020015b60405180910390f35b6103906103bb3660046131fd565b61088d565b61039a609d5481565b61039a6103d7366004613248565b60a46020526000908152604090205481565b6103906103f7366004613265565b610a6d565b61039061040a366004613248565b610b57565b61039061041d366004613265565b610eeb565b61039061043036600461327e565b610f99565b609b5461044f90600160401b90046001600160401b031681565b6040516001600160401b0390911681526020016103a4565b61039a6104753660046132a7565b610fb5565b61039a600181565b61039a60a05481565b60a7546104a590600160801b90046001600160801b031681565b6040516001600160801b0390911681526020016103a4565b61039a6104cb366004613265565b610fe6565b61039a6104de366004613248565b611071565b60655460ff165b60405190151581526020016103a4565b6103906105083660046132d3565b611098565b61039061051b3660046132fc565b61126d565b61053361052e366004613335565b6114a5565b6040516103a4919061336a565b61039a61054e366004613248565b6001600160a01b0316600090815260a4602052604090205490565b610390611669565b6104ea61057f3660046132a7565b61167d565b609754610597906001600160a01b031681565b6040516001600160a01b0390911681526020016103a4565b6099546104a590600160801b90046001600160801b031681565b6099546104a5906001600160801b031681565b61044f6116a6565b61039a603c81565b6103906116d0565b6033546001600160a01b0316610597565b61039a611740565b61053361061b366004613335565b611759565b61039061062e366004613265565b611938565b60aa546104ea9060ff1681565b61039a6312cc030081565b61039a611aee565b61039a611b55565b609b5461044f90600160801b90046001600160401b031681565b61039a6c0c9f2c9cd04674edea4000000081565b61039a60a55481565b61039a611b76565b61070a6106a8366004613265565b60a16020526000908152604090208054600182015460028301546003840154600485015460059095015493949293919290916001600160a01b0381169063ffffffff600160a01b8204811691600160c01b8104821691600160e01b9091041689565b60408051998a5260208a019890985296880195909552606087019390935260808601919091526001600160a01b031660a085015263ffffffff90811660c085015290811660e084015216610100820152610120016103a4565b61039a611bff565b61039a609f5481565b610787610782366004613426565b611c0b565b6040516103a49190613448565b61039a609a5481565b61039a611cff565b61039a609e5481565b61039a6107bc366004613248565b6001600160a01b0316600090815260a2602052604090205490565b609b5461044f906001600160401b031681565b609b5461044f90600160c01b90046001600160401b031681565b61039a611dc1565b61039a609c5481565b610390610823366004613248565b611def565b609854610597906001600160a01b031681565b61039a670de0b6b3a764000081565b610852611e65565b801561086357610860611ebf565b50565b610860611f19565b30600090815260a4602052604081205460a65461088891906134ab565b905090565b600054610100900460ff16158080156108ad5750600054600160ff909116105b806108c75750303b1580156108c7575060005460ff166001145b61092f5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084015b60405180910390fd5b6000805460ff191660011790558015610952576000805461ff0019166101001790555b6001600160a01b0384166109785760405162461bcd60e51b8152600401610926906134be565b6001600160a01b03831661099e5760405162461bcd60e51b8152600401610926906134be565b6001600160a01b0382166109c45760405162461bcd60e51b8152600401610926906134be565b609780546001600160a01b038087166001600160a01b0319928316179092556098805492861692909116919091179055609b80546b01e13380000000000000000067ffffffffffffffff60401b19909116179055610a2182611f52565b8015610a67576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50505050565b610a78816001611fa4565b600080610a85833361200f565b91509150610a9161086b565b600003610aa357610aa3600130612253565b82337f75e161b3e824b114fc1a33274bd7091918dd4e639cede50b78b15a4eea956a2184610acf61086b565b6040805192835260208301919091520160405180910390a3604051818152839033907fd6f2c8500df5b44f11e9e48b91ff9f1b9d81bc496d55570c2b1b75bf65243f519060200160405180910390a38015610b3b57609854610b3b906001600160a01b03163383612446565b609754610b52906001600160a01b03163384612446565b505050565b610b5f611e65565b60aa5460ff1615610b9d5760405162461bcd60e51b8152602060048201526008602482015267119a5b9a5cda195960c21b6044820152606401610926565b6001600160a01b038116610be45760405162461bcd60e51b815260206004820152600e60248201526d16995c9bc81c9958d95c1a595b9d60921b6044820152606401610926565b609b546001600160401b03164281108015610bfe57508015155b610c425760405162461bcd60e51b815260206004820152601560248201527413db9b1e4818599d195c881c195c9a5bd908195b99605a1b6044820152606401610926565b609b54600090610c6290600160c01b90046001600160401b0316836134ab565b609954909150600090610c7f9083906001600160801b03166134e7565b905080609c6000828254610c9391906134fe565b9091555050609d54609e8054600090610cad9084906134fe565b90915550506000609d819055610cc1611740565b9050600060a05482609e54609c54610cd991906134ab565b610ce391906134ab565b610ced91906134ab565b6098546097546040516370a0823160e01b81523060048201529293506001600160a01b039182169291169060009083906370a0823190602401602060405180830381865afa158015610d43573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d679190613511565b6040516370a0823160e01b81523060048201529091506000906001600160a01b038416906370a0823190602401602060405180830381865afa158015610db1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dd59190613511565b60aa805460ff191660011790556040519091506001600160a01b038b16907fe6782ef5425ff7b9fdd779270f985cd651ea84df7bcf21f9ed6d9f29dceeb1c990600090a2826001600160a01b0316846001600160a01b031603610e86576000610e3c61086b565b9050610e4886826134fe565b610e5290846134ab565b15610e8057610e808b610e6588846134fe565b610e6f90866134ab565b6001600160a01b0388169190612446565b50610edf565b610e9085836134ab565b15610eb457610eb48a610ea387856134ab565b6001600160a01b0387169190612446565b6000610ebe61086b565b9050610eca81836134ab565b15610edd57610edd8b610ea383856134ab565b505b50505050505050505050565b610ef6816001611fa4565b6000610f0282336124a9565b905080600003610f475760405162461bcd60e51b815260206004820152601060248201526f4e6f7468696e6720746f20636c61696d60801b6044820152606401610926565b604051818152829033907fd6f2c8500df5b44f11e9e48b91ff9f1b9d81bc496d55570c2b1b75bf65243f519060200160405180910390a3609854610f95906001600160a01b03163383612446565b5050565b610fa1611e65565b610fac600080611fa4565b610860816125db565b60a26020528160005260406000208181548110610fd157600080fd5b90600052602060002001600091509150505481565b600081815260a1602052604081206005810154600160c01b900463ffffffff168203611068576001810154600061101b611b76565b6004840154600285015491925090600090670de0b6b3a764000061103f84866134ab565b61104990876134e7565b6110539190613540565b61105d91906134fe565b979650505050505050565b50600092915050565b6001600160a01b038116600090815260a36020526040812061109290612c5e565b92915050565b6110a0611e65565b609b546001600160401b031642116110fa5760405162461bcd60e51b815260206004820152601c60248201527f50726576696f757320706572696f64206e6f7420636f6d706c657465000000006044820152606401610926565b603c816001600160401b031610156111545760405162461bcd60e51b815260206004820152601d60248201527f52657761726473206475726174696f6e20697320746f6f2073686f72740000006044820152606401610926565b6312cc0300816001600160401b031611156111b15760405162461bcd60e51b815260206004820152601c60248201527f52657761726473206475726174696f6e20697320746f6f206c6f6e67000000006044820152606401610926565b609b546001600160401b03600160401b9091048116908216036112165760405162461bcd60e51b815260206004820152601a60248201527f52657761726473206475726174696f6e206475706c69636174650000000000006044820152606401610926565b609b805467ffffffffffffffff60401b1916600160401b6001600160401b038416908102919091179091556040517ffb46ca5a5e06d4540d6387b930a7c978bce0db5f449ec6b3f5d07c6e1d44f2d390600090a250565b611275611e65565b6001600160a01b0382166112bb5760405162461bcd60e51b815260206004820152600d60248201526c24b73b30b634b2103a37b5b2b760991b6044820152606401610926565b6001600160a01b0381166113025760405162461bcd60e51b815260206004820152600e60248201526d16995c9bc81c9958d95c1a595b9d60921b6044820152606401610926565b6097546001600160a01b03908116908316036113595760405162461bcd60e51b81526020600482015260166024820152752a37b5b2b7101e9e9039ba30b5b4b733903a37b5b2b760511b6044820152606401610926565b6098546001600160a01b03908116908316036113af5760405162461bcd60e51b81526020600482015260156024820152742a37b5b2b7101e9e903932bbb0b932103a37b5b2b760591b6044820152606401610926565b6040516370a0823160e01b81523060048201526000906001600160a01b038416906370a0823190602401602060405180830381865afa1580156113f6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061141a9190613511565b90508060000361145b5760405162461bcd60e51b815260206004820152600c60248201526b5a65726f2062616c616e636560a01b6044820152606401610926565b60405181906001600160a01b038416907f373d92bf7d9cdd58a8c86db5461f3cdcd325b803fdbac8d1b224a0f5fce847b890600090a3610b526001600160a01b0384168383612446565b6060816000036114c75760405162461bcd60e51b815260040161092690613554565b6001600160a01b038416600090815260a260205260409020546114ea83856134fe565b11156115085760405162461bcd60e51b815260040161092690613579565b6000826001600160401b03811115611522576115226135b0565b60405190808252806020026020018201604052801561155b57816020015b611548613156565b8152602001906001900390816115405790505b50905060005b83811015611660576001600160a01b038616600090815260a26020526040812061158b87846134fe565b8154811061159b5761159b6135c6565b600091825260208083209091015480835260a182526040928390208351610120810185528154815260018201549381019390935260028101549383019390935260038301546060830152600483015460808301526005909201546001600160a01b03811660a083015263ffffffff600160a01b8204811660c0840152600160c01b8204811660e0840152600160e01b9091041661010082015284519192509084908490811061164c5761164c6135c6565b602090810291909101015250600101611561565b50949350505050565b611671611e65565b61167b6000611f52565b565b6001600160a01b038216600090815260a36020526040812061169f9083612c68565b9392505050565b609b546000906001600160401b031642106116cb5750609b546001600160401b031690565b504290565b6116d8611e65565b6116e3600080611fa4565b6099546001600160801b03166000819003610fac5760405162461bcd60e51b815260206004820152601f60248201527f50726576696f757320726577617264207261746520697320746f6f206c6f77006044820152606401610926565b6000609f5461174f6000610fe6565b61088891906134fe565b60608160000361177b5760405162461bcd60e51b815260040161092690613554565b6001600160a01b038416600090815260a36020526040902061179c90612c5e565b6117a683856134fe565b11156117c45760405162461bcd60e51b815260040161092690613579565b6000826001600160401b038111156117de576117de6135b0565b60405190808252806020026020018201604052801561181757816020015b611804613156565b8152602001906001900390816117fc5790505b50905060005b8381101561166057600061185261183487846134fe565b6001600160a01b038916600090815260a36020526040902090612c80565b600081815260a160209081526040918290208251610120810184528154815260018201549281019290925260028101549282019290925260038201546060820152600482015460808201526005909101546001600160a01b03811660a083015263ffffffff600160a01b8204811660c0840152600160c01b8204811660e0840152600160e01b909104166101008201528451919250908490849081106118fa576118fa6135c6565b602002602001018190525061190e81610fe6565b838381518110611920576119206135c6565b6020908102919091010151604001525060010161181d565b611940612c8c565b600081116119815760405162461bcd60e51b815260206004820152600e60248201526d043616e6e6f74207374616b6520360941b6044820152606401610926565b6c0c9f2c9cd04674edea400000008111156119d65760405162461bcd60e51b81526020600482015260156024820152740a6e8c2d6ca40c2dadeeadce840e8dede40d0d2ced605b1b6044820152606401610926565b609b54426001600160401b0390911611611a325760405162461bcd60e51b815260206004820152601b60248201527f52657761726420706572696f64206e6f742061637469766174656400000000006044820152606401610926565b611a3a61086b565b600003611a7b57611a4d60006001611fa4565b6000611a5a60003061200f565b91505080609f6000828254611a6f91906134fe565b90915550611a86915050565b611a86600080611fa4565b611a908133612253565b60a554337fb4caaf29adda3eefee3ad552a8e85058589bf834c7466cae4ee58787f70589ed83611abe61086b565b6040805192835260208301919091520160405180910390a3609754610860906001600160a01b0316333084612cd2565b600080611af961086b565b905080600003611b0b57600091505090565b6099548190611b2c90670de0b6b3a7640000906001600160801b03166134e7565b611b3a906301e133806134e7565b611b459060646134e7565b611b4f9190613540565b91505090565b611b62603c6103e86134e7565b611b73906001600160801b03613540565b81565b60a654600090808203611b8b575050609a5490565b609954609b548291670de0b6b3a7640000916001600160801b0390911690600160801b90046001600160401b0316611bc16116a6565b611bcb91906135dc565b6001600160401b0316611bde91906134e7565b611be891906134e7565b611bf29190613540565b609a54611b4f91906134fe565b600061088860a8612c5e565b606081600003611c2d5760405162461bcd60e51b815260040161092690613554565b611c3760a8612c5e565b611c4183856134fe565b1115611c5f5760405162461bcd60e51b815260040161092690613579565b6000826001600160401b03811115611c7957611c796135b0565b604051908082528060200260200182016040528015611ca2578160200160208202803683370190505b50905060005b83811015611cf757611cc5611cbd86836134fe565b60a890612c80565b828281518110611cd757611cd76135c6565b6001600160a01b0390921660209283029190910190910152600101611ca8565b509392505050565b6000611d0961086b565b15611dbb57609b54600090600160c01b90046001600160401b0316611d2c6116a6565b611d3691906135dc565b609c5460aa546001600160401b039290921692509060ff16611d7657609954611d699083906001600160801b03166134e7565b611d7390826134fe565b90505b6000609d54609e54611d8891906134fe565b905060a054611d95611740565b611d9f83856134ab565b611da991906134ab565b611db391906134ab565b935050505090565b50600090565b30600090815260a360205260408120611dd990612c5e565b60a75461088891906001600160801b03166134ab565b611df7611e65565b6001600160a01b038116611e5c5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610926565b61086081611f52565b6033546001600160a01b0316331461167b5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610926565b611ec7612c8c565b6065805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258611efc3390565b6040516001600160a01b03909116815260200160405180910390a1565b611f21612d0a565b6065805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa33611efc565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b611fac611b76565b609a55611fb76116a6565b609b60106101000a8154816001600160401b0302191690836001600160401b031602179055508015610f9557611fec82610fe6565b600083815260a1602052604090206002810191909155609a546004909101555050565b600082815260a1602052604081206001810154600582015490929190600160c01b900463ffffffff16156120785760405162461bcd60e51b815260206004820152601060248201526f105b1c9958591e481d5b9cdd185ad95960821b6044820152606401610926565b60058101546001600160a01b038581169116146120d35760405162461bcd60e51b815260206004820152601960248201527821b0b63632b2103737ba10313c9039ba30b5b29037bbb732b960391b6044820152606401610926565b8260a660008282546120e591906134ab565b90915550506001600160a01b038416600090815260a46020526040812080548592906121129084906134ab565b909155505060a78054600090612130906001600160801b03166135fc565b91906101000a8154816001600160801b0302191690836001600160801b0316021790555061215e85856124a9565b6001600160a01b038516600090815260a4602052604090205490925015801561219057506001600160a01b0384163014155b156121a2576121a060a885612d53565b505b6001600160a01b038416600090815260a3602052604090206121c49086612d68565b506001600160a01b0384163014612201576001600160a01b038416600090815260a260209081526040822080546001810182559083529120018590555b50600093845260a1602052604090932060050180544263ffffffff908116600160e01b026001600160e01b034392909216600160c01b02919091166001600160c01b0390921691909117179055929050565b8160a6600082825461226591906134fe565b909155505060a78054600090612283906001600160801b031661361f565b91906101000a8154816001600160801b0302191690836001600160801b031602179055506000306001600160a01b0316826001600160a01b0316146122d95760a5600081546122d190613645565b918290555090505b60408051610120810182528281526020808201868152600083850181815260608501828152609a54608087019081526001600160a01b03808b1660a0890181815263ffffffff42811660c08c0190815260e08c018981526101008d018a81528f8b5260a18d528e8b209d518e559a5160018e0155975160028d0155955160038c0155935160048b015551600590990180549451955197518416600160e01b026001600160e01b03988516600160c01b02989098166001600160c01b0396909416600160a01b026001600160c01b031990951699909216989098179290921792909216919091179290921790915591825260a4905220541580156123e557506001600160a01b0382163014155b156123f7576123f560a883612d74565b505b6001600160a01b038216600090815260a460205260408120805485929061241f9084906134fe565b90915550506001600160a01b038216600090815260a360205260409020610a679082612d89565b6040516001600160a01b038316602482015260448101829052610b5290849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612d95565b600082815260a1602052604081206005810154600160c01b900463ffffffff16156125095760405162461bcd60e51b815260206004820152601060248201526f105b1c9958591e481d5b9cdd185ad95960821b6044820152606401610926565b60058101546001600160a01b038481169116146125645760405162461bcd60e51b815260206004820152601960248201527821b0b63632b2103737ba10313c9039ba30b5b29037bbb732b960391b6044820152606401610926565b60028101549150811580159061258357506001600160a01b0383163014155b156125a05781609d600082825461259a91906134fe565b90915550505b81156125d457600084815260a1602052604081206002810182905560030180548492906125ce9084906134fe565b90915550505b5092915050565b60aa5460ff16156126195760405162461bcd60e51b8152602060048201526008602482015267119a5b9a5cda195960c21b6044820152606401610926565b612626603c6103e86134e7565b612637906001600160801b03613540565b816001600160801b031611156126865760405162461bcd60e51b81526020600482015260146024820152730a4caeec2e4c840e4c2e8ca40e8dede40d0d2ced60631b6044820152606401610926565b609b54609954600160401b9091046001600160401b0316906001600160801b03908116906000906126ba90849086166134e7565b609b5460a7549192506001600160401b031690600190600160801b90046001600160801b0316600003612710576126f2600130612253565b5060a780546001600160801b03428116600160801b02911617905560005b6000821561275557609b54600160c01b90046001600160401b03166127336116a6565b61273d91906135dc565b612750906001600160401b0316866134e7565b612758565b60005b905080609c600082825461276c91906134fe565b9091555050609d54609e80546000906127869084906134fe565b90915550506000609d55428311612830576099546001600160401b038716906127bf90600160801b90046001600160801b0316866134fe565b6127c99190613540565b609980546001600160801b0319166001600160801b0392831617908190556001600160401b0388169161280491600160801b900416866134fe565b61280e919061365e565b609980546001600160801b03928316600160801b0292169190911790556128f0565b600061283c42856135dc565b609954909150600090600160801b90046001600160801b0316612868886001600160401b0385166134e7565b61287291906134fe565b90506001600160401b03881661288882886134fe565b6128929190613540565b609980546001600160801b0319166001600160801b03929092169190911790556001600160401b0388166128c682886134fe565b6128d0919061365e565b609980546001600160801b03928316600160801b02921691909117905550505b6099546001600160801b0316600081900361294d5760405162461bcd60e51b815260206004820152601d60248201527f41637475616c20726577617264207261746520697320746f6f206c6f770000006044820152606401610926565b6097546098546000916001600160a01b039182169116146129d9576098546040516370a0823160e01b81523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa1580156129b0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129d49190613511565b612a57565b6129e161086b565b6098546040516370a0823160e01b81523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa158015612a29573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a4d9190613511565b612a5791906134ab565b90506000612a6361086b565b1590506000612a70611740565b9050600060a05482609e54609c54612a8891906134ab565b612a9291906134ab565b612a9c91906134ab565b90506000609f819055508160a06000828254612ab891906134fe565b909155508390508015612ac85750865b15612ae757612ad960006001611fa4565b612ae460003061200f565b50505b838282612afd6001600160401b038f16896134e7565b612b0791906134fe565b612b1191906134fe565b1115612b5f5760405162461bcd60e51b815260206004820152601860248201527f50726f76696465642072657761726420746f6f206869676800000000000000006044820152606401610926565b609b80546001600160401b0342908116600160801b0267ffffffffffffffff60801b1990921691909117909155612b97908c90613672565b609b8054426001600160401b03908116600160c01b0277ffffffffffffffffffffffffffffffff0000000000000000909216931692909217919091179055828015612bdf5750865b15612bef57612bef600130612253565b8115612c1d57612c1d612c0a6033546001600160a01b031690565b6098546001600160a01b03169084612446565b6040518981527fde88a922e0d3b88b24e9623efeb464919c6bf9f66857a65e2bfcf2ce87a9433d9060200160405180910390a1505050505050505050505050565b6000611092825490565b6000818152600183016020526040812054151561169f565b600061169f8383612e6a565b60655460ff161561167b5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610926565b6040516001600160a01b0380851660248301528316604482015260648101829052610a679085906323b872dd60e01b90608401612472565b60655460ff1661167b5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610926565b600061169f836001600160a01b038416612e94565b600061169f8383612e94565b600061169f836001600160a01b038416612f87565b600061169f8383612f87565b6000612dea826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612fd69092919063ffffffff16565b9050805160001480612e0b575080806020019051810190612e0b9190613692565b610b525760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610926565b6000826000018281548110612e8157612e816135c6565b9060005260206000200154905092915050565b60008181526001830160205260408120548015612f7d576000612eb86001836134ab565b8554909150600090612ecc906001906134ab565b9050818114612f31576000866000018281548110612eec57612eec6135c6565b9060005260206000200154905080876000018481548110612f0f57612f0f6135c6565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080612f4257612f426136af565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050611092565b6000915050611092565b6000818152600183016020526040812054612fce57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155611092565b506000611092565b6060612fe58484600085612fed565b949350505050565b60608247101561304e5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610926565b600080866001600160a01b0316858760405161306a91906136e9565b60006040518083038185875af1925050503d80600081146130a7576040519150601f19603f3d011682016040523d82523d6000602084013e6130ac565b606091505b509150915061105d8783838760608315613127578251600003613120576001600160a01b0385163b6131205760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610926565b5081612fe5565b612fe5838381511561313c5781518083602001fd5b8060405162461bcd60e51b81526004016109269190613705565b604051806101200160405280600081526020016000815260200160008152602001600081526020016000815260200160006001600160a01b03168152602001600063ffffffff168152602001600063ffffffff168152602001600063ffffffff1681525090565b801515811461086057600080fd5b6000602082840312156131dd57600080fd5b813561169f816131bd565b6001600160a01b038116811461086057600080fd5b60008060006060848603121561321257600080fd5b833561321d816131e8565b9250602084013561322d816131e8565b9150604084013561323d816131e8565b809150509250925092565b60006020828403121561325a57600080fd5b813561169f816131e8565b60006020828403121561327757600080fd5b5035919050565b60006020828403121561329057600080fd5b81356001600160801b038116811461169f57600080fd5b600080604083850312156132ba57600080fd5b82356132c5816131e8565b946020939093013593505050565b6000602082840312156132e557600080fd5b81356001600160401b038116811461169f57600080fd5b6000806040838503121561330f57600080fd5b823561331a816131e8565b9150602083013561332a816131e8565b809150509250929050565b60008060006060848603121561334a57600080fd5b8335613355816131e8565b95602085013595506040909401359392505050565b602080825282518282018190526000919060409081850190868401855b828110156134195781518051855286810151878601528581015186860152606080820151908601526080808201519086015260a0808201516001600160a01b03169086015260c08082015163ffffffff169086015260e0808201516133f38288018263ffffffff169052565b50506101009081015163ffffffff16908501526101209093019290850190600101613387565b5091979650505050505050565b6000806040838503121561343957600080fd5b50508035926020909101359150565b6020808252825182820181905260009190848201906040850190845b818110156134895783516001600160a01b031683529284019291840191600101613464565b50909695505050505050565b634e487b7160e01b600052601160045260246000fd5b8181038181111561109257611092613495565b6020808252600f908201526e496e76616c6964206164647265737360881b604082015260600190565b808202811582820484141761109257611092613495565b8082018082111561109257611092613495565b60006020828403121561352357600080fd5b5051919050565b634e487b7160e01b600052601260045260246000fd5b60008261354f5761354f61352a565b500490565b6020808252600b908201526a0b4cae4de40d8cadccee8d60ab1b604082015260600190565b6020808252601b908201527f496e76616c6964207374617274496e646578202b206c656e6774680000000000604082015260600190565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b6001600160401b038281168282160390808211156125d4576125d4613495565b60006001600160801b0382168061361557613615613495565b6000190192915050565b60006001600160801b0380831681810361363b5761363b613495565b6001019392505050565b60006001820161365757613657613495565b5060010190565b60008261366d5761366d61352a565b500690565b6001600160401b038181168382160190808211156125d4576125d4613495565b6000602082840312156136a457600080fd5b815161169f816131bd565b634e487b7160e01b600052603160045260246000fd5b60005b838110156136e05781810151838201526020016136c8565b50506000910152565b600082516136fb8184602087016136c5565b9190910192915050565b60208152600082518060208401526137248160408501602087016136c5565b601f01601f1916919091016040019291505056fea2646970667358221220b8bde0c9204ab83c213939abb091f159132841b20a591fe7f54a4291eaa1f76464736f6c63430008120033
Deployed ByteCode
0x608060405234801561001057600080fd5b50600436106103785760003560e01c80638446f31a116101d3578063db04aef411610104578063ebe2b12b116100a2578063f27890061161007c578063f27890061461080c578063f2fde38b14610815578063f7c618c114610828578063fbcd9b051461083b57600080fd5b8063ebe2b12b146107d7578063eda4e6d6146107ea578063f1752ec51461080457600080fd5b8063df136d65116100de578063df136d6514610794578063e627f2db1461079d578063e6d8aa94146107a5578063eb8af21a146107ae57600080fd5b8063db04aef414610763578063db3924211461076b578063dd5c6d471461077457600080fd5b8063c214048a11610171578063c98517c51161014b578063c98517c514610675578063ca66682314610689578063cd3daf9d14610692578063d5a44f861461069a57600080fd5b8063c214048a1461064b578063c24dbebd14610653578063c8f33c911461065b57600080fd5b8063a182dd13116101ad578063a182dd131461060d578063a694fc3a14610620578063bef4876b14610633578063bf21a8aa1461064057600080fd5b80638446f31a146105ec5780638da5cb5b146105f45780639a2f055f1461060557600080fd5b80634d6ed8c4116102ad578063715018a61161024b57806378c196f31161022557806378c196f3146105af5780637b0a47ee146105c957806380faa57d146105dc578063829ba2f2146105e457600080fd5b8063715018a6146105695780637180e5901461057157806372f702f31461058457600080fd5b80635fe8301b116102875780635fe8301b146104fa57806360eb8a2e1461050d5780636a89beb71461052057806370a082311461054057600080fd5b80634d6ed8c4146104bd5780635709632b146104d05780635c975abb146104e357600080fd5b8063379607f51161031a5780633a5dd35f116102f45780633a5dd35f146104675780634054c5c91461047a57806348c7d182146104825780634a1cc82b1461048b57600080fd5b8063379607f51461040f578063381b1d5714610422578063386a95251461043557600080fd5b80632503aea2116103565780632503aea2146103c057806326224c64146103c95780632e1a7d4d146103e9578063305ec69e146103fc57600080fd5b806316c38b3c1461037d57806318160ddd14610392578063184b9559146103ad575b600080fd5b61039061038b3660046131cb565b61084a565b005b61039a61086b565b6040519081526020015b60405180910390f35b6103906103bb3660046131fd565b61088d565b61039a609d5481565b61039a6103d7366004613248565b60a46020526000908152604090205481565b6103906103f7366004613265565b610a6d565b61039061040a366004613248565b610b57565b61039061041d366004613265565b610eeb565b61039061043036600461327e565b610f99565b609b5461044f90600160401b90046001600160401b031681565b6040516001600160401b0390911681526020016103a4565b61039a6104753660046132a7565b610fb5565b61039a600181565b61039a60a05481565b60a7546104a590600160801b90046001600160801b031681565b6040516001600160801b0390911681526020016103a4565b61039a6104cb366004613265565b610fe6565b61039a6104de366004613248565b611071565b60655460ff165b60405190151581526020016103a4565b6103906105083660046132d3565b611098565b61039061051b3660046132fc565b61126d565b61053361052e366004613335565b6114a5565b6040516103a4919061336a565b61039a61054e366004613248565b6001600160a01b0316600090815260a4602052604090205490565b610390611669565b6104ea61057f3660046132a7565b61167d565b609754610597906001600160a01b031681565b6040516001600160a01b0390911681526020016103a4565b6099546104a590600160801b90046001600160801b031681565b6099546104a5906001600160801b031681565b61044f6116a6565b61039a603c81565b6103906116d0565b6033546001600160a01b0316610597565b61039a611740565b61053361061b366004613335565b611759565b61039061062e366004613265565b611938565b60aa546104ea9060ff1681565b61039a6312cc030081565b61039a611aee565b61039a611b55565b609b5461044f90600160801b90046001600160401b031681565b61039a6c0c9f2c9cd04674edea4000000081565b61039a60a55481565b61039a611b76565b61070a6106a8366004613265565b60a16020526000908152604090208054600182015460028301546003840154600485015460059095015493949293919290916001600160a01b0381169063ffffffff600160a01b8204811691600160c01b8104821691600160e01b9091041689565b60408051998a5260208a019890985296880195909552606087019390935260808601919091526001600160a01b031660a085015263ffffffff90811660c085015290811660e084015216610100820152610120016103a4565b61039a611bff565b61039a609f5481565b610787610782366004613426565b611c0b565b6040516103a49190613448565b61039a609a5481565b61039a611cff565b61039a609e5481565b61039a6107bc366004613248565b6001600160a01b0316600090815260a2602052604090205490565b609b5461044f906001600160401b031681565b609b5461044f90600160c01b90046001600160401b031681565b61039a611dc1565b61039a609c5481565b610390610823366004613248565b611def565b609854610597906001600160a01b031681565b61039a670de0b6b3a764000081565b610852611e65565b801561086357610860611ebf565b50565b610860611f19565b30600090815260a4602052604081205460a65461088891906134ab565b905090565b600054610100900460ff16158080156108ad5750600054600160ff909116105b806108c75750303b1580156108c7575060005460ff166001145b61092f5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084015b60405180910390fd5b6000805460ff191660011790558015610952576000805461ff0019166101001790555b6001600160a01b0384166109785760405162461bcd60e51b8152600401610926906134be565b6001600160a01b03831661099e5760405162461bcd60e51b8152600401610926906134be565b6001600160a01b0382166109c45760405162461bcd60e51b8152600401610926906134be565b609780546001600160a01b038087166001600160a01b0319928316179092556098805492861692909116919091179055609b80546b01e13380000000000000000067ffffffffffffffff60401b19909116179055610a2182611f52565b8015610a67576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50505050565b610a78816001611fa4565b600080610a85833361200f565b91509150610a9161086b565b600003610aa357610aa3600130612253565b82337f75e161b3e824b114fc1a33274bd7091918dd4e639cede50b78b15a4eea956a2184610acf61086b565b6040805192835260208301919091520160405180910390a3604051818152839033907fd6f2c8500df5b44f11e9e48b91ff9f1b9d81bc496d55570c2b1b75bf65243f519060200160405180910390a38015610b3b57609854610b3b906001600160a01b03163383612446565b609754610b52906001600160a01b03163384612446565b505050565b610b5f611e65565b60aa5460ff1615610b9d5760405162461bcd60e51b8152602060048201526008602482015267119a5b9a5cda195960c21b6044820152606401610926565b6001600160a01b038116610be45760405162461bcd60e51b815260206004820152600e60248201526d16995c9bc81c9958d95c1a595b9d60921b6044820152606401610926565b609b546001600160401b03164281108015610bfe57508015155b610c425760405162461bcd60e51b815260206004820152601560248201527413db9b1e4818599d195c881c195c9a5bd908195b99605a1b6044820152606401610926565b609b54600090610c6290600160c01b90046001600160401b0316836134ab565b609954909150600090610c7f9083906001600160801b03166134e7565b905080609c6000828254610c9391906134fe565b9091555050609d54609e8054600090610cad9084906134fe565b90915550506000609d819055610cc1611740565b9050600060a05482609e54609c54610cd991906134ab565b610ce391906134ab565b610ced91906134ab565b6098546097546040516370a0823160e01b81523060048201529293506001600160a01b039182169291169060009083906370a0823190602401602060405180830381865afa158015610d43573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d679190613511565b6040516370a0823160e01b81523060048201529091506000906001600160a01b038416906370a0823190602401602060405180830381865afa158015610db1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dd59190613511565b60aa805460ff191660011790556040519091506001600160a01b038b16907fe6782ef5425ff7b9fdd779270f985cd651ea84df7bcf21f9ed6d9f29dceeb1c990600090a2826001600160a01b0316846001600160a01b031603610e86576000610e3c61086b565b9050610e4886826134fe565b610e5290846134ab565b15610e8057610e808b610e6588846134fe565b610e6f90866134ab565b6001600160a01b0388169190612446565b50610edf565b610e9085836134ab565b15610eb457610eb48a610ea387856134ab565b6001600160a01b0387169190612446565b6000610ebe61086b565b9050610eca81836134ab565b15610edd57610edd8b610ea383856134ab565b505b50505050505050505050565b610ef6816001611fa4565b6000610f0282336124a9565b905080600003610f475760405162461bcd60e51b815260206004820152601060248201526f4e6f7468696e6720746f20636c61696d60801b6044820152606401610926565b604051818152829033907fd6f2c8500df5b44f11e9e48b91ff9f1b9d81bc496d55570c2b1b75bf65243f519060200160405180910390a3609854610f95906001600160a01b03163383612446565b5050565b610fa1611e65565b610fac600080611fa4565b610860816125db565b60a26020528160005260406000208181548110610fd157600080fd5b90600052602060002001600091509150505481565b600081815260a1602052604081206005810154600160c01b900463ffffffff168203611068576001810154600061101b611b76565b6004840154600285015491925090600090670de0b6b3a764000061103f84866134ab565b61104990876134e7565b6110539190613540565b61105d91906134fe565b979650505050505050565b50600092915050565b6001600160a01b038116600090815260a36020526040812061109290612c5e565b92915050565b6110a0611e65565b609b546001600160401b031642116110fa5760405162461bcd60e51b815260206004820152601c60248201527f50726576696f757320706572696f64206e6f7420636f6d706c657465000000006044820152606401610926565b603c816001600160401b031610156111545760405162461bcd60e51b815260206004820152601d60248201527f52657761726473206475726174696f6e20697320746f6f2073686f72740000006044820152606401610926565b6312cc0300816001600160401b031611156111b15760405162461bcd60e51b815260206004820152601c60248201527f52657761726473206475726174696f6e20697320746f6f206c6f6e67000000006044820152606401610926565b609b546001600160401b03600160401b9091048116908216036112165760405162461bcd60e51b815260206004820152601a60248201527f52657761726473206475726174696f6e206475706c69636174650000000000006044820152606401610926565b609b805467ffffffffffffffff60401b1916600160401b6001600160401b038416908102919091179091556040517ffb46ca5a5e06d4540d6387b930a7c978bce0db5f449ec6b3f5d07c6e1d44f2d390600090a250565b611275611e65565b6001600160a01b0382166112bb5760405162461bcd60e51b815260206004820152600d60248201526c24b73b30b634b2103a37b5b2b760991b6044820152606401610926565b6001600160a01b0381166113025760405162461bcd60e51b815260206004820152600e60248201526d16995c9bc81c9958d95c1a595b9d60921b6044820152606401610926565b6097546001600160a01b03908116908316036113595760405162461bcd60e51b81526020600482015260166024820152752a37b5b2b7101e9e9039ba30b5b4b733903a37b5b2b760511b6044820152606401610926565b6098546001600160a01b03908116908316036113af5760405162461bcd60e51b81526020600482015260156024820152742a37b5b2b7101e9e903932bbb0b932103a37b5b2b760591b6044820152606401610926565b6040516370a0823160e01b81523060048201526000906001600160a01b038416906370a0823190602401602060405180830381865afa1580156113f6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061141a9190613511565b90508060000361145b5760405162461bcd60e51b815260206004820152600c60248201526b5a65726f2062616c616e636560a01b6044820152606401610926565b60405181906001600160a01b038416907f373d92bf7d9cdd58a8c86db5461f3cdcd325b803fdbac8d1b224a0f5fce847b890600090a3610b526001600160a01b0384168383612446565b6060816000036114c75760405162461bcd60e51b815260040161092690613554565b6001600160a01b038416600090815260a260205260409020546114ea83856134fe565b11156115085760405162461bcd60e51b815260040161092690613579565b6000826001600160401b03811115611522576115226135b0565b60405190808252806020026020018201604052801561155b57816020015b611548613156565b8152602001906001900390816115405790505b50905060005b83811015611660576001600160a01b038616600090815260a26020526040812061158b87846134fe565b8154811061159b5761159b6135c6565b600091825260208083209091015480835260a182526040928390208351610120810185528154815260018201549381019390935260028101549383019390935260038301546060830152600483015460808301526005909201546001600160a01b03811660a083015263ffffffff600160a01b8204811660c0840152600160c01b8204811660e0840152600160e01b9091041661010082015284519192509084908490811061164c5761164c6135c6565b602090810291909101015250600101611561565b50949350505050565b611671611e65565b61167b6000611f52565b565b6001600160a01b038216600090815260a36020526040812061169f9083612c68565b9392505050565b609b546000906001600160401b031642106116cb5750609b546001600160401b031690565b504290565b6116d8611e65565b6116e3600080611fa4565b6099546001600160801b03166000819003610fac5760405162461bcd60e51b815260206004820152601f60248201527f50726576696f757320726577617264207261746520697320746f6f206c6f77006044820152606401610926565b6000609f5461174f6000610fe6565b61088891906134fe565b60608160000361177b5760405162461bcd60e51b815260040161092690613554565b6001600160a01b038416600090815260a36020526040902061179c90612c5e565b6117a683856134fe565b11156117c45760405162461bcd60e51b815260040161092690613579565b6000826001600160401b038111156117de576117de6135b0565b60405190808252806020026020018201604052801561181757816020015b611804613156565b8152602001906001900390816117fc5790505b50905060005b8381101561166057600061185261183487846134fe565b6001600160a01b038916600090815260a36020526040902090612c80565b600081815260a160209081526040918290208251610120810184528154815260018201549281019290925260028101549282019290925260038201546060820152600482015460808201526005909101546001600160a01b03811660a083015263ffffffff600160a01b8204811660c0840152600160c01b8204811660e0840152600160e01b909104166101008201528451919250908490849081106118fa576118fa6135c6565b602002602001018190525061190e81610fe6565b838381518110611920576119206135c6565b6020908102919091010151604001525060010161181d565b611940612c8c565b600081116119815760405162461bcd60e51b815260206004820152600e60248201526d043616e6e6f74207374616b6520360941b6044820152606401610926565b6c0c9f2c9cd04674edea400000008111156119d65760405162461bcd60e51b81526020600482015260156024820152740a6e8c2d6ca40c2dadeeadce840e8dede40d0d2ced605b1b6044820152606401610926565b609b54426001600160401b0390911611611a325760405162461bcd60e51b815260206004820152601b60248201527f52657761726420706572696f64206e6f742061637469766174656400000000006044820152606401610926565b611a3a61086b565b600003611a7b57611a4d60006001611fa4565b6000611a5a60003061200f565b91505080609f6000828254611a6f91906134fe565b90915550611a86915050565b611a86600080611fa4565b611a908133612253565b60a554337fb4caaf29adda3eefee3ad552a8e85058589bf834c7466cae4ee58787f70589ed83611abe61086b565b6040805192835260208301919091520160405180910390a3609754610860906001600160a01b0316333084612cd2565b600080611af961086b565b905080600003611b0b57600091505090565b6099548190611b2c90670de0b6b3a7640000906001600160801b03166134e7565b611b3a906301e133806134e7565b611b459060646134e7565b611b4f9190613540565b91505090565b611b62603c6103e86134e7565b611b73906001600160801b03613540565b81565b60a654600090808203611b8b575050609a5490565b609954609b548291670de0b6b3a7640000916001600160801b0390911690600160801b90046001600160401b0316611bc16116a6565b611bcb91906135dc565b6001600160401b0316611bde91906134e7565b611be891906134e7565b611bf29190613540565b609a54611b4f91906134fe565b600061088860a8612c5e565b606081600003611c2d5760405162461bcd60e51b815260040161092690613554565b611c3760a8612c5e565b611c4183856134fe565b1115611c5f5760405162461bcd60e51b815260040161092690613579565b6000826001600160401b03811115611c7957611c796135b0565b604051908082528060200260200182016040528015611ca2578160200160208202803683370190505b50905060005b83811015611cf757611cc5611cbd86836134fe565b60a890612c80565b828281518110611cd757611cd76135c6565b6001600160a01b0390921660209283029190910190910152600101611ca8565b509392505050565b6000611d0961086b565b15611dbb57609b54600090600160c01b90046001600160401b0316611d2c6116a6565b611d3691906135dc565b609c5460aa546001600160401b039290921692509060ff16611d7657609954611d699083906001600160801b03166134e7565b611d7390826134fe565b90505b6000609d54609e54611d8891906134fe565b905060a054611d95611740565b611d9f83856134ab565b611da991906134ab565b611db391906134ab565b935050505090565b50600090565b30600090815260a360205260408120611dd990612c5e565b60a75461088891906001600160801b03166134ab565b611df7611e65565b6001600160a01b038116611e5c5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610926565b61086081611f52565b6033546001600160a01b0316331461167b5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610926565b611ec7612c8c565b6065805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258611efc3390565b6040516001600160a01b03909116815260200160405180910390a1565b611f21612d0a565b6065805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa33611efc565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b611fac611b76565b609a55611fb76116a6565b609b60106101000a8154816001600160401b0302191690836001600160401b031602179055508015610f9557611fec82610fe6565b600083815260a1602052604090206002810191909155609a546004909101555050565b600082815260a1602052604081206001810154600582015490929190600160c01b900463ffffffff16156120785760405162461bcd60e51b815260206004820152601060248201526f105b1c9958591e481d5b9cdd185ad95960821b6044820152606401610926565b60058101546001600160a01b038581169116146120d35760405162461bcd60e51b815260206004820152601960248201527821b0b63632b2103737ba10313c9039ba30b5b29037bbb732b960391b6044820152606401610926565b8260a660008282546120e591906134ab565b90915550506001600160a01b038416600090815260a46020526040812080548592906121129084906134ab565b909155505060a78054600090612130906001600160801b03166135fc565b91906101000a8154816001600160801b0302191690836001600160801b0316021790555061215e85856124a9565b6001600160a01b038516600090815260a4602052604090205490925015801561219057506001600160a01b0384163014155b156121a2576121a060a885612d53565b505b6001600160a01b038416600090815260a3602052604090206121c49086612d68565b506001600160a01b0384163014612201576001600160a01b038416600090815260a260209081526040822080546001810182559083529120018590555b50600093845260a1602052604090932060050180544263ffffffff908116600160e01b026001600160e01b034392909216600160c01b02919091166001600160c01b0390921691909117179055929050565b8160a6600082825461226591906134fe565b909155505060a78054600090612283906001600160801b031661361f565b91906101000a8154816001600160801b0302191690836001600160801b031602179055506000306001600160a01b0316826001600160a01b0316146122d95760a5600081546122d190613645565b918290555090505b60408051610120810182528281526020808201868152600083850181815260608501828152609a54608087019081526001600160a01b03808b1660a0890181815263ffffffff42811660c08c0190815260e08c018981526101008d018a81528f8b5260a18d528e8b209d518e559a5160018e0155975160028d0155955160038c0155935160048b015551600590990180549451955197518416600160e01b026001600160e01b03988516600160c01b02989098166001600160c01b0396909416600160a01b026001600160c01b031990951699909216989098179290921792909216919091179290921790915591825260a4905220541580156123e557506001600160a01b0382163014155b156123f7576123f560a883612d74565b505b6001600160a01b038216600090815260a460205260408120805485929061241f9084906134fe565b90915550506001600160a01b038216600090815260a360205260409020610a679082612d89565b6040516001600160a01b038316602482015260448101829052610b5290849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612d95565b600082815260a1602052604081206005810154600160c01b900463ffffffff16156125095760405162461bcd60e51b815260206004820152601060248201526f105b1c9958591e481d5b9cdd185ad95960821b6044820152606401610926565b60058101546001600160a01b038481169116146125645760405162461bcd60e51b815260206004820152601960248201527821b0b63632b2103737ba10313c9039ba30b5b29037bbb732b960391b6044820152606401610926565b60028101549150811580159061258357506001600160a01b0383163014155b156125a05781609d600082825461259a91906134fe565b90915550505b81156125d457600084815260a1602052604081206002810182905560030180548492906125ce9084906134fe565b90915550505b5092915050565b60aa5460ff16156126195760405162461bcd60e51b8152602060048201526008602482015267119a5b9a5cda195960c21b6044820152606401610926565b612626603c6103e86134e7565b612637906001600160801b03613540565b816001600160801b031611156126865760405162461bcd60e51b81526020600482015260146024820152730a4caeec2e4c840e4c2e8ca40e8dede40d0d2ced60631b6044820152606401610926565b609b54609954600160401b9091046001600160401b0316906001600160801b03908116906000906126ba90849086166134e7565b609b5460a7549192506001600160401b031690600190600160801b90046001600160801b0316600003612710576126f2600130612253565b5060a780546001600160801b03428116600160801b02911617905560005b6000821561275557609b54600160c01b90046001600160401b03166127336116a6565b61273d91906135dc565b612750906001600160401b0316866134e7565b612758565b60005b905080609c600082825461276c91906134fe565b9091555050609d54609e80546000906127869084906134fe565b90915550506000609d55428311612830576099546001600160401b038716906127bf90600160801b90046001600160801b0316866134fe565b6127c99190613540565b609980546001600160801b0319166001600160801b0392831617908190556001600160401b0388169161280491600160801b900416866134fe565b61280e919061365e565b609980546001600160801b03928316600160801b0292169190911790556128f0565b600061283c42856135dc565b609954909150600090600160801b90046001600160801b0316612868886001600160401b0385166134e7565b61287291906134fe565b90506001600160401b03881661288882886134fe565b6128929190613540565b609980546001600160801b0319166001600160801b03929092169190911790556001600160401b0388166128c682886134fe565b6128d0919061365e565b609980546001600160801b03928316600160801b02921691909117905550505b6099546001600160801b0316600081900361294d5760405162461bcd60e51b815260206004820152601d60248201527f41637475616c20726577617264207261746520697320746f6f206c6f770000006044820152606401610926565b6097546098546000916001600160a01b039182169116146129d9576098546040516370a0823160e01b81523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa1580156129b0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129d49190613511565b612a57565b6129e161086b565b6098546040516370a0823160e01b81523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa158015612a29573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a4d9190613511565b612a5791906134ab565b90506000612a6361086b565b1590506000612a70611740565b9050600060a05482609e54609c54612a8891906134ab565b612a9291906134ab565b612a9c91906134ab565b90506000609f819055508160a06000828254612ab891906134fe565b909155508390508015612ac85750865b15612ae757612ad960006001611fa4565b612ae460003061200f565b50505b838282612afd6001600160401b038f16896134e7565b612b0791906134fe565b612b1191906134fe565b1115612b5f5760405162461bcd60e51b815260206004820152601860248201527f50726f76696465642072657761726420746f6f206869676800000000000000006044820152606401610926565b609b80546001600160401b0342908116600160801b0267ffffffffffffffff60801b1990921691909117909155612b97908c90613672565b609b8054426001600160401b03908116600160c01b0277ffffffffffffffffffffffffffffffff0000000000000000909216931692909217919091179055828015612bdf5750865b15612bef57612bef600130612253565b8115612c1d57612c1d612c0a6033546001600160a01b031690565b6098546001600160a01b03169084612446565b6040518981527fde88a922e0d3b88b24e9623efeb464919c6bf9f66857a65e2bfcf2ce87a9433d9060200160405180910390a1505050505050505050505050565b6000611092825490565b6000818152600183016020526040812054151561169f565b600061169f8383612e6a565b60655460ff161561167b5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610926565b6040516001600160a01b0380851660248301528316604482015260648101829052610a679085906323b872dd60e01b90608401612472565b60655460ff1661167b5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610926565b600061169f836001600160a01b038416612e94565b600061169f8383612e94565b600061169f836001600160a01b038416612f87565b600061169f8383612f87565b6000612dea826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612fd69092919063ffffffff16565b9050805160001480612e0b575080806020019051810190612e0b9190613692565b610b525760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610926565b6000826000018281548110612e8157612e816135c6565b9060005260206000200154905092915050565b60008181526001830160205260408120548015612f7d576000612eb86001836134ab565b8554909150600090612ecc906001906134ab565b9050818114612f31576000866000018281548110612eec57612eec6135c6565b9060005260206000200154905080876000018481548110612f0f57612f0f6135c6565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080612f4257612f426136af565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050611092565b6000915050611092565b6000818152600183016020526040812054612fce57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155611092565b506000611092565b6060612fe58484600085612fed565b949350505050565b60608247101561304e5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610926565b600080866001600160a01b0316858760405161306a91906136e9565b60006040518083038185875af1925050503d80600081146130a7576040519150601f19603f3d011682016040523d82523d6000602084013e6130ac565b606091505b509150915061105d8783838760608315613127578251600003613120576001600160a01b0385163b6131205760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610926565b5081612fe5565b612fe5838381511561313c5781518083602001fd5b8060405162461bcd60e51b81526004016109269190613705565b604051806101200160405280600081526020016000815260200160008152602001600081526020016000815260200160006001600160a01b03168152602001600063ffffffff168152602001600063ffffffff168152602001600063ffffffff1681525090565b801515811461086057600080fd5b6000602082840312156131dd57600080fd5b813561169f816131bd565b6001600160a01b038116811461086057600080fd5b60008060006060848603121561321257600080fd5b833561321d816131e8565b9250602084013561322d816131e8565b9150604084013561323d816131e8565b809150509250925092565b60006020828403121561325a57600080fd5b813561169f816131e8565b60006020828403121561327757600080fd5b5035919050565b60006020828403121561329057600080fd5b81356001600160801b038116811461169f57600080fd5b600080604083850312156132ba57600080fd5b82356132c5816131e8565b946020939093013593505050565b6000602082840312156132e557600080fd5b81356001600160401b038116811461169f57600080fd5b6000806040838503121561330f57600080fd5b823561331a816131e8565b9150602083013561332a816131e8565b809150509250929050565b60008060006060848603121561334a57600080fd5b8335613355816131e8565b95602085013595506040909401359392505050565b602080825282518282018190526000919060409081850190868401855b828110156134195781518051855286810151878601528581015186860152606080820151908601526080808201519086015260a0808201516001600160a01b03169086015260c08082015163ffffffff169086015260e0808201516133f38288018263ffffffff169052565b50506101009081015163ffffffff16908501526101209093019290850190600101613387565b5091979650505050505050565b6000806040838503121561343957600080fd5b50508035926020909101359150565b6020808252825182820181905260009190848201906040850190845b818110156134895783516001600160a01b031683529284019291840191600101613464565b50909695505050505050565b634e487b7160e01b600052601160045260246000fd5b8181038181111561109257611092613495565b6020808252600f908201526e496e76616c6964206164647265737360881b604082015260600190565b808202811582820484141761109257611092613495565b8082018082111561109257611092613495565b60006020828403121561352357600080fd5b5051919050565b634e487b7160e01b600052601260045260246000fd5b60008261354f5761354f61352a565b500490565b6020808252600b908201526a0b4cae4de40d8cadccee8d60ab1b604082015260600190565b6020808252601b908201527f496e76616c6964207374617274496e646578202b206c656e6774680000000000604082015260600190565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b6001600160401b038281168282160390808211156125d4576125d4613495565b60006001600160801b0382168061361557613615613495565b6000190192915050565b60006001600160801b0380831681810361363b5761363b613495565b6001019392505050565b60006001820161365757613657613495565b5060010190565b60008261366d5761366d61352a565b500690565b6001600160401b038181168382160190808211156125d4576125d4613495565b6000602082840312156136a457600080fd5b815161169f816131bd565b634e487b7160e01b600052603160045260246000fd5b60005b838110156136e05781810151838201526020016136c8565b50506000910152565b600082516136fb8184602087016136c5565b9190910192915050565b60208152600082518060208401526137248160408501602087016136c5565b601f01601f1916919091016040019291505056fea2646970667358221220b8bde0c9204ab83c213939abb091f159132841b20a591fe7f54a4291eaa1f76464736f6c63430008120033