Contract Overview
Contract Name:
SystemStaking
Compiler Version
v0.8.17+commit.8df45f5f
// Sources flattened with hardhat v2.17.3 https://hardhat.org // SPDX-License-Identifier: MIT // File @openzeppelin/contracts/utils/[email protected] // Original license: SPDX_License_Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // File @openzeppelin/contracts/access/[email protected] // Original license: SPDX_License_Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.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 Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { _checkOwner(); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { require(owner() == _msgSender(), "Ownable: caller is not the owner"); } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing 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); } } // File @openzeppelin/contracts/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 Pausable is Context { /** * @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. */ constructor() { _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()); } } // File @openzeppelin/contracts/utils/introspection/[email protected] // Original license: SPDX_License_Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // File @openzeppelin/contracts/token/ERC721/[email protected] // Original license: SPDX_License_Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721 * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must * understand this adds an external call which potentially creates a reentrancy vulnerability. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); } // File @openzeppelin/contracts/token/ERC721/extensions/[email protected] // Original license: SPDX_License_Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // File @openzeppelin/contracts/token/ERC721/[email protected] // Original license: SPDX_License_Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // File @openzeppelin/contracts/utils/[email protected] // Original license: SPDX_License_Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [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://diligence.consensys.net/posts/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.5.11/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/utils/introspection/[email protected] // Original license: SPDX_License_Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // File @openzeppelin/contracts/utils/math/[email protected] // Original license: SPDX_License_Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol) pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { enum Rounding { Down, // Toward negative infinity Up, // Toward infinity Zero // Toward zero } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds up instead * of rounding down. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) * with further edits by Uniswap Labs also under MIT license. */ function mulDiv( uint256 x, uint256 y, uint256 denominator ) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod0 := mul(x, y) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. require(denominator > prod1); /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1. // See https://cs.stackexchange.com/q/138556/92363. // Does not overflow because the denominator cannot be zero at this stage in the function. uint256 twos = denominator & (~denominator + 1); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works // in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv( uint256 x, uint256 y, uint256 denominator, Rounding rounding ) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`. // // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)` // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))` // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)` // // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1 << (log2(a) >> 1); // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = sqrt(a); return result + (rounding == Rounding.Up && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2, rounded down, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 128; } if (value >> 64 > 0) { value >>= 64; result += 64; } if (value >> 32 > 0) { value >>= 32; result += 32; } if (value >> 16 > 0) { value >>= 16; result += 16; } if (value >> 8 > 0) { value >>= 8; result += 8; } if (value >> 4 > 0) { value >>= 4; result += 4; } if (value >> 2 > 0) { value >>= 2; result += 2; } if (value >> 1 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 2, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log2(value); return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10, rounded down, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >= 10**64) { value /= 10**64; result += 64; } if (value >= 10**32) { value /= 10**32; result += 32; } if (value >= 10**16) { value /= 10**16; result += 16; } if (value >= 10**8) { value /= 10**8; result += 8; } if (value >= 10**4) { value /= 10**4; result += 4; } if (value >= 10**2) { value /= 10**2; result += 2; } if (value >= 10**1) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0); } } /** * @dev Return the log in base 256, rounded down, of a positive value. * Returns 0 if given 0. * * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string. */ function log256(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 16; } if (value >> 64 > 0) { value >>= 64; result += 8; } if (value >> 32 > 0) { value >>= 32; result += 4; } if (value >> 16 > 0) { value >>= 16; result += 2; } if (value >> 8 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0); } } } // File @openzeppelin/contracts/utils/[email protected] // Original license: SPDX_License_Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _SYMBOLS = "0123456789abcdef"; uint8 private constant _ADDRESS_LENGTH = 20; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { unchecked { uint256 length = Math.log10(value) + 1; string memory buffer = new string(length); uint256 ptr; /// @solidity memory-safe-assembly assembly { ptr := add(buffer, add(32, length)) } while (true) { ptr--; /// @solidity memory-safe-assembly assembly { mstore8(ptr, byte(mod(value, 10), _SYMBOLS)) } value /= 10; if (value == 0) break; } return buffer; } } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { unchecked { return toHexString(value, Math.log256(value) + 1); } } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } /** * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation. */ function toHexString(address addr) internal pure returns (string memory) { return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH); } } // File @openzeppelin/contracts/token/ERC721/[email protected] // Original license: SPDX_License_Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/ERC721.sol) pragma solidity ^0.8.0; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: address zero is not a valid owner"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _ownerOf(tokenId); require(owner != address(0), "ERC721: invalid token ID"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { _requireMinted(tokenId); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overridden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not token owner or approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { _requireMinted(tokenId); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner or approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner or approved"); _safeTransfer(from, to, tokenId, data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns the owner of the `tokenId`. Does NOT revert if token doesn't exist */ function _ownerOf(uint256 tokenId) internal view virtual returns (address) { return _owners[tokenId]; } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _ownerOf(tokenId) != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { address owner = ERC721.ownerOf(tokenId); return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId, 1); // Check that tokenId was not minted by `_beforeTokenTransfer` hook require(!_exists(tokenId), "ERC721: token already minted"); unchecked { // Will not overflow unless all 2**256 token ids are minted to the same owner. // Given that tokens are minted one by one, it is impossible in practice that // this ever happens. Might change if we allow batch minting. // The ERC fails to describe this case. _balances[to] += 1; } _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); _afterTokenTransfer(address(0), to, tokenId, 1); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * This is an internal function that does not check if the sender is authorized to operate on the token. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId, 1); // Update ownership in case tokenId was transferred by `_beforeTokenTransfer` hook owner = ERC721.ownerOf(tokenId); // Clear approvals delete _tokenApprovals[tokenId]; unchecked { // Cannot overflow, as that would require more tokens to be burned/transferred // out than the owner initially received through minting and transferring in. _balances[owner] -= 1; } delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); _afterTokenTransfer(owner, address(0), tokenId, 1); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId, 1); // Check that tokenId was not transferred by `_beforeTokenTransfer` hook require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner"); // Clear approvals from the previous owner delete _tokenApprovals[tokenId]; unchecked { // `_balances[from]` cannot overflow for the same reason as described in `_burn`: // `from`'s balance is the number of token held, which is at least one before the current // transfer. // `_balances[to]` could overflow in the conditions described in `_mint`. That would require // all 2**256 token ids to be minted, which in practice is impossible. _balances[from] -= 1; _balances[to] += 1; } _owners[tokenId] = to; emit Transfer(from, to, tokenId); _afterTokenTransfer(from, to, tokenId, 1); } /** * @dev Approve `to` to operate on `tokenId` * * Emits an {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits an {ApprovalForAll} event. */ function _setApprovalForAll( address owner, address operator, bool approved ) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Reverts if the `tokenId` has not been minted yet. */ function _requireMinted(uint256 tokenId) internal view virtual { require(_exists(tokenId), "ERC721: invalid token ID"); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { /// @solidity memory-safe-assembly assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting and burning. If {ERC721Consecutive} is * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s tokens will be transferred to `to`. * - When `from` is zero, the tokens will be minted for `to`. * - When `to` is zero, ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * - `batchSize` is non-zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256, /* firstTokenId */ uint256 batchSize ) internal virtual { if (batchSize > 1) { if (from != address(0)) { _balances[from] -= batchSize; } if (to != address(0)) { _balances[to] += batchSize; } } } /** * @dev Hook that is called after any token transfer. This includes minting and burning. If {ERC721Consecutive} is * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s tokens were transferred to `to`. * - When `from` is zero, the tokens were minted for `to`. * - When `to` is zero, ``from``'s tokens were burned. * - `from` and `to` are never both zero. * - `batchSize` is non-zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 firstTokenId, uint256 batchSize ) internal virtual {} } // File src/SystemStaking.sol // Original license: SPDX_License_Identifier: MIT pragma solidity >=0.8; struct BucketInfo { uint256 typeIndex; uint256 unlockedAt; // UINT256_MAX: in lock uint256 unstakedAt; // UINT256_MAX: in stake address delegate; } struct BucketType { uint256 amount; uint256 duration; uint256 activatedAt; } contract SystemStaking is ERC721, Ownable, Pausable { uint256 public constant UINT256_MAX = type(uint256).max; uint256 public constant UNSTAKE_FREEZE_BLOCKS = 51840; // (3 * 24 * 60 * 60) / 5; event BucketTypeActivated(uint256 amount, uint256 duration); event BucketTypeDeactivated(uint256 amount, uint256 duration); event Staked(uint256 indexed tokenId, address delegate, uint256 amount, uint256 duration); event Locked(uint256 indexed tokenId, uint256 duration); event Unlocked(uint256 indexed tokenId); event Unstaked(uint256 indexed tokenId); event Merged(uint256[] tokenIds, uint256 amount, uint256 duration); event BucketExpanded(uint256 indexed tokenId, uint256 amount, uint256 duration); event DelegateChanged(uint256 indexed tokenId, address newDelegate); event Withdrawal(uint256 indexed tokenId, address indexed recipient); modifier onlyTokenOwner(uint256 _tokenId) { _assertOnlyTokenOwner(_tokenId); _; } // token id uint256 private __currTokenId; // mapping from token ID to bucket mapping(uint256 => BucketInfo) private __buckets; // delegate address -> bucket type -> count mapping(address => mapping(uint256 => uint256)) private __unlockedVotes; // delegate address -> bucket type -> count mapping(address => mapping(uint256 => uint256)) private __lockedVotes; // bucket type BucketType[] private __bucketTypes; // amount -> duration -> index mapping(uint256 => mapping(uint256 => uint256)) private __bucketTypeIndices; constructor() ERC721("BucketNFT", "BKT") {} function pause() external onlyOwner { _pause(); } function unpause() external onlyOwner { _unpause(); } function unsafeInc(uint256 x) private pure returns (uint256) { unchecked { return x + 1; } } function unsafeDec(uint256 x) private pure returns (uint256) { unchecked { return x - 1; } } // bucket type related functions function addBucketType(uint256 _amount, uint256 _duration) external onlyOwner { require(_amount != 0, "amount is invalid"); require(__bucketTypeIndices[_amount][_duration] == 0, "duplicate bucket type"); __bucketTypes.push(BucketType(_amount, _duration, block.number)); __bucketTypeIndices[_amount][_duration] = __bucketTypes.length; emit BucketTypeActivated(_amount, _duration); } function deactivateBucketType(uint256 _amount, uint256 _duration) external onlyOwner { __bucketTypes[_bucketTypeIndex(_amount, _duration)].activatedAt = UINT256_MAX; emit BucketTypeDeactivated(_amount, _duration); } function activateBucketType(uint256 _amount, uint256 _duration) external onlyOwner { __bucketTypes[_bucketTypeIndex(_amount, _duration)].activatedAt = block.number; emit BucketTypeActivated(_amount, _duration); } function isActiveBucketType(uint256 _amount, uint256 _duration) external view returns (bool) { return _isActiveBucketType(_bucketTypeIndex(_amount, _duration)); } function numOfBucketTypes() public view returns (uint256) { return __bucketTypes.length; } function bucketTypes( uint256 _offset, uint256 _size ) external view returns (BucketType[] memory types_) { require(_size > 0 && _offset + _size <= numOfBucketTypes(), "invalid parameters"); types_ = new BucketType[](_size); for (uint256 i = 0; i < _size; i = unsafeInc(i)) { unchecked { types_[i] = __bucketTypes[_offset + i]; } } } // token related functions function blocksToUnstake(uint256 _tokenId) external view returns (uint256) { _assertOnlyValidToken(_tokenId); BucketInfo storage bucket = __buckets[_tokenId]; _assertOnlyStakedToken(bucket); return _blocksToUnstake(bucket); } function blocksToWithdraw(uint256 _tokenId) external view returns (uint256) { _assertOnlyValidToken(_tokenId); return _blocksToWithdraw(__buckets[_tokenId].unstakedAt); } function bucketOf( uint256 _tokenId ) external view returns ( uint256 amount_, uint256 duration_, uint256 unlockedAt_, uint256 unstakedAt_, address delegate_ ) { _assertOnlyValidToken(_tokenId); BucketInfo storage bucket = __buckets[_tokenId]; BucketType storage bucketType = __bucketTypes[bucket.typeIndex]; return ( bucketType.amount, bucketType.duration, bucket.unlockedAt, bucket.unstakedAt, bucket.delegate ); } function stake( uint256 _duration, address _delegate ) external payable whenNotPaused returns (uint256) { uint256 msgValue = msg.value; uint256 index = _bucketTypeIndex(msgValue, _duration); _assertOnlyActiveBucketType(index); _stake(index, _delegate); uint256 tokenId = __currTokenId; emit Staked(tokenId, _delegate, msgValue, _duration); return tokenId; } function stake( uint256 _amount, uint256 _duration, address[] memory _delegates ) external payable whenNotPaused returns (uint256 firstTokenId_) { require(_amount * _delegates.length == msg.value, "invalid parameters"); uint256 index = _bucketTypeIndex(_amount, _duration); _assertOnlyActiveBucketType(index); unchecked { firstTokenId_ = __currTokenId + 1; } for (uint256 i = 0; i < _delegates.length; i = unsafeInc(i)) { _stake(index, _delegates[i]); emit Staked(firstTokenId_ + i, _delegates[i], _amount, _duration); } return firstTokenId_; } function stake( uint256 _amount, uint256 _duration, address _delegate, uint256 _count ) external payable whenNotPaused returns (uint256 firstTokenId_) { require(_count > 0 && _amount * _count == msg.value, "invalid parameters"); uint256 index = _bucketTypeIndex(_amount, _duration); _assertOnlyActiveBucketType(index); unchecked { firstTokenId_ = __currTokenId + 1; } for (uint256 i = 0; i < _count; i = unsafeInc(i)) { _stake(index, _delegate); emit Staked(firstTokenId_ + i, _delegate, _amount, _duration); } return firstTokenId_; } function unlock(uint256 _tokenId) external whenNotPaused onlyTokenOwner(_tokenId) { BucketInfo storage bucket = __buckets[_tokenId]; _assertOnlyLockedToken(bucket); _unlock(bucket); emit Unlocked(_tokenId); } function unlock(uint256[] calldata _tokenIds) external whenNotPaused { uint256 tokenId; BucketInfo storage bucket; for (uint256 i = 0; i < _tokenIds.length; i = unsafeInc(i)) { tokenId = _tokenIds[i]; _assertOnlyTokenOwner(tokenId); bucket = __buckets[tokenId]; _assertOnlyLockedToken(bucket); _unlock(bucket); emit Unlocked(tokenId); } } function lock( uint256 _tokenId, uint256 _duration ) external whenNotPaused onlyTokenOwner(_tokenId) { BucketInfo storage bucket = __buckets[_tokenId]; _assertOnlyStakedToken(bucket); _lock(bucket, _duration); emit Locked(_tokenId, _duration); } function lock(uint256[] calldata _tokenIds, uint256 _duration) external whenNotPaused { uint256 tokenId; BucketInfo storage bucket; for (uint256 i = 0; i < _tokenIds.length; i = unsafeInc(i)) { tokenId = _tokenIds[i]; _assertOnlyTokenOwner(tokenId); bucket = __buckets[tokenId]; _assertOnlyStakedToken(bucket); _lock(bucket, _duration); emit Locked(tokenId, _duration); } } function unstake(uint256 _tokenId) external whenNotPaused onlyTokenOwner(_tokenId) { BucketInfo storage bucket = __buckets[_tokenId]; _assertOnlyStakedToken(bucket); require(_blocksToUnstake(bucket) == 0, "not ready to unstake"); _unstake(bucket); emit Unstaked(_tokenId); } function unstake(uint256[] calldata _tokenIds) external whenNotPaused { uint256 tokenId; BucketInfo storage bucket; for (uint256 i = 0; i < _tokenIds.length; i = unsafeInc(i)) { tokenId = _tokenIds[i]; _assertOnlyTokenOwner(tokenId); bucket = __buckets[tokenId]; _assertOnlyStakedToken(bucket); require(_blocksToUnstake(bucket) == 0, "not ready to unstake"); _unstake(bucket); emit Unstaked(tokenId); } } function withdraw( uint256 _tokenId, address payable _recipient ) external whenNotPaused onlyTokenOwner(_tokenId) { BucketInfo storage bucket = __buckets[_tokenId]; require(_blocksToWithdraw(bucket.unstakedAt) == 0, "not ready to withdraw"); _burn(_tokenId); _withdraw(bucket, _recipient); emit Withdrawal(_tokenId, _recipient); } function withdraw( uint256[] calldata _tokenIds, address payable _recipient ) external whenNotPaused { uint256 tokenId; BucketInfo storage bucket; for (uint256 i = 0; i < _tokenIds.length; i = unsafeInc(i)) { tokenId = _tokenIds[i]; _assertOnlyTokenOwner(tokenId); bucket = __buckets[tokenId]; require(_blocksToWithdraw(bucket.unstakedAt) == 0, "not ready to withdraw"); _burn(tokenId); _withdraw(bucket, _recipient); emit Withdrawal(tokenId, _recipient); } } function merge( uint256[] calldata tokenIds, uint256 _newDuration ) external payable whenNotPaused { require(tokenIds.length > 1, "invalid length"); uint256 amount = msg.value; uint256 tokenId; BucketInfo storage bucket; BucketType storage bucketType; for (uint256 i = tokenIds.length; i > 0; ) { i = unsafeDec(i); tokenId = tokenIds[i]; _assertOnlyTokenOwner(tokenId); bucket = __buckets[tokenId]; _assertOnlyStakedToken(bucket); uint256 typeIndex = bucket.typeIndex; address delegate = bucket.delegate; bucketType = __bucketTypes[typeIndex]; require(_newDuration >= bucketType.duration, "invalid duration"); amount += bucketType.amount; if (_isTriggered(bucket.unlockedAt)) { __unlockedVotes[delegate][typeIndex] = unsafeDec( __unlockedVotes[delegate][typeIndex] ); } else { __lockedVotes[delegate][typeIndex] = unsafeDec(__lockedVotes[delegate][typeIndex]); } if (i != 0) { _burn(tokenId); } else { bucket.unlockedAt = UINT256_MAX; _updateBucketInfo(bucket, amount, _newDuration); emit Merged(tokenIds, amount, _newDuration); } } } function expandBucket( uint256 _tokenId, uint256 _newAmount, uint256 _newDuration ) external payable whenNotPaused onlyTokenOwner(_tokenId) { BucketInfo storage bucket = __buckets[_tokenId]; _assertOnlyLockedToken(bucket); uint256 typeIndex = bucket.typeIndex; BucketType storage bucketType = __bucketTypes[typeIndex]; require(_newDuration >= bucketType.duration, "invalid duration"); require(msg.value >= 0 && msg.value + bucketType.amount == _newAmount, "invalid amount"); __lockedVotes[bucket.delegate][typeIndex] = unsafeDec( __lockedVotes[bucket.delegate][typeIndex] ); _updateBucketInfo(bucket, _newAmount, _newDuration); emit BucketExpanded(_tokenId, _newAmount, _newDuration); } function changeDelegate( uint256 _tokenId, address _delegate ) external whenNotPaused onlyTokenOwner(_tokenId) { _changeDelegate(__buckets[_tokenId], _delegate); emit DelegateChanged(_tokenId, _delegate); } function changeDelegates( uint256[] calldata _tokenIds, address _delegate ) external whenNotPaused { uint256 tokenId; for (uint256 i = 0; i < _tokenIds.length; i = unsafeInc(i)) { tokenId = _tokenIds[i]; _assertOnlyTokenOwner(tokenId); _changeDelegate(__buckets[tokenId], _delegate); emit DelegateChanged(tokenId, _delegate); } } function lockedVotesTo( address[] calldata _delegates ) external view returns (uint256[][] memory counts_) { counts_ = new uint256[][](_delegates.length); uint256 tl = numOfBucketTypes(); for (uint256 i = 0; i < _delegates.length; i = unsafeInc(i)) { counts_[i] = new uint256[](tl); mapping(uint256 => uint256) storage votes = __lockedVotes[_delegates[i]]; for (uint256 j = 0; j < tl; j = unsafeInc(j)) { counts_[i][j] = votes[j]; } } return counts_; } function unlockedVotesTo( address[] calldata _delegates ) external view returns (uint256[][] memory counts_) { counts_ = new uint256[][](_delegates.length); uint256 tl = numOfBucketTypes(); for (uint256 i = 0; i < _delegates.length; i = unsafeInc(i)) { counts_[i] = new uint256[](tl); mapping(uint256 => uint256) storage votes = __unlockedVotes[_delegates[i]]; for (uint256 j = 0; j < tl; j = unsafeInc(j)) { counts_[i][j] = votes[j]; } } return counts_; } ///////////////////////////////////////////// // Private Functions function _bucketTypeIndex(uint256 _amount, uint256 _duration) internal view returns (uint256) { uint256 index = __bucketTypeIndices[_amount][_duration]; require(index > 0, "invalid bucket type"); return unsafeDec(index); } // bucket type index `_index` must be valid function _isActiveBucketType(uint256 _index) internal view returns (bool) { return __bucketTypes[_index].activatedAt <= block.number; } function _isTriggered(uint256 _value) internal pure returns (bool) { return _value != UINT256_MAX; } function _assertOnlyTokenOwner(uint256 _tokenId) internal view { require(msg.sender == ownerOf(_tokenId), "not owner"); } function _assertOnlyLockedToken(BucketInfo storage _bucket) internal view { require(!_isTriggered(_bucket.unlockedAt), "not a locked token"); } function _assertOnlyStakedToken(BucketInfo storage _bucket) internal view { require(!_isTriggered(_bucket.unstakedAt), "not a staked token"); } function _assertOnlyValidToken(uint256 _tokenId) internal view { require(_exists(_tokenId), "ERC721: invalid token ID"); } function _assertOnlyActiveBucketType(uint256 _index) internal view { require(_isActiveBucketType(_index), "inactive bucket type"); } function _beforeTokenTransfer( address _from, address _to, uint256 _firstTokenId, uint256 _batchSize ) internal override { require(_batchSize == 1, "batch transfer is not supported"); require( _to == address(0) || !_isTriggered(__buckets[_firstTokenId].unstakedAt), "cannot transfer unstaked token" ); super._beforeTokenTransfer(_from, _to, _firstTokenId, _batchSize); } function _blocksToWithdraw(uint256 _unstakedAt) internal view returns (uint256) { require(_isTriggered(_unstakedAt), "not an unstaked bucket"); uint256 withdrawBlock = _unstakedAt + UNSTAKE_FREEZE_BLOCKS; if (withdrawBlock <= block.number) { return 0; } unchecked { return withdrawBlock - block.number; } } function _blocksToUnstake(BucketInfo storage _bucket) internal view returns (uint256) { uint256 unlockedAt = _bucket.unlockedAt; require(_isTriggered(unlockedAt), "not an unlocked bucket"); uint256 unstakeBlock = unlockedAt + __bucketTypes[_bucket.typeIndex].duration; if (unstakeBlock <= block.number) { return 0; } unchecked { return unstakeBlock - block.number; } } function _stake(uint256 _index, address _delegate) internal { __currTokenId = unsafeInc(__currTokenId); __buckets[__currTokenId] = BucketInfo(_index, UINT256_MAX, UINT256_MAX, _delegate); __lockedVotes[_delegate][_index] = unsafeInc(__lockedVotes[_delegate][_index]); _safeMint(msg.sender, __currTokenId); } function _unlock(BucketInfo storage _bucket) internal { uint256 typeIndex = _bucket.typeIndex; address delegate = _bucket.delegate; _bucket.unlockedAt = block.number; __lockedVotes[delegate][typeIndex] = unsafeDec(__lockedVotes[delegate][typeIndex]); __unlockedVotes[delegate][typeIndex] = unsafeInc(__unlockedVotes[delegate][typeIndex]); } function _lock(BucketInfo storage _bucket, uint256 _duration) internal { uint256 typeIndex = _bucket.typeIndex; address delegate = _bucket.delegate; require(_duration >= _blocksToUnstake(_bucket), "invalid duration"); uint256 newIndex = _bucketTypeIndex(__bucketTypes[typeIndex].amount, _duration); _assertOnlyActiveBucketType(newIndex); _bucket.unlockedAt = UINT256_MAX; __unlockedVotes[delegate][typeIndex] = unsafeDec(__unlockedVotes[delegate][typeIndex]); _bucket.typeIndex = newIndex; __lockedVotes[delegate][newIndex] = unsafeInc(__lockedVotes[delegate][newIndex]); } function _unstake(BucketInfo storage _bucket) internal { _bucket.unstakedAt = block.number; __unlockedVotes[_bucket.delegate][_bucket.typeIndex] = unsafeDec( __unlockedVotes[_bucket.delegate][_bucket.typeIndex] ); } function _withdraw(BucketInfo storage _bucket, address payable _recipient) internal { uint256 amount = __bucketTypes[_bucket.typeIndex].amount; (bool success, ) = _recipient.call{value: amount}(""); require(success, "failed to transfer"); } function _updateBucketInfo( BucketInfo storage _bucket, uint256 _amount, uint256 _duration ) internal { uint256 index = _bucketTypeIndex(_amount, _duration); _assertOnlyActiveBucketType(index); __lockedVotes[_bucket.delegate][index] = unsafeInc(__lockedVotes[_bucket.delegate][index]); _bucket.typeIndex = index; } function _changeDelegate(BucketInfo storage _bucket, address _newDelegate) internal { _assertOnlyStakedToken(_bucket); uint256 typeIndex = _bucket.typeIndex; address delegate = _bucket.delegate; require(delegate != _newDelegate, "invalid operation"); if (_isTriggered(_bucket.unlockedAt)) { __unlockedVotes[delegate][typeIndex] = unsafeDec(__unlockedVotes[delegate][typeIndex]); __unlockedVotes[_newDelegate][typeIndex] = unsafeInc( __unlockedVotes[_newDelegate][typeIndex] ); } else { __lockedVotes[delegate][typeIndex] = unsafeDec(__lockedVotes[delegate][typeIndex]); __lockedVotes[_newDelegate][typeIndex] = unsafeInc( __lockedVotes[_newDelegate][typeIndex] ); } _bucket.delegate = _newDelegate; } }
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"duration","type":"uint256"}],"name":"BucketExpanded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"duration","type":"uint256"}],"name":"BucketTypeActivated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"duration","type":"uint256"}],"name":"BucketTypeDeactivated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"address","name":"newDelegate","type":"address"}],"name":"DelegateChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"duration","type":"uint256"}],"name":"Locked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"duration","type":"uint256"}],"name":"Merged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"address","name":"delegate","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"duration","type":"uint256"}],"name":"Staked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Unlocked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Unstaked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"}],"name":"Withdrawal","type":"event"},{"inputs":[],"name":"UINT256_MAX","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"UNSTAKE_FREEZE_BLOCKS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"uint256","name":"_duration","type":"uint256"}],"name":"activateBucketType","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"uint256","name":"_duration","type":"uint256"}],"name":"addBucketType","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"blocksToUnstake","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"blocksToWithdraw","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"bucketOf","outputs":[{"internalType":"uint256","name":"amount_","type":"uint256"},{"internalType":"uint256","name":"duration_","type":"uint256"},{"internalType":"uint256","name":"unlockedAt_","type":"uint256"},{"internalType":"uint256","name":"unstakedAt_","type":"uint256"},{"internalType":"address","name":"delegate_","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_offset","type":"uint256"},{"internalType":"uint256","name":"_size","type":"uint256"}],"name":"bucketTypes","outputs":[{"components":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"duration","type":"uint256"},{"internalType":"uint256","name":"activatedAt","type":"uint256"}],"internalType":"struct BucketType[]","name":"types_","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"address","name":"_delegate","type":"address"}],"name":"changeDelegate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_tokenIds","type":"uint256[]"},{"internalType":"address","name":"_delegate","type":"address"}],"name":"changeDelegates","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"uint256","name":"_duration","type":"uint256"}],"name":"deactivateBucketType","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"uint256","name":"_newAmount","type":"uint256"},{"internalType":"uint256","name":"_newDuration","type":"uint256"}],"name":"expandBucket","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"uint256","name":"_duration","type":"uint256"}],"name":"isActiveBucketType","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"uint256","name":"_duration","type":"uint256"}],"name":"lock","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_tokenIds","type":"uint256[]"},{"internalType":"uint256","name":"_duration","type":"uint256"}],"name":"lock","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_delegates","type":"address[]"}],"name":"lockedVotesTo","outputs":[{"internalType":"uint256[][]","name":"counts_","type":"uint256[][]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"},{"internalType":"uint256","name":"_newDuration","type":"uint256"}],"name":"merge","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"numOfBucketTypes","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"uint256","name":"_duration","type":"uint256"},{"internalType":"address","name":"_delegate","type":"address"},{"internalType":"uint256","name":"_count","type":"uint256"}],"name":"stake","outputs":[{"internalType":"uint256","name":"firstTokenId_","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_duration","type":"uint256"},{"internalType":"address","name":"_delegate","type":"address"}],"name":"stake","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"uint256","name":"_duration","type":"uint256"},{"internalType":"address[]","name":"_delegates","type":"address[]"}],"name":"stake","outputs":[{"internalType":"uint256","name":"firstTokenId_","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_tokenIds","type":"uint256[]"}],"name":"unlock","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"unlock","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_delegates","type":"address[]"}],"name":"unlockedVotesTo","outputs":[{"internalType":"uint256[][]","name":"counts_","type":"uint256[][]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"unstake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_tokenIds","type":"uint256[]"}],"name":"unstake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"address payable","name":"_recipient","type":"address"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_tokenIds","type":"uint256[]"},{"internalType":"address payable","name":"_recipient","type":"address"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
6080604052600436106103075760003560e01c8063715018a61161019a578063b8f4bd7b116100e1578063e449f3411161008a578063eec7ee7311610064578063eec7ee73146108d8578063f0b56b5d146108eb578063f2fde38b1461090157600080fd5b8063e449f3411461084f578063e985e9c51461086f578063eb0ffb2e146108b857600080fd5b8063c8e77923116100bb578063c8e77923146107f9578063d0949f9914610819578063e0028ecf1461082f57600080fd5b8063b8f4bd7b146107a6578063bbe33ea5146107c6578063c87b56dd146107d957600080fd5b806395d89b41116101435780639f7d5b001161011d5780639f7d5b0014610751578063a22cb46514610766578063b88d4fde1461078657600080fd5b806395d89b41146106fc578063960014bd1461071157806398ca3b761461073157600080fd5b80638456cb59116101745780638456cb59146106a95780638da5cb5b146106be57806393b6ef59146106dc57600080fd5b8063715018a61461065457806378bfca10146106695780637acb77571461069657600080fd5b80633f4ba83a1161025e5780635ceb8b5b116102075780636352211e116101e15780636352211e1461060157806370a0823114610621578063711563d41461064157600080fd5b80635ceb8b5b146105a15780635d36598f146105c15780636198e339146105e157600080fd5b8063431cd92a11610238578063431cd92a1461050057806343e06c59146105515780635c975abb1461057157600080fd5b80633f4ba83a1461049e5780633fd140df146104b357806342842e0e146104e057600080fd5b8063081812fc116102c05780631338736f1161029a5780631338736f1461043e57806323b872dd1461045e5780632e17de781461047e57600080fd5b8063081812fc146103c6578063095ea7b3146103fe5780630f5b2ca51461041e57600080fd5b8063025008ed116102f1578063025008ed1461036357806303459b161461037657806306fdde03146103a457600080fd5b8062f714ce1461030c57806301ffc9a71461032e575b600080fd5b34801561031857600080fd5b5061032c610327366004613bc4565b610921565b005b34801561033a57600080fd5b5061034e610349366004613c22565b6109f0565b60405190151581526020015b60405180910390f35b61032c610371366004613c3f565b610ad5565b34801561038257600080fd5b50610396610391366004613c6b565b610c55565b60405190815260200161035a565b3480156103b057600080fd5b506103b9610c7b565b60405161035a9190613cf2565b3480156103d257600080fd5b506103e66103e1366004613c6b565b610d0d565b6040516001600160a01b03909116815260200161035a565b34801561040a57600080fd5b5061032c610419366004613d05565b610d34565b34801561042a57600080fd5b5061032c610439366004613bc4565b610e65565b34801561044a57600080fd5b5061032c610459366004613d31565b610ed2565b34801561046a57600080fd5b5061032c610479366004613d53565b610f45565b34801561048a57600080fd5b5061032c610499366004613c6b565b610fcc565b3480156104aa57600080fd5b5061032c6110ad565b3480156104bf57600080fd5b506104d36104ce366004613de0565b6110bf565b60405161035a9190613e22565b3480156104ec57600080fd5b5061032c6104fb366004613d53565b611243565b34801561050c57600080fd5b5061052061051b366004613c6b565b61125e565b6040805195865260208601949094529284019190915260608301526001600160a01b0316608082015260a00161035a565b34801561055d57600080fd5b5061034e61056c366004613d31565b6112da565b34801561057d57600080fd5b5060065474010000000000000000000000000000000000000000900460ff1661034e565b3480156105ad57600080fd5b5061032c6105bc366004613eca565b6112f5565b3480156105cd57600080fd5b5061032c6105dc366004613de0565b61139c565b3480156105ed57600080fd5b5061032c6105fc366004613c6b565b61147d565b34801561060d57600080fd5b506103e661061c366004613c6b565b61152a565b34801561062d57600080fd5b5061039661063c366004613f16565b61158f565b61039661064f366004613f33565b611629565b34801561066057600080fd5b5061032c611732565b34801561067557600080fd5b50610689610684366004613d31565b611744565b60405161035a9190613f72565b6103966106a4366004613bc4565b6118aa565b3480156106b557600080fd5b5061032c61192e565b3480156106ca57600080fd5b506006546001600160a01b03166103e6565b3480156106e857600080fd5b506103966106f7366004613c6b565b61193e565b34801561070857600080fd5b506103b9611969565b34801561071d57600080fd5b506104d361072c366004613de0565b611978565b34801561073d57600080fd5b5061032c61074c366004613fcb565b611af4565b34801561075d57600080fd5b50600b54610396565b34801561077257600080fd5b5061032c610781366004614022565b611b8a565b34801561079257600080fd5b5061032c6107a13660046140d3565b611b99565b3480156107b257600080fd5b5061032c6107c1366004613fcb565b611c27565b61032c6107d4366004613eca565b611d1e565b3480156107e557600080fd5b506103b96107f4366004613c6b565b611f44565b34801561080557600080fd5b5061032c610814366004613d31565b611fb7565b34801561082557600080fd5b5061039660001981565b34801561083b57600080fd5b5061032c61084a366004613d31565b612170565b34801561085b57600080fd5b5061032c61086a366004613de0565b6121e4565b34801561087b57600080fd5b5061034e61088a3660046141b5565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b3480156108c457600080fd5b5061032c6108d3366004613d31565b6122f2565b6103966108e63660046141e3565b612368565b3480156108f757600080fd5b5061039661ca8081565b34801561090d57600080fd5b5061032c61091c366004613f16565b61249d565b61092961252d565b8161093381612598565b6000838152600860205260409020600281015461094f90612601565b156109a15760405162461bcd60e51b815260206004820152601560248201527f6e6f7420726561647920746f207769746864726177000000000000000000000060448201526064015b60405180910390fd5b6109aa8461267d565b6109b48184612738565b6040516001600160a01b0384169085907fd964a27d45f595739c13d8b1160b57491050cacf3a2e5602207277d6228f64ee90600090a350505050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f80ac58cd000000000000000000000000000000000000000000000000000000001480610a8357507fffffffff0000000000000000000000000000000000000000000000000000000082167f5b5e139f00000000000000000000000000000000000000000000000000000000145b80610acf57507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316145b92915050565b610add61252d565b82610ae781612598565b6000848152600860205260409020610afe81612802565b8054600b80546000919083908110610b1857610b186142aa565b906000526020600020906003020190508060010154851015610b7c5760405162461bcd60e51b815260206004820152601060248201527f696e76616c6964206475726174696f6e000000000000000000000000000000006044820152606401610998565b80548690610b8a9034614308565b14610bd75760405162461bcd60e51b815260206004820152600e60248201527f696e76616c696420616d6f756e740000000000000000000000000000000000006044820152606401610998565b60038301546001600160a01b03166000908152600a6020908152604080832085845290915290208054600019019055610c11838787612857565b604080518781526020810187905288917fd29e04160a74f0dbab5e7b82ef0392d86d11ac2939e5883eb3353be4cfedb83e910160405180910390a250505050505050565b6000610c60826128a3565b600082815260086020526040902060020154610acf90612601565b606060008054610c8a9061431b565b80601f0160208091040260200160405190810160405280929190818152602001828054610cb69061431b565b8015610d035780601f10610cd857610100808354040283529160200191610d03565b820191906000526020600020905b815481529060010190602001808311610ce657829003601f168201915b5050505050905090565b6000610d18826128a3565b506000908152600460205260409020546001600160a01b031690565b6000610d3f8261152a565b9050806001600160a01b0316836001600160a01b031603610dc85760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560448201527f72000000000000000000000000000000000000000000000000000000000000006064820152608401610998565b336001600160a01b0382161480610de45750610de4813361088a565b610e565760405162461bcd60e51b815260206004820152603d60248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f7420746f60448201527f6b656e206f776e6572206f7220617070726f76656420666f7220616c6c0000006064820152608401610998565b610e608383612907565b505050565b610e6d61252d565b81610e7781612598565b6000838152600860205260409020610e8f908361298d565b6040516001600160a01b038316815283907f6f08c7e76d830d5f3d0a18fd27f4d8c0049b24a8689ddb39625e0864d894a9c19060200160405180910390a2505050565b610eda61252d565b81610ee481612598565b6000838152600860205260409020610efb81612ad3565b610f058184612b28565b837f907fece23ce39fbcbceb71e515043fe29408353fbb393b25b35eb8a70a4bad0b84604051610f3791815260200190565b60405180910390a250505050565b610f4f3382612c22565b610fc15760405162461bcd60e51b815260206004820152602d60248201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560448201527f72206f7220617070726f766564000000000000000000000000000000000000006064820152608401610998565b610e60838383612ca0565b610fd461252d565b80610fde81612598565b6000828152600860205260409020610ff581612ad3565b610ffe81612eee565b1561104b5760405162461bcd60e51b815260206004820152601460248201527f6e6f7420726561647920746f20756e7374616b650000000000000000000000006044820152606401610998565b43600282015560038101546001600160a01b031660009081526009602090815260408083208454845290915280822080546000190190555184917f11725367022c3ff288940f4b5473aa61c2da6a24af7363a1128ee2401e8983b291a2505050565b6110b5612f9a565b6110bd612ff4565b565b60608167ffffffffffffffff8111156110da576110da614055565b60405190808252806020026020018201604052801561110d57816020015b60608152602001906001900390816110f85790505b509050600061111b600b5490565b905060005b8381101561123b578167ffffffffffffffff81111561114157611141614055565b60405190808252806020026020018201604052801561116a578160200160208202803683370190505b5083828151811061117d5761117d6142aa565b60200260200101819052506000600a60008787858181106111a0576111a06142aa565b90506020020160208101906111b59190613f16565b6001600160a01b03166001600160a01b03168152602001908152602001600020905060005b83811015611231576000818152602083905260409020548551869085908110611205576112056142aa565b6020026020010151828151811061121e5761121e6142aa565b60209081029190910101526001016111da565b5050600101611120565b505092915050565b610e6083838360405180602001604052806000815250611b99565b600080600080600061126f866128a3565b60008681526008602052604081208054600b80549293929091908110611297576112976142aa565b6000918252602090912060039182020180546001918201549185015460028601549590930154909b919a509198509296506001600160a01b031694509092505050565b60006112ee6112e98484613064565b6130d5565b9392505050565b6112fd61252d565b60008060005b848110156113945785858281811061131d5761131d6142aa565b90506020020135925061132f83612598565b6000838152600860205260409020915061134882612ad3565b6113528285612b28565b827f907fece23ce39fbcbceb71e515043fe29408353fbb393b25b35eb8a70a4bad0b8560405161138491815260200190565b60405180910390a2600101611303565b505050505050565b6113a461252d565b60008060005b83811015611476578484828181106113c4576113c46142aa565b9050602002013592506113d683612598565b600083815260086020526040902091506113ef82612802565b81546003830154436001808601919091556001600160a01b039091166000818152600a6020908152604080832086845282528083208054600019019055928252600981528282209482529390935280832080549092019091555184917ff27b6ce5b2f5e68ddb2fd95a8a909d4ecf1daaac270935fff052feacb24f184291a26001016113aa565b5050505050565b61148561252d565b8061148f81612598565b60008281526008602052604090206114a681612802565b80546003820154436001808501919091556001600160a01b039091166000818152600a6020908152604080832086845282528083208054600019019055928252600981528282209482529390935280832080549092019091555184917ff27b6ce5b2f5e68ddb2fd95a8a909d4ecf1daaac270935fff052feacb24f184291a2505050565b6000818152600260205260408120546001600160a01b031680610acf5760405162461bcd60e51b815260206004820152601860248201527f4552433732313a20696e76616c696420746f6b656e20494400000000000000006044820152606401610998565b60006001600160a01b03821661160d5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a2061646472657373207a65726f206973206e6f74206120766160448201527f6c6964206f776e657200000000000000000000000000000000000000000000006064820152608401610998565b506001600160a01b031660009081526003602052604090205490565b600061163361252d565b60008211801561164b575034611649838761436e565b145b6116975760405162461bcd60e51b815260206004820152601260248201527f696e76616c696420706172616d657465727300000000000000000000000000006044820152606401610998565b60006116a38686613064565b90506116ae81613106565b600754600101915060005b83811015611727576116cb828661315b565b6116d58184614308565b604080516001600160a01b0388168152602081018a90529081018890527f17700ceb1658b18206f427c1578048e87504106b14ec69e9b4586d9a95174a329060600160405180910390a26001016116b9565b50505b949350505050565b61173a612f9a565b6110bd600061320d565b60606000821180156117615750600b5461175e8385614308565b11155b6117ad5760405162461bcd60e51b815260206004820152601260248201527f696e76616c696420706172616d657465727300000000000000000000000000006044820152606401610998565b8167ffffffffffffffff8111156117c6576117c6614055565b60405190808252806020026020018201604052801561181b57816020015b61180860405180606001604052806000815260200160008152602001600081525090565b8152602001906001900390816117e45790505b50905060005b828110156118a357600b8185018154811061183e5761183e6142aa565b90600052602060002090600302016040518060600160405290816000820154815260200160018201548152602001600282015481525050828281518110611887576118876142aa565b602002602001018190525061189c8160010190565b9050611821565b5092915050565b60006118b461252d565b3460006118c18286613064565b90506118cc81613106565b6118d6818561315b565b600754604080516001600160a01b03871681526020810185905290810187905281907f17700ceb1658b18206f427c1578048e87504106b14ec69e9b4586d9a95174a329060600160405180910390a295945050505050565b611936612f9a565b6110bd613277565b6000611949826128a3565b600082815260086020526040902061196081612ad3565b6112ee81612eee565b606060018054610c8a9061431b565b60608167ffffffffffffffff81111561199357611993614055565b6040519080825280602002602001820160405280156119c657816020015b60608152602001906001900390816119b15790505b50905060006119d4600b5490565b905060005b8381101561123b578167ffffffffffffffff8111156119fa576119fa614055565b604051908082528060200260200182016040528015611a23578160200160208202803683370190505b50838281518110611a3657611a366142aa565b6020026020010181905250600060096000878785818110611a5957611a596142aa565b9050602002016020810190611a6e9190613f16565b6001600160a01b03166001600160a01b03168152602001908152602001600020905060005b83811015611aea576000818152602083905260409020548551869085908110611abe57611abe6142aa565b60200260200101518281518110611ad757611ad76142aa565b6020908102919091010152600101611a93565b50506001016119d9565b611afc61252d565b6000805b8381101561147657848482818110611b1a57611b1a6142aa565b905060200201359150611b2c82612598565b6000828152600860205260409020611b44908461298d565b6040516001600160a01b038416815282907f6f08c7e76d830d5f3d0a18fd27f4d8c0049b24a8689ddb39625e0864d894a9c19060200160405180910390a2600101611b00565b611b953383836132e6565b5050565b611ba33383612c22565b611c155760405162461bcd60e51b815260206004820152602d60248201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560448201527f72206f7220617070726f766564000000000000000000000000000000000000006064820152608401610998565b611c21848484846133d2565b50505050565b611c2f61252d565b60008060005b8481101561139457858582818110611c4f57611c4f6142aa565b905060200201359250611c6183612598565b60008381526008602052604090206002810154909250611c8090612601565b15611ccd5760405162461bcd60e51b815260206004820152601560248201527f6e6f7420726561647920746f20776974686472617700000000000000000000006044820152606401610998565b611cd68361267d565b611ce08285612738565b6040516001600160a01b0385169084907fd964a27d45f595739c13d8b1160b57491050cacf3a2e5602207277d6228f64ee90600090a3600101611c35565b611d2661252d565b60018211611d765760405162461bcd60e51b815260206004820152600e60248201527f696e76616c6964206c656e6774680000000000000000000000000000000000006044820152606401610998565b3460008080855b8015611f3a5760001901878782818110611d9957611d996142aa565b905060200201359350611dab84612598565b60008481526008602052604090209250611dc483612ad3565b82546003840154600b80546001600160a01b039092169183908110611deb57611deb6142aa565b906000526020600020906003020193508360010154881015611e4f5760405162461bcd60e51b815260206004820152601060248201527f696e76616c6964206475726174696f6e000000000000000000000000000000006044820152606401610998565b8354611e5b9088614308565b9650611e6d8560010154600019141590565b15611ea2576001600160a01b038116600090815260096020908152604080832085845290915290208054600019019055611ece565b6001600160a01b0381166000908152600a60209081526040808320858452909152902080546000190190555b8215611ee257611edd8661267d565b611f33565b6000196001860155611ef585888a612857565b7fb3f4c8ca702dbbd32d9a25ce17b1942a5060284d9d69fc4fcac8fb0397891b128a8a898b604051611f2a9493929190614385565b60405180910390a15b5050611d7d565b5050505050505050565b6060611f4f826128a3565b6000611f6660408051602081019091526000815290565b90506000815111611f8657604051806020016040528060008152506112ee565b80611f908461345b565b604051602001611fa19291906143e4565b6040516020818303038152906040529392505050565b611fbf612f9a565b8160000361200f5760405162461bcd60e51b815260206004820152601160248201527f616d6f756e7420697320696e76616c69640000000000000000000000000000006044820152606401610998565b6000828152600c60209081526040808320848452909152902054156120765760405162461bcd60e51b815260206004820152601560248201527f6475706c6963617465206275636b6574207479706500000000000000000000006044820152606401610998565b60408051606081018252838152602080820184815243838501908152600b8054600181018255600082815295517f0175b7a638427703f0dbe7bb9bbf987a2551717b34e79f33b5b1008d1fa01db960039092029182015592517f0175b7a638427703f0dbe7bb9bbf987a2551717b34e79f33b5b1008d1fa01dba84015590517f0175b7a638427703f0dbe7bb9bbf987a2551717b34e79f33b5b1008d1fa01dbb9092019190915554858352600c82528383208584528252918390209190915581518481529081018390527f6b39e3267efcd6611c8d7d2534c4715dcb4824322b90d85540a3a82967b6e7b791015b60405180910390a15050565b612178612f9a565b43600b6121858484613064565b81548110612195576121956142aa565b9060005260206000209060030201600201819055507f6b39e3267efcd6611c8d7d2534c4715dcb4824322b90d85540a3a82967b6e7b78282604051612164929190918252602082015260400190565b6121ec61252d565b60008060005b838110156114765784848281811061220c5761220c6142aa565b90506020020135925061221e83612598565b6000838152600860205260409020915061223782612ad3565b61224082612eee565b1561228d5760405162461bcd60e51b815260206004820152601460248201527f6e6f7420726561647920746f20756e7374616b650000000000000000000000006044820152606401610998565b43600283015560038201546001600160a01b031660009081526009602090815260408083208554845290915280822080546000190190555184917f11725367022c3ff288940f4b5473aa61c2da6a24af7363a1128ee2401e8983b291a26001016121f2565b6122fa612f9a565b600019600b6123098484613064565b81548110612319576123196142aa565b9060005260206000209060030201600201819055507f099df2bf9247b43481cf1b791a4dd5fa1220c40c62940da539082fbcb30241d68282604051612164929190918252602082015260400190565b600061237261252d565b34825185612380919061436e565b146123cd5760405162461bcd60e51b815260206004820152601260248201527f696e76616c696420706172616d657465727300000000000000000000000000006044820152606401610998565b60006123d98585613064565b90506123e481613106565b600754600101915060005b83518110156124945761241b8285838151811061240e5761240e6142aa565b602002602001015161315b565b6124258184614308565b7f17700ceb1658b18206f427c1578048e87504106b14ec69e9b4586d9a95174a32858381518110612458576124586142aa565b602090810291909101810151604080516001600160a01b0390921682529181018a905290810188905260600160405180910390a26001016123ef565b50509392505050565b6124a5612f9a565b6001600160a01b0381166125215760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610998565b61252a8161320d565b50565b60065474010000000000000000000000000000000000000000900460ff16156110bd5760405162461bcd60e51b815260206004820152601060248201527f5061757361626c653a20706175736564000000000000000000000000000000006044820152606401610998565b6125a18161152a565b6001600160a01b0316336001600160a01b03161461252a5760405162461bcd60e51b815260206004820152600960248201527f6e6f74206f776e657200000000000000000000000000000000000000000000006044820152606401610998565b600060001982036126545760405162461bcd60e51b815260206004820152601660248201527f6e6f7420616e20756e7374616b6564206275636b6574000000000000000000006044820152606401610998565b600061266261ca8084614308565b90504381116126745750600092915050565b43900392915050565b60006126888261152a565b90506126988160008460016134fb565b6126a18261152a565b600083815260046020908152604080832080547fffffffffffffffffffffffff00000000000000000000000000000000000000009081169091556001600160a01b0385168085526003845282852080546000190190558785526002909352818420805490911690555192935084927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a45050565b6000600b836000015481548110612751576127516142aa565b600091825260208220600390910201546040519092506001600160a01b0384169083908381818185875af1925050503d80600081146127ac576040519150601f19603f3d011682016040523d82523d6000602084013e6127b1565b606091505b5050905080611c215760405162461bcd60e51b815260206004820152601260248201527f6661696c656420746f207472616e7366657200000000000000000000000000006044820152606401610998565b60018101546000191461252a5760405162461bcd60e51b815260206004820152601260248201527f6e6f742061206c6f636b656420746f6b656e00000000000000000000000000006044820152606401610998565b60006128638383613064565b905061286e81613106565b60038401546001600160a01b03166000908152600a602090815260408083208484529091529020805460010190559092555050565b6000818152600260205260409020546001600160a01b031661252a5760405162461bcd60e51b815260206004820152601860248201527f4552433732313a20696e76616c696420746f6b656e20494400000000000000006044820152606401610998565b600081815260046020526040902080547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b03841690811790915581906129548261152a565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b61299682612ad3565b815460038301546001600160a01b0390811690831681036129f95760405162461bcd60e51b815260206004820152601160248201527f696e76616c6964206f7065726174696f6e0000000000000000000000000000006044820152606401610998565b600184015460001914612a4f576001600160a01b03818116600090815260096020818152604080842087855282528084208054600019019055938716835290815282822085835290522080546001019055612a94565b6001600160a01b038181166000908152600a60208181526040808420878552825280842080546000190190559387168352908152828220858352905220805460010190555b505060039190910180547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b03909216919091179055565b60028101546000191461252a5760405162461bcd60e51b815260206004820152601260248201527f6e6f742061207374616b656420746f6b656e00000000000000000000000000006044820152606401610998565b815460038301546001600160a01b0316612b4184612eee565b831015612b905760405162461bcd60e51b815260206004820152601060248201527f696e76616c6964206475726174696f6e000000000000000000000000000000006044820152606401610998565b6000612bc0600b8481548110612ba857612ba86142aa565b90600052602060002090600302016000015485613064565b9050612bcb81613106565b60001960018681018290556001600160a01b039390931660008181526009602090815260408083209783529681528682208054909401909355968390558652600a8152838620918652529220805490920190915550565b600080612c2e8361152a565b9050806001600160a01b0316846001600160a01b03161480612c7557506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b8061172a5750836001600160a01b0316612c8e84610d0d565b6001600160a01b031614949350505050565b826001600160a01b0316612cb38261152a565b6001600160a01b031614612d2f5760405162461bcd60e51b815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201527f6f776e65720000000000000000000000000000000000000000000000000000006064820152608401610998565b6001600160a01b038216612daa5760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f2061646460448201527f72657373000000000000000000000000000000000000000000000000000000006064820152608401610998565b612db783838360016134fb565b826001600160a01b0316612dca8261152a565b6001600160a01b031614612e465760405162461bcd60e51b815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201527f6f776e65720000000000000000000000000000000000000000000000000000006064820152608401610998565b600081815260046020908152604080832080547fffffffffffffffffffffffff00000000000000000000000000000000000000009081169091556001600160a01b0387811680865260038552838620805460001901905590871680865283862080546001019055868652600290945282852080549092168417909155905184937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b60018101546000906000198103612f475760405162461bcd60e51b815260206004820152601660248201527f6e6f7420616e20756e6c6f636b6564206275636b6574000000000000000000006044820152606401610998565b6000600b846000015481548110612f6057612f606142aa565b90600052602060002090600302016001015482612f7d9190614308565b9050438111612f90575060009392505050565b4390039392505050565b6006546001600160a01b031633146110bd5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610998565b612ffc6135cb565b600680547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff1690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b6000828152600c60209081526040808320848452909152812054806130cb5760405162461bcd60e51b815260206004820152601360248201527f696e76616c6964206275636b65742074797065000000000000000000000000006044820152606401610998565b600019810161172a565b600043600b83815481106130eb576130eb6142aa565b90600052602060002090600302016002015411159050919050565b61310f816130d5565b61252a5760405162461bcd60e51b815260206004820152601460248201527f696e616374697665206275636b657420747970650000000000000000000000006044820152606401610998565b6007805460019081018083556040805160808101825286815260001960208083018281528385019283526001600160a01b0389811660608601818152600098895260088552878920965187559251868a0155935160028601559051600390940180547fffffffffffffffffffffffff00000000000000000000000000000000000000001694909116939093179092558352600a8152818320878452905290208054909101905554611b95903390613635565b600680546001600160a01b038381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b61327f61252d565b600680547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff16740100000000000000000000000000000000000000001790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586130473390565b816001600160a01b0316836001600160a01b0316036133475760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610998565b6001600160a01b0383811660008181526005602090815260408083209487168084529482529182902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b6133dd848484612ca0565b6133e98484848461364f565b611c215760405162461bcd60e51b815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527f63656976657220696d706c656d656e74657200000000000000000000000000006064820152608401610998565b606060006134688361380b565b600101905060008167ffffffffffffffff81111561348857613488614055565b6040519080825280601f01601f1916602001820160405280156134b2576020820181803683370190505b5090508181016020015b600019017f3031323334353637383961626364656600000000000000000000000000000000600a86061a8153600a85049450846134bc57509392505050565b8060011461354b5760405162461bcd60e51b815260206004820152601f60248201527f6261746368207472616e73666572206973206e6f7420737570706f72746564006044820152606401610998565b6001600160a01b03831615806135735750600082815260086020526040902060020154600019145b6135bf5760405162461bcd60e51b815260206004820152601e60248201527f63616e6e6f74207472616e7366657220756e7374616b656420746f6b656e00006044820152606401610998565b611c21848484846138ed565b60065474010000000000000000000000000000000000000000900460ff166110bd5760405162461bcd60e51b815260206004820152601460248201527f5061757361626c653a206e6f74207061757365640000000000000000000000006044820152606401610998565b611b95828260405180602001604052806000815250613975565b60006001600160a01b0384163b15613803576040517f150b7a020000000000000000000000000000000000000000000000000000000081526001600160a01b0385169063150b7a02906136ac903390899088908890600401614413565b6020604051808303816000875af1925050508015613705575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01682019092526137029181019061444f565b60015b6137b8573d808015613733576040519150601f19603f3d011682016040523d82523d6000602084013e613738565b606091505b5080516000036137b05760405162461bcd60e51b815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527f63656976657220696d706c656d656e74657200000000000000000000000000006064820152608401610998565b805181602001fd5b7fffffffff00000000000000000000000000000000000000000000000000000000167f150b7a020000000000000000000000000000000000000000000000000000000014905061172a565b50600161172a565b6000807a184f03e93ff9f4daa797ed6e38ed64bf6a1f0100000000000000008310613854577a184f03e93ff9f4daa797ed6e38ed64bf6a1f010000000000000000830492506040015b6d04ee2d6d415b85acef81000000008310613880576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc10000831061389e57662386f26fc10000830492506010015b6305f5e10083106138b6576305f5e100830492506008015b61271083106138ca57612710830492506004015b606483106138dc576064830492506002015b600a8310610acf5760010192915050565b6001811115611c21576001600160a01b03841615613933576001600160a01b0384166000908152600360205260408120805483929061392d90849061446c565b90915550505b6001600160a01b03831615611c21576001600160a01b0383166000908152600360205260408120805483929061396a908490614308565b909155505050505050565b61397f83836139fe565b61398c600084848461364f565b610e605760405162461bcd60e51b815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527f63656976657220696d706c656d656e74657200000000000000000000000000006064820152608401610998565b6001600160a01b038216613a545760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610998565b6000818152600260205260409020546001600160a01b031615613ab95760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610998565b613ac76000838360016134fb565b6000818152600260205260409020546001600160a01b031615613b2c5760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610998565b6001600160a01b038216600081815260036020908152604080832080546001019055848352600290915280822080547fffffffffffffffffffffffff0000000000000000000000000000000000000000168417905551839291907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b6001600160a01b038116811461252a57600080fd5b60008060408385031215613bd757600080fd5b823591506020830135613be981613baf565b809150509250929050565b7fffffffff000000000000000000000000000000000000000000000000000000008116811461252a57600080fd5b600060208284031215613c3457600080fd5b81356112ee81613bf4565b600080600060608486031215613c5457600080fd5b505081359360208301359350604090920135919050565b600060208284031215613c7d57600080fd5b5035919050565b60005b83811015613c9f578181015183820152602001613c87565b50506000910152565b60008151808452613cc0816020860160208601613c84565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b6020815260006112ee6020830184613ca8565b60008060408385031215613d1857600080fd5b8235613d2381613baf565b946020939093013593505050565b60008060408385031215613d4457600080fd5b50508035926020909101359150565b600080600060608486031215613d6857600080fd5b8335613d7381613baf565b92506020840135613d8381613baf565b929592945050506040919091013590565b60008083601f840112613da657600080fd5b50813567ffffffffffffffff811115613dbe57600080fd5b6020830191508360208260051b8501011115613dd957600080fd5b9250929050565b60008060208385031215613df357600080fd5b823567ffffffffffffffff811115613e0a57600080fd5b613e1685828601613d94565b90969095509350505050565b6000602080830181845280855180835260408601915060408160051b87010192508387016000805b83811015613ebc578886037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc0018552825180518088529088019088880190845b81811015613ea65783518352928a0192918a0191600101613e8a565b5090975050509386019391860191600101613e4a565b509398975050505050505050565b600080600060408486031215613edf57600080fd5b833567ffffffffffffffff811115613ef657600080fd5b613f0286828701613d94565b909790965060209590950135949350505050565b600060208284031215613f2857600080fd5b81356112ee81613baf565b60008060008060808587031215613f4957600080fd5b84359350602085013592506040850135613f6281613baf565b9396929550929360600135925050565b602080825282518282018190526000919060409081850190868401855b82811015613fbe5781518051855286810151878601528501518585015260609093019290850190600101613f8f565b5091979650505050505050565b600080600060408486031215613fe057600080fd5b833567ffffffffffffffff811115613ff757600080fd5b61400386828701613d94565b909450925050602084013561401781613baf565b809150509250925092565b6000806040838503121561403557600080fd5b823561404081613baf565b915060208301358015158114613be957600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff811182821017156140cb576140cb614055565b604052919050565b600080600080608085870312156140e957600080fd5b84356140f481613baf565b935060208581013561410581613baf565b935060408601359250606086013567ffffffffffffffff8082111561412957600080fd5b818801915088601f83011261413d57600080fd5b81358181111561414f5761414f614055565b61417f847fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f84011601614084565b9150808252898482850101111561419557600080fd5b808484018584013760008482840101525080935050505092959194509250565b600080604083850312156141c857600080fd5b82356141d381613baf565b91506020830135613be981613baf565b6000806000606084860312156141f857600080fd5b833592506020808501359250604085013567ffffffffffffffff8082111561421f57600080fd5b818701915087601f83011261423357600080fd5b81358181111561424557614245614055565b8060051b9150614256848301614084565b818152918301840191848101908a84111561427057600080fd5b938501935b8385101561429a578435925061428a83613baf565b8282529385019390850190614275565b8096505050505050509250925092565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b80820180821115610acf57610acf6142d9565b600181811c9082168061432f57607f821691505b602082108103614368577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b8082028115828204841417610acf57610acf6142d9565b6060815283606082015260007f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8511156143be57600080fd5b8460051b8087608085013760208301949094525060408101919091520160800192915050565b600083516143f6818460208801613c84565b83519083019061440a818360208801613c84565b01949350505050565b60006001600160a01b038087168352808616602084015250836040830152608060608301526144456080830184613ca8565b9695505050505050565b60006020828403121561446157600080fd5b81516112ee81613bf4565b81810381811115610acf57610acf6142d956fea2646970667358221220b0324da8c15fb7ae9fef5db541816738e53967d5517f435e1c886a6400d0502164736f6c63430008110033
Age | Block | Fee Address | BC Fee Address | Voting Power | Jailed | Incoming |
---|
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for
interesting conversations.