Contract Overview
Contract Name:
IOTXStaking
Compiler Version
v0.8.9+commit.e5eed63a
// File: @openzeppelin/contracts/utils/introspection/IERC165.sol // 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/IERC721.sol // OpenZeppelin Contracts (last updated v4.9.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: interfaces/ISystemStaking.sol /* * ================================================================== * Copyright (C) 2023 Altstake Technology Pte. Ltd. (RockX) * This code is free software; you can redistribute it * and/or modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 3 of the License, * or (at your option) any later version. * This code is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License. * If not, see <http://www.gnu.org/licenses/> * ================================================================== */ pragma solidity ^0.8.9; // @notice This is the IoTeX system contract interface. It issues an NFT token for each bucket creation. // For more information see https://github.com/iotexproject/iip13-contracts/blob/main/src/SystemStaking.sol interface ISystemStaking is IERC721 { function isActiveBucketType(uint256 _amount, uint256 _duration) external view returns (bool); function bucketOf(uint _tokenId) external view returns ( uint amount_, uint duration_, uint unlockedAt_, uint unstakedAt_, address delegate_); function stake(uint _amount, uint _duration, address _delegate, uint _count) external payable returns (uint firstTokenId_); function unlock(uint[] calldata _tokenIds) external; function unstake(uint[] calldata _tokenIds) external; function withdraw( uint[] calldata _tokenIds, address payable _recipient) external; function merge(uint[] calldata tokenIds, uint _newDuration) external payable; function changeDelegates(uint[] calldata _tokenIds, address _delegate) external; } // File: @openzeppelin/contracts/token/ERC20/IERC20.sol // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 amount) external returns (bool); } // File: interfaces/IUniIOTX.sol /* * ================================================================== * Copyright (C) 2023 Altstake Technology Pte. Ltd. (RockX) * This code is free software; you can redistribute it * and/or modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 3 of the License, * or (at your option) any later version. * This code is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License. * If not, see <http://www.gnu.org/licenses/> * ================================================================== */ pragma solidity ^0.8.9; interface IUniIOTX is IERC20 { function mint(address account, uint amount) external; function burn(uint amount) external; function burnFrom(address account, uint256 amount) external; function batchTransfer(address[] memory recipients, uint256[] memory amounts) external; } // File: @openzeppelin/contracts/token/ERC721/IERC721Receiver.sol // 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: interfaces/IIOTXStaking.sol /* * ================================================================== * Copyright (C) 2023 Altstake Technology Pte. Ltd. (RockX) * This code is free software; you can redistribute it * and/or modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 3 of the License, * or (at your option) any later version. * This code is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License. * If not, see <http://www.gnu.org/licenses/> * ================================================================== */ pragma solidity ^0.8.9; interface IIOTXStaking is IERC721Receiver { function exchangeRatio() external returns (uint ratio); function currentReserve() external view returns(uint); function redeemAmountBase() external returns(uint); function getRedeemedTokenIdSlice(uint i, uint j) external view returns (uint[] memory tokenIds); function getStakedTokenCount(uint tokenQueueIndex) external view returns (uint count); function setGlobalDelegate(address delegate) external; function updateDelegates(uint[] calldata tokenIds, address delegate) external; function deposit(uint deadline) external payable returns (uint minted); function stake() external; function redeem(uint iotxsToRedeem, uint deadline) external returns (uint burned); function updateReward() external; function withdrawManagerFee(uint amount, address recipient) external; } // File: interfaces/IIOTXClear.sol /* * ================================================================== * Copyright (C) 2023 Altstake Technology Pte. Ltd. (RockX) * This code is free software; you can redistribute it * and/or modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 3 of the License, * or (at your option) any later version. * This code is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License. * If not, see <http://www.gnu.org/licenses/> * ================================================================== */ pragma solidity ^0.8.9; interface IIOTXClear is IERC721Receiver { function updateDelegates(uint[] calldata tokenIds, address delegate) external; function getReward(address acount) external returns (uint); function joinDebt(address claimAddr, uint amount) external; function unstake(uint[] calldata tokenIds) external; function payDebts(uint[] calldata tokenIds) external; function claimRewards(uint amount, address recipient) external; function claimPrincipals(uint amount, address recipient) external; function claim(uint amount, address recipient) external; } // File: interfaces/Roles.sol /* * ================================================================== * Copyright (C) 2023 Altstake Technology Pte. Ltd. (RockX) * This code is free software; you can redistribute it * and/or modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 3 of the License, * or (at your option) any later version. * This code is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License. * If not, see <http://www.gnu.org/licenses/> * ================================================================== */ pragma solidity ^0.8.9; // Roles bytes32 constant ROLE_PAUSER = keccak256("ROLE_PAUSER"); bytes32 constant ROLE_MINTER = keccak256("ROLE_MINTER"); bytes32 constant ROLE_STAKER = keccak256("ROLE_STAKER"); bytes32 constant ROLE_FEE_MANAGER = keccak256("ROLE_FEE_MANAGER"); bytes32 constant ROLE_ORACLE = keccak256("ROLE_ORACLE"); // File: @openzeppelin/contracts-upgradeable/utils/introspection/IERC165Upgradeable.sol // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165Upgradeable { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // File: @openzeppelin/contracts-upgradeable/utils/math/SignedMathUpgradeable.sol // OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol) pragma solidity ^0.8.0; /** * @dev Standard signed math utilities missing in the Solidity language. */ library SignedMathUpgradeable { /** * @dev Returns the largest of two signed numbers. */ function max(int256 a, int256 b) internal pure returns (int256) { return a > b ? a : b; } /** * @dev Returns the smallest of two signed numbers. */ function min(int256 a, int256 b) internal pure returns (int256) { return a < b ? a : b; } /** * @dev Returns the average of two signed numbers without overflow. * The result is rounded towards zero. */ function average(int256 a, int256 b) internal pure returns (int256) { // Formula from the book "Hacker's Delight" int256 x = (a & b) + ((a ^ b) >> 1); return x + (int256(uint256(x) >> 255) & (a ^ b)); } /** * @dev Returns the absolute unsigned value of a signed value. */ function abs(int256 n) internal pure returns (uint256) { unchecked { // must be unchecked in order to support `n = type(int256).min` return uint256(n >= 0 ? n : -n); } } } // File: @openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol // OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol) pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library MathUpgradeable { 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) { // Solidity will revert if denominator == 0, unlike the div opcode on its own. // The surrounding unchecked block does not change this fact. // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic. return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. require(denominator > prod1, "Math: mulDiv overflow"); /////////////////////////////////////////////// // 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 256, 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 << 3) < value ? 1 : 0); } } } // File: @openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol // OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library StringsUpgradeable { 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 = MathUpgradeable.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 `int256` to its ASCII `string` decimal representation. */ function toString(int256 value) internal pure returns (string memory) { return string(abi.encodePacked(value < 0 ? "-" : "", toString(SignedMathUpgradeable.abs(value)))); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { unchecked { return toHexString(value, MathUpgradeable.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); } /** * @dev Returns true if the two strings are equal. */ function equal(string memory a, string memory b) internal pure returns (bool) { return keccak256(bytes(a)) == keccak256(bytes(b)); } } // File: @openzeppelin/contracts-upgradeable/access/IAccessControlUpgradeable.sol // OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol) pragma solidity ^0.8.0; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControlUpgradeable { /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {AccessControl-_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) external view returns (bool); /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {AccessControl-_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) external view returns (bytes32); /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) external; /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) external; /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) external; } // File: @openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol // OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library AddressUpgradeable { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * * Furthermore, `isContract` will also return true if the target contract within * the same transaction is already scheduled for destruction by `SELFDESTRUCT`, * which only has an effect at the end of a transaction. * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } // File: @openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol // OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol) pragma solidity ^0.8.2; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in * case an upgrade adds a module that needs to be initialized. * * For example: * * [.hljs-theme-light.nopadding] * ```solidity * contract MyToken is ERC20Upgradeable { * function initialize() initializer public { * __ERC20_init("MyToken", "MTK"); * } * } * * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable { * function initializeV2() reinitializer(2) public { * __ERC20Permit_init("MyToken"); * } * } * ``` * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() { * _disableInitializers(); * } * ``` * ==== */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. * @custom:oz-retyped-from bool */ uint8 private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Triggered when the contract has been initialized or reinitialized. */ event Initialized(uint8 version); /** * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope, * `onlyInitializing` functions can be used to initialize parent contracts. * * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a * constructor. * * Emits an {Initialized} event. */ modifier initializer() { bool isTopLevelCall = !_initializing; require( (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1), "Initializable: contract is already initialized" ); _initialized = 1; if (isTopLevelCall) { _initializing = true; } _; if (isTopLevelCall) { _initializing = false; emit Initialized(1); } } /** * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be * used to initialize parent contracts. * * A reinitializer may be used after the original initialization step. This is essential to configure modules that * are added through upgrades and that require initialization. * * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer` * cannot be nested. If one is invoked in the context of another, execution will revert. * * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in * a contract, executing them in the right order is up to the developer or operator. * * WARNING: setting the version to 255 will prevent any future reinitialization. * * Emits an {Initialized} event. */ modifier reinitializer(uint8 version) { require(!_initializing && _initialized < version, "Initializable: contract is already initialized"); _initialized = version; _initializing = true; _; _initializing = false; emit Initialized(version); } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} and {reinitializer} modifiers, directly or indirectly. */ modifier onlyInitializing() { require(_initializing, "Initializable: contract is not initializing"); _; } /** * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call. * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized * to any version. It is recommended to use this to lock implementation contracts that are designed to be called * through proxies. * * Emits an {Initialized} event the first time it is successfully executed. */ function _disableInitializers() internal virtual { require(!_initializing, "Initializable: contract is initializing"); if (_initialized != type(uint8).max) { _initialized = type(uint8).max; emit Initialized(type(uint8).max); } } /** * @dev Returns the highest version that has been initialized. See {reinitializer}. */ function _getInitializedVersion() internal view returns (uint8) { return _initialized; } /** * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}. */ function _isInitializing() internal view returns (bool) { return _initializing; } } // File: @openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol // OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol) pragma solidity ^0.8.0; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuardUpgradeable is Initializable { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; function __ReentrancyGuard_init() internal onlyInitializing { __ReentrancyGuard_init_unchained(); } function __ReentrancyGuard_init_unchained() internal onlyInitializing { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { _nonReentrantBefore(); _; _nonReentrantAfter(); } function _nonReentrantBefore() private { // On the first call to nonReentrant, _status will be _NOT_ENTERED require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; } function _nonReentrantAfter() private { // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } /** * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a * `nonReentrant` function in the call stack. */ function _reentrancyGuardEntered() internal view returns (bool) { return _status == _ENTERED; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; } // File: @openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol // 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 ERC165Upgradeable is Initializable, IERC165Upgradeable { function __ERC165_init() internal onlyInitializing { } function __ERC165_init_unchained() internal onlyInitializing { } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165Upgradeable).interfaceId; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; } // File: @openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol // 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 ContextUpgradeable is Initializable { function __Context_init() internal onlyInitializing { } function __Context_init_unchained() internal onlyInitializing { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; } // File: @openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol // OpenZeppelin Contracts (last updated v4.9.0) (access/AccessControl.sol) pragma solidity ^0.8.0; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ```solidity * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ```solidity * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules} * to enforce additional security measures for this role. */ abstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControlUpgradeable, ERC165Upgradeable { function __AccessControl_init() internal onlyInitializing { } function __AccessControl_init_unchained() internal onlyInitializing { } struct RoleData { mapping(address => bool) members; bytes32 adminRole; } mapping(bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Modifier that checks that an account has a specific role. Reverts * with a standardized message including the required role. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ * * _Available since v4.1._ */ modifier onlyRole(bytes32 role) { _checkRole(role); _; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControlUpgradeable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view virtual override returns (bool) { return _roles[role].members[account]; } /** * @dev Revert with a standard message if `_msgSender()` is missing `role`. * Overriding this function changes the behavior of the {onlyRole} modifier. * * Format of the revert message is described in {_checkRole}. * * _Available since v4.6._ */ function _checkRole(bytes32 role) internal view virtual { _checkRole(role, _msgSender()); } /** * @dev Revert with a standard message if `account` is missing `role`. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ */ function _checkRole(bytes32 role, address account) internal view virtual { if (!hasRole(role, account)) { revert( string( abi.encodePacked( "AccessControl: account ", StringsUpgradeable.toHexString(account), " is missing role ", StringsUpgradeable.toHexString(uint256(role), 32) ) ) ); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleGranted} event. */ function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleRevoked} event. */ function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been revoked `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. * * May emit a {RoleRevoked} event. */ function renounceRole(bytes32 role, address account) public virtual override { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * May emit a {RoleGranted} event. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== * * NOTE: This function is deprecated in favor of {_grantRole}. */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { bytes32 previousAdminRole = getRoleAdmin(role); _roles[role].adminRole = adminRole; emit RoleAdminChanged(role, previousAdminRole, adminRole); } /** * @dev Grants `role` to `account`. * * Internal function without access restriction. * * May emit a {RoleGranted} event. */ function _grantRole(bytes32 role, address account) internal virtual { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } /** * @dev Revokes `role` from `account`. * * Internal function without access restriction. * * May emit a {RoleRevoked} event. */ function _revokeRole(bytes32 role, address account) internal virtual { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; } // File: @openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol // OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol) pragma solidity ^0.8.0; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract PausableUpgradeable is Initializable, ContextUpgradeable { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ function __Pausable_init() internal onlyInitializing { __Pausable_init_unchained(); } function __Pausable_init_unchained() internal onlyInitializing { _paused = false; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { _requireNotPaused(); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { _requirePaused(); _; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Throws if the contract is paused. */ function _requireNotPaused() internal view virtual { require(!paused(), "Pausable: paused"); } /** * @dev Throws if the contract is not paused. */ function _requirePaused() internal view virtual { require(paused(), "Pausable: not paused"); } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; } // File: contracts/IOTXStaking.sol /* * ================================================================== * Copyright (C) 2023 Altstake Technology Pte. Ltd. (RockX) * This code is free software; you can redistribute it * and/or modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 3 of the License, * or (at your option) any later version. * This code is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License. * If not, see <http://www.gnu.org/licenses/> * ================================================================== */ pragma solidity ^0.8.9; contract IOTXStaking is IIOTXStaking, Initializable, PausableUpgradeable, AccessControlUpgradeable, ReentrancyGuardUpgradeable { address public systemStaking; address public uniIOTX; address public iotxClear; uint private constant DEFAULT_EXCHANGE_RATIO = 1; uint private constant MULTIPLIER = 1e18; /** * @dev The global delegate for upcoming deposit activities. */ address public globalDelegate; /** * @dev The startAmount, commonRatio and sequenceLength collectively constitute a geometric sequence * for the staking amount that can be committed to the IoTeX network through our liquid staking protocol. * Each value in this sequence must be a valid bucket amount, as predefined by the IoTeX network. * Each value in this sequence corresponds to a unique indexed level within the range of [0, sequenceLength-1] * Once set, the sequence remains immutable. */ uint public startAmount; uint public commonRatio; uint public sequenceLength; /** * @dev Users can deposit any amount of IOTXs, but can only redeem amounts that are in multiples of the redeemAmountBase. * This value is determined at contract initialization using the formula: * redeemAmountBase = startAmount * (commonRatio ** (sequenceLength-1)) * Once set, it remains immutable. */ uint public redeemAmountBase; /** * @dev The global stake duration for upcoming deposit activities. * This value is determined at contract initialization. * Once set, it remains immutable. */ uint public stakeDuration; /** * @dev Token queue map for token ID management: * 1. The KEY corresponds to the bucket amount level defined as above. * 2. The VALUE is a dynamic array of token IDs. */ mapping(uint => uint[]) private tokenQueues; /** * @dev The number of redeemed tokens can change only when a redeeming operation is performed. * In addition, the staked token count at the highest staking level can be calculated using this formula: * tokenQueues[sequenceLength-1].length - redeemedTokenCount */ uint public redeemedTokenCount; /** * @dev The balance synchronized from this contract fluctuates due to several factors: * 1. It increases when users deposit IOTXs for liquid staking service. * 2. It increases when rewards are distributed by delegates. * 3. It decreases when pending IOTXs are staked with delegates. */ uint public accountedBalance; /** * @dev The total pending IOTXs fluctuates due to several factors: * 1. It increases when users deposit IOTXs for liquid staking service. * 2. It increases when users' rewards are compounded.. * 3. It increases when the manager fee is withdrawn. * 4. It decreases when pending IOTXs are staked with delegates. */ uint public totalPending; /** * @dev The total staked IOTXs fluctuates due to several factors: * 1.It increases when pending IOTXs are staked with delegates. * 2. It decreases when users request to redeem IOTXs. */ uint public totalStaked; /** * @dev The manager fee share ranges from 0 to 1000, as regulated by the default Admin. */ uint public managerFeeShares; /** * @dev The accounted user rewards will increase when the rewards are divided. * The total is equivalent to the amount of automatic compounding. */ uint public accountedUserReward; /** * @dev The accounted manger rewards will increase when the rewards are divided. * However, the quantity will decrease when the manager's fee is deducted. */ uint public accountedManagerReward; event Minted(address user, uint minted); event Redeemed(address user, uint burned, uint[] tokenIds); event Staked(uint firstTokenId, uint amount, address delegate, uint count); event Merged(uint fromLevel, uint toLevel, uint amount); event RewardUpdated(uint amount); event ManagerFeeSharesSet(uint shares); event ManagerFeeWithdrawed(uint amount, uint minted, address recipient); event GlobalDelegateSet(address delegate); event DelegatesUpdated(uint[] tokenIds, address delegate); modifier onlyValidTransaction(uint deadline) { require(deadline > block.timestamp, "USR001"); // Transaction expired _; } /** * ====================================================================================== * * SYSTEM SETTINGS * * ====================================================================================== */ /** * @dev This function is exclusively designed to receive staking rewards. * The 'deposit' function should be invoked whenever users wish to stake IOTXs. * Any IOTXs accidentally sent to this contract will be considered as rewards. */ receive() external payable { } /** * @dev This function pauses the contract */ function pause() public onlyRole(ROLE_PAUSER) { _pause(); } /** * @dev This function unpauses the contract */ function unpause() public onlyRole(ROLE_PAUSER) { _unpause(); } /** * @dev @custom:oz-upgrades-unsafe-allow constructor */ constructor() { _disableInitializers(); } /** * @dev This function initializes the contract. */ function initialize( address _systemStaking, address _uniIOTX, address _iotxClear, address _oracle, address _pauser, uint _startAmount, uint _commonRatio, uint _sequenceLength, uint _stakeDuration ) public initializer { // Init __Pausable_init(); __AccessControl_init(); __ReentrancyGuard_init(); // Roles _setupRole(DEFAULT_ADMIN_ROLE, msg.sender); _setupRole(ROLE_FEE_MANAGER, msg.sender); _setupRole(ROLE_PAUSER, _pauser); _setupRole(ROLE_ORACLE, _oracle); // Collaborative contracts systemStaking = _systemStaking; uniIOTX = _uniIOTX; iotxClear = _iotxClear; // Immutable staking variables startAmount = _startAmount; commonRatio = _commonRatio; sequenceLength = _sequenceLength; stakeDuration = _stakeDuration; redeemAmountBase = startAmount * (commonRatio ** (sequenceLength-1)); // Validate bucket type info for (uint level = 0; level < _sequenceLength; level++) { uint amount = _startAmount * (_commonRatio**level); bool isActive = ISystemStaking(systemStaking).isActiveBucketType(amount, _stakeDuration); require(isActive, "SYS001"); // Inactive bucket type } } /** * @dev This function sets manager's fee in range [0, 1000] */ function setManagerFeeShares(uint shares) external onlyRole(DEFAULT_ADMIN_ROLE) { require(shares <= 1000, "SYS002"); // Manager fee shares out of range managerFeeShares = shares; emit ManagerFeeSharesSet(shares); } /** * ====================================================================================== * * VIEW FUNCTIONS * * ====================================================================================== */ /** * @dev This function is the 'IERC721Receiver' implement for receiving staking NFT */ function onERC721Received( address, // operator address, // from uint, // tokenId bytes calldata // data ) external pure override returns (bytes4) { return this.onERC721Received.selector; } /** * @dev The factors that affect the returned result are the same as those of the 'currentReserve' function. * @return ratio The current exchange ratio of uniIOTX to IOTX, multiplied by 1e18. */ function exchangeRatio() external view returns (uint ratio) { return _exchangeRatio(); } /** * @dev The returned amount is determined by the following contributions: * 1. User deposits/stakes their principal. * 2. Rewards generated from delegation, excluding manager rewards, are added to the reserve. * 3. The manager fee is withdrawn and included in the totalPending amount. * 4. When users make a 'redeem' call, the totalStaked amount decreases. * 5. The Oracle service should regularly call the 'updateReward' function to account for new rewards. * @return The current reserve of IOTXs in our liquid staking protocol. */ function currentReserve() external view returns(uint) { return _currentReserve(); } /** * @return The array of IOTX amounts that remain constant and active for each staking activity. */ function getStakeAmounts() external view returns (uint[] memory) { uint[] memory amounts = new uint[](sequenceLength); for (uint level = 0; level < sequenceLength; level++) { uint amount = startAmount * (commonRatio**level); amounts[level] = amount; } return amounts; } /** * @return The global delegate that is utilized for upcoming staking requests. */ function getGlobalDelegate() external view returns (address) { return globalDelegate; } /** * @notice The amount to be redeemed must be in multiples of the 'redeemAmountBase'. * @return The base amount that remains constant for each redeeming request. */ function getRedeemAmountBase() external view returns (uint) { return redeemAmountBase; } /** * @return The stake duration in seconds that remains constant for each staking request. */ function getStakeDuration() external view returns (uint) { return stakeDuration; } /** * @return The balance that has been synchronized and accounted for this contract. */ function getAccountedBalance() external view returns (uint) { return accountedBalance; } /** * @return the pending reward that has not yet been synchronized and accounted for. */ function getPendingReward() external view returns(uint) { return address(this).balance - accountedBalance; } /** * @return The total amount of IOTX awaiting staking, including the pending user reward. */ function getTotalPending() external view returns (uint) { (uint pendingUserReward, ) = _calcPendingReward(); return totalPending + pendingUserReward; } /** * @return The total amount of staked IOTX. */ function getTotalStaked() external view returns (uint) { return totalStaked; } /** * @return The current manager fee shares. */ function getManagerFeeShares() external view returns (uint) { return managerFeeShares; } /** * @return The amount of the user's shared reward, including the pending portion. */ function getUserReward() external view returns (uint) { (uint userRewardIncr, ) = _calcPendingReward(); return accountedUserReward + userRewardIncr; } /** * @return The amount of the manager's reward, including the pending portion. */ function getManagerReward() external view returns (uint) { (, uint pendingManagerReward) = _calcPendingReward(); return accountedManagerReward + pendingManagerReward; } /** * @return The amount of the user's shared reward that has been automatically compounded for upcoming staking requests. */ function getCompoundedAmount() external view returns (uint) { return accountedUserReward; } /** * @dev If an invalid tokenQueueIndex is given, a zero value will be returned. * @param tokenQueueIndex The token queue index falls within the range of [0, sequenceLength). * @return The length of the queried token queue. */ function getTokenQueueLength(uint tokenQueueIndex) external view returns (uint) { if (tokenQueueIndex < sequenceLength) { return tokenQueues[tokenQueueIndex].length; } return 0; } /** * @dev If an invalid tokenQueueIndex is given, a zero value will be returned. * @param tokenQueueIndex The token queue index falls within the range of [0, sequenceLength). * @return count The current staked token count of the specified token queue. */ function getStakedTokenCount(uint tokenQueueIndex) external view returns (uint count) { if (tokenQueueIndex < sequenceLength) { uint queueLen = tokenQueues[tokenQueueIndex].length; if (tokenQueueIndex == sequenceLength-1) { count = queueLen - redeemedTokenCount; } else { count = queueLen; } } } /** * @return The number of redeemed token IDs. */ function getRedeemedTokenCount() external view returns (uint) { return redeemedTokenCount; } /** * @dev If an invalid tokenQueueIndex and tokenIndex are given, a zero value will be returned. * @param tokenQueueIndex The token queue index falls within the range of [0, sequenceLength). * @param tokenIndex The token index is within the range of [0, tokenQueue.Length) in the specified token queue.. * @return tokenId The queried token ID. */ function getTokenId(uint tokenQueueIndex, uint tokenIndex) external view returns (uint tokenId) { if (tokenQueueIndex < sequenceLength && tokenIndex < tokenQueues[tokenQueueIndex].length) { return tokenQueues[tokenQueueIndex][tokenIndex]; } return 0; } /** * @dev If an invalid tokenQueueIndex is given, an empty array will be returned. * @param tokenQueueIndex The token queue index falls within the range of [0, sequenceLength) * @return The staked token IDs for the specified index. */ function getStakedTokenIds(uint tokenQueueIndex) external view returns (uint[] memory) { if (tokenQueueIndex < sequenceLength) { uint[] memory tq = tokenQueues[tokenQueueIndex]; uint queueLen = tq.length; if (tokenQueueIndex == sequenceLength-1) { uint stakedCount = queueLen - redeemedTokenCount; uint[] memory tokenIds = new uint[](stakedCount); for (uint i = 0; i < stakedCount; i++) { tokenIds[i] = tq[redeemedTokenCount+i]; } return tokenIds; } else { return tq; } } return new uint[](0); } /** * @dev If param values are given, an empty array will be returned. * @param tokenQueueIndex The token queue index falls within the range of [0, sequenceLength) * @param i, j The index values for i and j should satisfy the following conditions: * 1. i < j && j < tokenQueues[tokenQueueIndex].length. * 2. i >= redeemedTokenCount if tokenQueueIndex == sequenceLength-1. * @return An [i, j) slice of staked token IDs for the specified index. */ function getStakedTokenIdSlice(uint tokenQueueIndex, uint i, uint j) external view returns (uint[] memory) { if (tokenQueueIndex < sequenceLength && i < j) { uint[] memory tq = tokenQueues[tokenQueueIndex]; uint[] memory tokenIds = new uint[](j-i); if (j <= tq.length) { for (uint k = 0; k < j-i; k++) { tokenIds[k] = tq[i+k]; } bool validI = true; if (tokenQueueIndex == sequenceLength-1 && i < redeemedTokenCount) { validI = false; } if (validI) { return tokenIds; } } } return new uint[](0); } /** * @return An array of already redeemed/unlocked token id, which is indexed from 0 in this contract. */ function getRedeemedTokenIds() external view returns (uint[] memory) { uint[] memory tq = tokenQueues[sequenceLength-1]; uint[] memory tokenIds = new uint[](redeemedTokenCount); for (uint i = 0; i < redeemedTokenCount; i++) { tokenIds[i] = tq[i]; } return tokenIds; } /** * @dev If an invalid tokenQueueIndex is given, an empty array will be returned. * @dev It recommended to check the value of 'redeemedTokenCount' beforehand to prevent the passed j from going out of range. * @param i, j The valid index values for i and j are determined by this conditional check: i < j && j <= redeemedTokenCount * @return An [i, j) slice of already redeemed/unlocked token id, which is indexed from 0 in this contract. */ function getRedeemedTokenIdSlice(uint i, uint j) external view returns (uint[] memory) { if (i < j && j <= redeemedTokenCount) { uint[] memory tq = tokenQueues[sequenceLength-1]; uint[] memory tokenIds = new uint[](j-i); for (uint k = 0; k < j-i; k++) { tokenIds[k] = tq[i+k]; } return tokenIds; } return new uint[](0); } /** * ====================================================================================== * * EXTERNAL FUNCTIONS FOR ORACLE * * ====================================================================================== */ /** * @dev This function sets the global delegate for upcoming deposit activities. */ function setGlobalDelegate(address delegate) external whenNotPaused onlyRole(ROLE_ORACLE) { globalDelegate = delegate; emit GlobalDelegateSet(delegate); } /** * @dev This function updates the delegates of token IDs. */ function updateDelegates(uint[] calldata tokenIds, address delegate) external whenNotPaused onlyRole(ROLE_ORACLE) { ISystemStaking(systemStaking).changeDelegates(tokenIds, delegate); emit DelegatesUpdated(tokenIds, delegate); } /** * @dev This function stakes any pending IOTXs and merges staked buckets when conditions are fulfilled. * It synchronizes the most recently distributed reward before conducting the staking operation. */ function stake() external whenNotPaused onlyRole(ROLE_ORACLE) { // Synchronize rewards _updateReward(); // Proceed with the staking process. _stakeAtTopLevel(); _stakeAndMergeAtSubLevel(); } /** * @dev This function distributes recently accrued rewards from delegates among users and the manager. * It also automatically reinvests the users' share into totalPending for upcoming staking activities. */ function updateReward() external onlyRole(ROLE_ORACLE) { _updateReward(); } /** * ====================================================================================== * * EXTERNAL FUNCTIONS FOR USERS * * ====================================================================================== */ /** * @dev This function mints uniIOTXs for the user, stakes any pending IOTXs and * merges staked buckets when conditions are fulfilled. * @return minted The quantity of minted uniIOTXs */ function deposit(uint deadline) external payable nonReentrant whenNotPaused onlyValidTransaction(deadline) returns (uint minted) { // Verify the transferred value require(msg.value > 0, "USR002"); // Invalid deposit amount accountedBalance += msg.value; // Mint uniIOTX, keeping a consistent exchange ratio _updateReward(); minted = _mint(); // Proceed with the staking process. _stakeAtTopLevel(); _stakeAndMergeAtSubLevel(); } /** * @dev This function unlocks staked bucket(s) and subsequently calls the 'IOTXClear' contract to record the debt. * @param iotxsToRedeem The number of IOTXs to redeem must be a multiple of the accepted amount of redeeming base. * @return burned the quantity of burned uniIOTXs. */ function redeem(uint iotxsToRedeem, uint deadline) external nonReentrant onlyValidTransaction(deadline) returns(uint burned) { burned = _redeem(iotxsToRedeem); } /** * ====================================================================================== * * EXTERNAL FUNCTIONS FOR FEE_MANAGER * * ====================================================================================== */ /** * @dev This function handles manager reward in this way: * 1. Mint uniIOTXs to the given recipient based on the given IOTX amount; * 2. Shift the corresponding amount of accountedManagerReward to totalPending. */ function withdrawManagerFee(uint amount, address recipient) external nonReentrant onlyRole(ROLE_FEE_MANAGER) { // Update the reward to help maintain a consistent exchange ratio _updateReward(); require(amount <= accountedManagerReward, "USR006"); // Insufficient accounted manager reward uint toMint = _convertIotxToUniIOTX(amount); IUniIOTX(uniIOTX).mint(recipient, toMint); accountedManagerReward -= amount; totalPending += amount; emit ManagerFeeWithdrawed(amount, toMint, recipient); } /** * ====================================================================================== * * INTERNAL FUNCTIONS * * ====================================================================================== */ /** * @dev This function mints uniIOTXs for the user based on their sent value and the latest exchange ratio. */ function _mint() internal returns (uint minted) { uint toMint = _convertIotxToUniIOTX(msg.value); IUniIOTX(uniIOTX).mint(msg.sender, toMint); minted = toMint; totalPending += msg.value; emit Minted(msg.sender, minted); } /** * @dev This function stakes IOTXs at the highest level, utilizing the maximum staking amount, * without incorporating any merging behaviors. */ function _stakeAtTopLevel() internal { // Determine values of stake params uint level = sequenceLength-1; (uint amount, uint count) = _getStakeAmountAndCount(level); if (count == 0) return; // Perform stake _doStake(level, amount, count); } /** * @dev This function stakes IOTXs at lower levels, using smaller staking amounts. * It may incorporate merging behaviors if conditions are met. */ function _stakeAndMergeAtSubLevel() internal { uint nextLevel = sequenceLength-2; while (totalPending >= startAmount) { nextLevel = _tryStake(nextLevel); } } /** * @dev This function verifies if the pending IOTXs are adequate for staking at the specified level. * If adequate , it triggers the '_doStake' function to execute the actual staking. * Otherwise, it will return a lower try level. */ function _tryStake(uint tryLevel) internal returns (uint nextLevel) { // Verify if there is an adequate total of pending IOTX and ascertain the values of stake parameters. (uint amount, uint count) = _getStakeAmountAndCount(tryLevel); if (count == 0) { return tryLevel-1; } uint stakedCount = tokenQueues[tryLevel].length; if ((count+stakedCount) >= commonRatio) { count = commonRatio-stakedCount; } // Perform stake _doStake(tryLevel, amount, count); // Merge tokens if possible if (count+stakedCount == commonRatio) _merge(tryLevel); return tryLevel; } /** * @dev This function carries out the actual staking activity. */ function _doStake(uint level, uint amount, uint count) internal { // Calculate total amount uint totalAmount = amount * count; // Call system stake service uint firstTokenId = ISystemStaking(systemStaking).stake{value:totalAmount}(amount, stakeDuration, globalDelegate, count); // Record minted & staked tokens uint[] storage tq = tokenQueues[level]; for (uint j = 0; j < count; j++) { tq.push(firstTokenId+j); } // Update fund status totalPending -= totalAmount; totalStaked += totalAmount; accountedBalance -= totalAmount; emit Staked(firstTokenId, amount, globalDelegate, count); } /** * @dev This function computes and return the available staking amount and count at the specified level, * considering the current total pending amount. */ function _getStakeAmountAndCount(uint level) internal view returns(uint amount, uint count) { amount = startAmount * (commonRatio**level); count = totalPending / amount; } /** * @dev This function combines lower-level tokens into upper-level ones. */ function _merge(uint fromLevel) internal { uint steps; for (uint i = fromLevel; i < sequenceLength-1; i++) { // Check merge condition uint[] storage tq = tokenQueues[i]; if (tq.length < commonRatio) break; // Call system merge service // All tokens will be merged into the first token in tokenIdsToMerge // Reference: https://github.com/iotexproject/iip13-contracts/blob/main/src/SystemStaking.sol#L302 ISystemStaking(systemStaking).merge(tq, stakeDuration); // Move the merged tokens to upper queue uint[] storage tqUpper = tokenQueues[i+1]; tqUpper.push(tq[0]); delete tokenQueues[i]; steps++; } uint toLevel = fromLevel + steps; uint mergeAmount = startAmount * (commonRatio**toLevel); emit Merged(fromLevel, toLevel, mergeAmount); } /** * @dev This function unlocks staked buckets and triggers the 'IOTXClear' contract to record corresponding debts. */ function _redeem(uint iotxsToRedeem) internal returns(uint burned) { // Check redeem condition require(iotxsToRedeem >= redeemAmountBase && iotxsToRedeem % redeemAmountBase == 0, "USR003"); // Invalid redeem amount // Update the reward to help maintain a consistent exchange ratio _updateReward(); // Burn uniIOTXs uint toBurn = _convertIotxToUniIOTX(iotxsToRedeem); IUniIOTX(uniIOTX).burnFrom(msg.sender, toBurn); burned = toBurn; totalStaked -= iotxsToRedeem; // Extract tokens to unlock uint [] memory tq = tokenQueues[sequenceLength-1]; uint count = iotxsToRedeem / redeemAmountBase; uint[] memory tokenIdsToUnlock = new uint[](count); for (uint i = 0; i < count; i++) { tokenIdsToUnlock[i] = tq[redeemedTokenCount]; redeemedTokenCount++; } // Call system unlock service ISystemStaking(systemStaking).unlock(tokenIdsToUnlock); // Transfer unlocked tokens to IOTXClear contract for (uint i = 0; i < count; i++) { ISystemStaking(systemStaking).safeTransferFrom(address(this), address(iotxClear), tokenIdsToUnlock[i]); } // Record corresponding amount of debt with IOTXClear contract IIOTXClear(iotxClear).joinDebt(msg.sender, iotxsToRedeem); emit Redeemed(msg.sender, burned, tokenIdsToUnlock); } /** * @dev This function calculates uniIOTX amount based on IOTX amount for mint and burn operation after updating * rewards, aiming to keep the exchange ratio invariant to avoid user arbitrage. * Reference: https://github.com/RockX-SG/stake/blob/main/doc/uniETH_ETH2_0_Liquid_Staking_Explained.pdf */ function _convertIotxToUniIOTX(uint amountIOTX) internal view returns (uint uniIOTXAmount) { uint totalSupply = IUniIOTX(uniIOTX).totalSupply(); uint currentReserveAmt = _accountedReserve(); uniIOTXAmount = DEFAULT_EXCHANGE_RATIO * amountIOTX; if (currentReserveAmt > 0) { // avert division overflow uniIOTXAmount = totalSupply * amountIOTX / currentReserveAmt; } } /** * @dev This function computes and returns the exchange ratio of uniIOTX to IOTX, multiplied by 1e18. */ function _exchangeRatio() internal view returns (uint ratio) { uint uniIOTXAmount = IUniIOTX(uniIOTX).totalSupply(); if (uniIOTXAmount == 0) { return DEFAULT_EXCHANGE_RATIO * MULTIPLIER; } ratio = _currentReserve() * MULTIPLIER / uniIOTXAmount; } /** * @dev This function computes and provides the current reserved IOTXs. */ function _currentReserve() internal view returns(uint) { (uint pendingUserReward, ) = _calcPendingReward(); return totalPending + totalStaked + pendingUserReward; } /** * @dev This function computes and provides the accounted reserved IOTXs. */ function _accountedReserve() internal view returns(uint) { return totalPending + totalStaked; } /** * @dev This function distributes recently accrued rewards from delegates among users and the manager. * It also automatically reinvests the users' share into totalPending for upcoming staking activities. */ function _updateReward() internal { uint reward = _syncReward(); if ( reward > 0 ){ uint userReward = _splitReward(reward); _compoundReward(userReward); emit RewardUpdated(reward); } } /** * @dev This function synchronizes the contract balance, calculating the increase in balance as the returned reward. */ function _syncReward() internal returns (uint reward) { uint thisBalance = address(this).balance; uint diff = thisBalance - accountedBalance; accountedBalance = thisBalance; reward = diff; } /** * @dev This function divides the specified reward amount between users and the manager. */ function _splitReward(uint reward) internal returns (uint userReward) { uint fee = reward * managerFeeShares / 1000; accountedManagerReward += fee; userReward = reward - fee; accountedUserReward += userReward; } /** * @dev This function incorporates the specified reward amount into the 'totalPending' value. */ function _compoundReward(uint amount) internal { totalPending += amount; } /** * @dev This function calculates the pending reward that has not yet been synchronized and accounted for. */ function _calcPendingReward() internal view returns(uint pendingUserReward, uint pendingManagerReward) { uint pendingReward = address(this).balance - accountedBalance; if (pendingReward > 0) { pendingManagerReward = pendingReward * managerFeeShares / 1000; return (pendingReward - pendingManagerReward, pendingManagerReward); } return (0, 0); } }
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"},{"indexed":false,"internalType":"address","name":"delegate","type":"address"}],"name":"DelegatesUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"delegate","type":"address"}],"name":"GlobalDelegateSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"}],"name":"ManagerFeeSharesSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"minted","type":"uint256"},{"indexed":false,"internalType":"address","name":"recipient","type":"address"}],"name":"ManagerFeeWithdrawed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"fromLevel","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"toLevel","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Merged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"minted","type":"uint256"}],"name":"Minted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"burned","type":"uint256"},{"indexed":false,"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"name":"Redeemed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"RewardUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"firstTokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"address","name":"delegate","type":"address"},{"indexed":false,"internalType":"uint256","name":"count","type":"uint256"}],"name":"Staked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"accountedBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"accountedManagerReward","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"accountedUserReward","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"commonRatio","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"currentReserve","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"deposit","outputs":[{"internalType":"uint256","name":"minted","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"exchangeRatio","outputs":[{"internalType":"uint256","name":"ratio","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getAccountedBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getCompoundedAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getGlobalDelegate","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getManagerFeeShares","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getManagerReward","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPendingReward","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getRedeemAmountBase","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getRedeemedTokenCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"i","type":"uint256"},{"internalType":"uint256","name":"j","type":"uint256"}],"name":"getRedeemedTokenIdSlice","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getRedeemedTokenIds","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getStakeAmounts","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getStakeDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenQueueIndex","type":"uint256"}],"name":"getStakedTokenCount","outputs":[{"internalType":"uint256","name":"count","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenQueueIndex","type":"uint256"},{"internalType":"uint256","name":"i","type":"uint256"},{"internalType":"uint256","name":"j","type":"uint256"}],"name":"getStakedTokenIdSlice","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenQueueIndex","type":"uint256"}],"name":"getStakedTokenIds","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenQueueIndex","type":"uint256"},{"internalType":"uint256","name":"tokenIndex","type":"uint256"}],"name":"getTokenId","outputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenQueueIndex","type":"uint256"}],"name":"getTokenQueueLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTotalPending","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTotalStaked","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getUserReward","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"globalDelegate","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_systemStaking","type":"address"},{"internalType":"address","name":"_uniIOTX","type":"address"},{"internalType":"address","name":"_iotxClear","type":"address"},{"internalType":"address","name":"_oracle","type":"address"},{"internalType":"address","name":"_pauser","type":"address"},{"internalType":"uint256","name":"_startAmount","type":"uint256"},{"internalType":"uint256","name":"_commonRatio","type":"uint256"},{"internalType":"uint256","name":"_sequenceLength","type":"uint256"},{"internalType":"uint256","name":"_stakeDuration","type":"uint256"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"iotxClear","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"managerFeeShares","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC721Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"iotxsToRedeem","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"redeem","outputs":[{"internalType":"uint256","name":"burned","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"redeemAmountBase","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"redeemedTokenCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"sequenceLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"delegate","type":"address"}],"name":"setGlobalDelegate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"shares","type":"uint256"}],"name":"setManagerFeeShares","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"stake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"stakeDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"startAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"systemStaking","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalPending","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalStaked","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"uniIOTX","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"},{"internalType":"address","name":"delegate","type":"address"}],"name":"updateDelegates","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"updateReward","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"}],"name":"withdrawManagerFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]
Contract Creation Code
6080604052600436106103855760003560e01c80635c975abb116101d1578063a5e35ef611610102578063d547741f116100a0578063f2be86b31161006f578063f2be86b314610991578063f36c0a72146109a7578063f6af7527146109bc578063fa0ec2ce146109d357600080fd5b8063d547741f14610926578063d793d83e14610946578063da7f9db31461095b578063efa9058b1461097b57600080fd5b8063b9bafb72116100dc578063b9bafb72146108c3578063becd0858146108da578063c030a6b9146108fa578063c081c90b1461091157600080fd5b8063a5e35ef614610870578063abe30c0b14610890578063b6b55f25146108b057600080fd5b8063817b1cd21161016f57806391d148541161014957806391d14854146108055780639f1bfc6c14610825578063a217fddf1461083b578063a59ec9971461085057600080fd5b8063817b1cd2146107c45780638456cb59146107db578063865112c1146107f057600080fd5b806364d5bae4116101ab57806364d5bae414610744578063797fa5c21461076657806379df5f41146107865780637cbc2373146107a457600080fd5b80635c975abb146106f55780635ff35b5c1461070d5780636322b5131461072457600080fd5b806333e5761f116102b65780633f4ba83a11610254578063489a2fa611610223578063489a2fa61461069357806348c26fce146106a95780635a23248d146106c05780635b3f86b4146106d557600080fd5b80633f4ba83a1461063b5780633f90916a146106505780634006ccc51461066757806340f02ab61461067c57600080fd5b806337f523451161029057806337f52345146105e35780633a4b66f1146105fa5780633bd054001461060f5780633dd419d01461062457600080fd5b806333e5761f1461058d57806335b83d28146105a357806336568abe146105c357600080fd5b8063229bf1b6116103235780632a67bbe5116102fd5780632a67bbe5146105225780632e12007c146105385780632f2ff15d1461054d5780633112de9a1461056d57600080fd5b8063229bf1b6146104b05780632328782f146104d2578063248a9ca3146104f257600080fd5b80630f7678721161035f5780630f767872146103fd57806311e4bc2d14610413578063150b7a021461044b5780632291f70a1461049057600080fd5b806301ffc9a7146103915780630917e776146103c65780630937eb54146103e657600080fd5b3661038c57005b600080fd5b34801561039d57600080fd5b506103b16103ac366004612cc7565b6109f3565b60405190151581526020015b60405180910390f35b3480156103d257600080fd5b50610108545b6040519081526020016103bd565b3480156103f257600080fd5b506103d86101065481565b34801561040957600080fd5b506103d860ff5481565b34801561041f57600080fd5b5060fe54610433906001600160a01b031681565b6040516001600160a01b0390911681526020016103bd565b34801561045757600080fd5b50610477610466366004612d08565b630a85bd0160e11b95945050505050565b6040516001600160e01b031990911681526020016103bd565b34801561049c57600080fd5b506103d86104ab366004612da3565b610a2a565b3480156104bc57600080fd5b506104d06104cb366004612dbc565b610a7e565b005b3480156104de57600080fd5b506104d06104ed366004612dd7565b610af4565b3480156104fe57600080fd5b506103d861050d366004612da3565b60009081526097602052604090206001015490565b34801561052e57600080fd5b50610109546103d8565b34801561054457600080fd5b506103d8610bbb565b34801561055957600080fd5b506104d0610568366004612e5b565b610bca565b34801561057957600080fd5b506103d8610588366004612e87565b610bf4565b34801561059957600080fd5b50610106546103d8565b3480156105af57600080fd5b5060fc54610433906001600160a01b031681565b3480156105cf57600080fd5b506104d06105de366004612e5b565b610c57565b3480156105ef57600080fd5b506103d86101025481565b34801561060657600080fd5b506104d0610cda565b34801561061b57600080fd5b506103d8610d15565b34801561063057600080fd5b506103d86101005481565b34801561064757600080fd5b506104d0610d38565b34801561065c57600080fd5b506103d86101075481565b34801561067357600080fd5b506103d8610d6a565b34801561068857600080fd5b506103d86101035481565b34801561069f57600080fd5b5061010a546103d8565b3480156106b557600080fd5b506103d861010b5481565b3480156106cc57600080fd5b506103d8610d74565b3480156106e157600080fd5b5060fd54610433906001600160a01b031681565b34801561070157600080fd5b5060335460ff166103b1565b34801561071957600080fd5b506103d861010a5481565b34801561073057600080fd5b506104d061073f366004612ea9565b610d85565b34801561075057600080fd5b5061075961109c565b6040516103bd9190612f6e565b34801561077257600080fd5b506103d8610781366004612da3565b611147565b34801561079257600080fd5b5060fe546001600160a01b0316610433565b3480156107b057600080fd5b506103d86107bf366004612e87565b611170565b3480156107d057600080fd5b506103d86101085481565b3480156107e757600080fd5b506104d06111c9565b3480156107fc57600080fd5b506103d86111fb565b34801561081157600080fd5b506103b1610820366004612e5b565b611218565b34801561083157600080fd5b50610103546103d8565b34801561084757600080fd5b506103d8600081565b34801561085c57600080fd5b5061075961086b366004612da3565b611243565b34801561087c57600080fd5b5060fb54610433906001600160a01b031681565b34801561089c57600080fd5b506107596108ab366004612f81565b6113ae565b6103d86108be366004612da3565b61153d565b3480156108cf57600080fd5b506103d86101055481565b3480156108e657600080fd5b506104d06108f5366004612da3565b611607565b34801561090657600080fd5b506103d86101015481565b34801561091d57600080fd5b50610759611683565b34801561093257600080fd5b506104d0610941366004612e5b565b61179c565b34801561095257600080fd5b506103d86117c1565b34801561096757600080fd5b50610759610976366004612e87565b6117de565b34801561098757600080fd5b50610105546103d8565b34801561099d57600080fd5b50610102546103d8565b3480156109b357600080fd5b506104d0611945565b3480156109c857600080fd5b506103d86101095481565b3480156109df57600080fd5b506104d06109ee366004612e5b565b611965565b60006001600160e01b03198216637965db0b60e01b1480610a2457506301ffc9a760e01b6001600160e01b03198316145b92915050565b600061010154821015610a79576000828152610104602052604090205461010154610a5790600190612fc3565b831415610a735761010554610a6c9082612fc3565b9150610a77565b8091505b505b919050565b610a86611ad4565b6000805160206133ce833981519152610a9e81611b1c565b60fe80546001600160a01b0319166001600160a01b0384169081179091556040519081527f19320da70b0c544e76e5dbc3c85129ac6d5d0d5486b4aa42982640788a157d71906020015b60405180910390a15050565b610afc611ad4565b6000805160206133ce833981519152610b1481611b1c565b60fb54604051634c651dbb60e11b81526001600160a01b03909116906398ca3b7690610b4890879087908790600401612fda565b600060405180830381600087803b158015610b6257600080fd5b505af1158015610b76573d6000803e3d6000fd5b505050507f055e970cad70d45557223e4ef35ac45bb162f8fc6f8a5986159f49d7d7fc742b848484604051610bad93929190612fda565b60405180910390a150505050565b6000610bc5611b26565b905090565b600082815260976020526040902060010154610be581611b1c565b610bef8383611b51565b505050565b60006101015483108015610c1657506000838152610104602052604090205482105b15610c4e57600083815261010460205260409020805483908110610c3c57610c3c61302c565b90600052602060002001549050610a24565b50600092915050565b6001600160a01b0381163314610ccc5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084015b60405180910390fd5b610cd68282611bd7565b5050565b610ce2611ad4565b6000805160206133ce833981519152610cfa81611b1c565b610d02611c3e565b610d0a611c96565b610d12611cd3565b50565b600080610d20611d04565b5090508061010754610d329190613042565b91505090565b7f372d55e37651a7c6e1940a3fb8628e4b6122a3c1a8b2b70aee13e07228604567610d6281611b1c565b610d12611d5a565b6000610bc5611dac565b60006101065447610bc59190612fc3565b600054610100900460ff1615808015610da55750600054600160ff909116105b80610dbf5750303b158015610dbf575060005460ff166001145b610e225760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610cc3565b6000805460ff191660011790558015610e45576000805461ff0019166101001790555b610e4d611e75565b610e55611ea4565b610e5d611ecb565b610e68600033611efa565b610e927f0fc26914248bb9568b0afb008dd993637f6fb6bdc9598c222c68a21e90ca53c133611efa565b610ebc7f372d55e37651a7c6e1940a3fb8628e4b6122a3c1a8b2b70aee13e0722860456787611efa565b610ed46000805160206133ce83398151915288611efa565b60fb80546001600160a01b03808d166001600160a01b03199283161790925560fc80548c841690831617905560fd8054928b169290911691909117905560ff859055610100849055610101839055610103829055610f33600184612fc3565b61010054610f41919061313e565b60ff54610f4e919061314a565b6101025560005b83811015611049576000610f69828761313e565b610f73908861314a565b60fb546040516343e06c5960e01b815260048101839052602481018790529192506000916001600160a01b03909116906343e06c599060440160206040518083038186803b158015610fc457600080fd5b505afa158015610fd8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ffc9190613169565b9050806110345760405162461bcd60e51b815260206004820152600660248201526553595330303160d01b6044820152606401610cc3565b505080806110419061318b565b915050610f55565b508015611090576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50505050505050505050565b606060006101015467ffffffffffffffff8111156110bc576110bc6131a6565b6040519080825280602002602001820160405280156110e5578160200160208202803683370190505b50905060005b61010154811015610a775760008161010054611107919061313e565b60ff54611114919061314a565b9050808383815181106111295761112961302c565b6020908102919091010152508061113f8161318b565b9150506110eb565b60006101015482101561116857506000908152610104602052604090205490565b506000919050565b600061117a611f04565b814281116111b35760405162461bcd60e51b815260206004820152600660248201526555535230303160d01b6044820152606401610cc3565b6111bc84611f5e565b915050610a24600160c955565b7f372d55e37651a7c6e1940a3fb8628e4b6122a3c1a8b2b70aee13e072286045676111f381611b1c565b610d1261235a565b600080611206611d04565b9150508061010b54610d329190613042565b60009182526097602090815260408084206001600160a01b0393909316845291905290205460ff1690565b60606101015482101561139857600082815261010460209081526040808320805482518185028101850190935280835291929091908301828280156112a757602002820191906000526020600020905b815481526020019060010190808311611293575b505050505090506000815190506001610101546112c49190612fc3565b84141561139157600061010554826112dc9190612fc3565b905060008167ffffffffffffffff8111156112f9576112f96131a6565b604051908082528060200260200182016040528015611322578160200160208202803683370190505b50905060005b82811015611387578481610105546113409190613042565b815181106113505761135061302c565b602002602001015182828151811061136a5761136a61302c565b60209081029190910101528061137f8161318b565b915050611328565b5095945050505050565b5092915050565b6040805160008082526020820190925290611391565b606061010154841080156113c157508183105b15611525576000848152610104602090815260408083208054825181850281018501909352808352919290919083018282801561141d57602002820191906000526020600020905b815481526020019060010190808311611409575b50505050509050600084846114329190612fc3565b67ffffffffffffffff81111561144a5761144a6131a6565b604051908082528060200260200182016040528015611473578160200160208202803683370190505b509050815184116115225760005b61148b8686612fc3565b8110156114e4578261149d8288613042565b815181106114ad576114ad61302c565b60200260200101518282815181106114c7576114c761302c565b6020908102919091010152806114dc8161318b565b915050611481565b50610101546001906114f7908290612fc3565b8714801561150757506101055486105b15611510575060005b8015611520575091506115369050565b505b50505b506040805160008152602081019091525b9392505050565b6000611547611f04565b61154f611ad4565b814281116115885760405162461bcd60e51b815260206004820152600660248201526555535230303160d01b6044820152606401610cc3565b600034116115c15760405162461bcd60e51b81526020600482015260066024820152652aa9a918181960d11b6044820152606401610cc3565b3461010660008282546115d49190613042565b909155506115e29050611c3e565b6115ea612397565b91506115f4611c96565b6115fc611cd3565b50610a79600160c955565b600061161281611b1c565b6103e882111561164d5760405162461bcd60e51b815260206004820152600660248201526529aca998181960d11b6044820152606401610cc3565b6101098290556040518281527fb6efe094bbb68f7f840c92b10663dc9fdee2f9c7b4b7ba75d88b13e0b685b22890602001610ae8565b60606000610104600060016101015461169c9190612fc3565b81526020019081526020016000208054806020026020016040519081016040528092919081815260200182805480156116f457602002820191906000526020600020905b8154815260200190600101908083116116e0575b5050505050905060006101055467ffffffffffffffff811115611719576117196131a6565b604051908082528060200260200182016040528015611742578160200160208202803683370190505b50905060005b61010554811015611391578281815181106117655761176561302c565b602002602001015182828151811061177f5761177f61302c565b6020908102919091010152806117948161318b565b915050611748565b6000828152609760205260409020600101546117b781611b1c565b610bef8383611bd7565b6000806117cc611d04565b5090508061010a54610d329190613042565b606081831080156117f25750610105548211155b1561192f576000610104600060016101015461180e9190612fc3565b815260200190815260200160002080548060200260200160405190810160405280929190818152602001828054801561186657602002820191906000526020600020905b815481526020019060010190808311611852575b505050505090506000848461187b9190612fc3565b67ffffffffffffffff811115611893576118936131a6565b6040519080825280602002602001820160405280156118bc578160200160208202803683370190505b50905060005b6118cc8686612fc3565b81101561192557826118de8288613042565b815181106118ee576118ee61302c565b60200260200101518282815181106119085761190861302c565b60209081029190910101528061191d8161318b565b9150506118c2565b509150610a249050565b5050604080516000815260208101909152919050565b6000805160206133ce83398151915261195d81611b1c565b610d12611c3e565b61196d611f04565b7f0fc26914248bb9568b0afb008dd993637f6fb6bdc9598c222c68a21e90ca53c161199781611b1c565b61199f611c3e565b61010b548311156119db5760405162461bcd60e51b81526020600482015260066024820152652aa9a918181b60d11b6044820152606401610cc3565b60006119e684612460565b60fc546040516340c10f1960e01b81526001600160a01b038681166004830152602482018490529293509116906340c10f1990604401600060405180830381600087803b158015611a3657600080fd5b505af1158015611a4a573d6000803e3d6000fd5b505050508361010b6000828254611a619190612fc3565b92505081905550836101076000828254611a7b9190613042565b909155505060408051858152602081018390526001600160a01b0385168183015290517fce3d910b07bcccb2bc98f93c5292e13a264d588f34ef3740940f872cea14a7eb9181900360600190a15050610cd6600160c955565b60335460ff1615611b1a5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610cc3565b565b610d128133612529565b600080611b31611d04565b509050806101085461010754611b479190613042565b610d329190613042565b611b5b8282611218565b610cd65760008281526097602090815260408083206001600160a01b03851684529091529020805460ff19166001179055611b933390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b611be18282611218565b15610cd65760008281526097602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6000611c48612582565b90508015610d12576000611c5b826125a4565b9050611c6681612609565b6040518281527fcb94909754d27c309adf4167150f1f7aa04de40b6a0e6bb98b2ae80a2bf438f690602001610ae8565b6000600161010154611ca89190612fc3565b9050600080611cb683612624565b915091508060001415611cc857505050565b610bef83838361265b565b6000600261010154611ce59190612fc3565b90505b60ff546101075410610d1257611cfd81612800565b9050611ce8565b60008060006101065447611d189190612fc3565b90508015611d4f576103e86101095482611d32919061314a565b611d3c91906131d2565b9150611d488282612fc3565b9250509091565b506000928392509050565b611d6261288c565b6033805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b60008060fc60009054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b158015611dfd57600080fd5b505afa158015611e11573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e3591906131e6565b905080611e4f57610d32670de0b6b3a7640000600161314a565b80670de0b6b3a7640000611e61611b26565b611e6b919061314a565b610d3291906131d2565b600054610100900460ff16611e9c5760405162461bcd60e51b8152600401610cc3906131ff565b611b1a6128d5565b600054610100900460ff16611b1a5760405162461bcd60e51b8152600401610cc3906131ff565b600054610100900460ff16611ef25760405162461bcd60e51b8152600401610cc3906131ff565b611b1a612908565b610cd68282611b51565b600260c9541415611f575760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610cc3565b600260c955565b6000610102548210158015611f7e575061010254611f7c908361324a565b155b611fb35760405162461bcd60e51b815260206004820152600660248201526555535230303360d01b6044820152606401610cc3565b611fbb611c3e565b6000611fc683612460565b60fc5460405163079cc67960e41b8152336004820152602481018390529192506001600160a01b0316906379cc679090604401600060405180830381600087803b15801561201357600080fd5b505af1158015612027573d6000803e3d6000fd5b505050508091508261010860008282546120419190612fc3565b925050819055506000610104600060016101015461205f9190612fc3565b81526020019081526020016000208054806020026020016040519081016040528092919081815260200182805480156120b757602002820191906000526020600020905b8154815260200190600101908083116120a3575b50505050509050600061010254856120cf91906131d2565b905060008167ffffffffffffffff8111156120ec576120ec6131a6565b604051908082528060200260200182016040528015612115578160200160208202803683370190505b50905060005b82811015612186578361010554815181106121385761213861302c565b60200260200101518282815181106121525761215261302c565b6020908102919091010152610105805490600061216e8361318b565b9190505550808061217e9061318b565b91505061211b565b5060fb54604051635d36598f60e01b81526001600160a01b0390911690635d36598f906121b7908490600401612f6e565b600060405180830381600087803b1580156121d157600080fd5b505af11580156121e5573d6000803e3d6000fd5b5050505060005b828110156122aa5760fb5460fd5483516001600160a01b03928316926342842e0e9230929116908690869081106122255761222561302c565b60209081029190910101516040516001600160e01b031960e086901b1681526001600160a01b0393841660048201529290911660248301526044820152606401600060405180830381600087803b15801561227f57600080fd5b505af1158015612293573d6000803e3d6000fd5b5050505080806122a29061318b565b9150506121ec565b5060fd54604051637180f85b60e01b8152336004820152602481018890526001600160a01b0390911690637180f85b90604401600060405180830381600087803b1580156122f757600080fd5b505af115801561230b573d6000803e3d6000fd5b505050507f6b921527f65949c80fab346e1e330b442e353b32e7b29f428d3d0c7766dd91523386836040516123429392919061325e565b60405180910390a150505050919050565b600160c955565b612362611ad4565b6033805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258611d8f3390565b6000806123a334612460565b60fc546040516340c10f1960e01b8152336004820152602481018390529192506001600160a01b0316906340c10f1990604401600060405180830381600087803b1580156123f057600080fd5b505af1158015612404573d6000803e3d6000fd5b5050505080915034610107600082825461241e9190613042565b909155505060408051338152602081018490527f30385c845b448a36257a6a1716e6ad2e1bc2cbe333cde1e69fe849ad6511adfe910160405180910390a15090565b60008060fc60009054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b1580156124b157600080fd5b505afa1580156124c5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124e991906131e6565b905060006124f561292f565b905061250284600161314a565b925080156125225780612515858461314a565b61251f91906131d2565b92505b5050919050565b6125338282611218565b610cd65761254081612943565b61254b836020612955565b60405160200161255c9291906132be565b60408051601f198184030181529082905262461bcd60e51b8252610cc391600401613333565b61010654600090479082906125979083612fc3565b6101069290925550919050565b6000806103e861010954846125b9919061314a565b6125c391906131d2565b90508061010b60008282546125d89190613042565b909155506125e890508184612fc3565b91508161010a60008282546125fd9190613042565b90915550919392505050565b80610107600082825461261c9190613042565b909155505050565b6000808261010054612636919061313e565b60ff54612643919061314a565b9150816101075461265491906131d2565b9050915091565b6000612667828461314a565b60fb546101035460fe54604051631c4558f560e21b81526004810188905260248101929092526001600160a01b039081166044830152606482018690529293506000929091169063711563d49084906084016020604051808303818588803b1580156126d257600080fd5b505af11580156126e6573d6000803e3d6000fd5b50505050506040513d601f19601f8201168201806040525081019061270b91906131e6565b6000868152610104602052604081209192505b8481101561275957816127318285613042565b81546001810183556000928352602090922090910155806127518161318b565b91505061271e565b5082610107600082825461276d9190612fc3565b925050819055508261010860008282546127879190613042565b925050819055508261010660008282546127a19190612fc3565b909155505060fe5460408051848152602081018890526001600160a01b039092168282015260608201869052517fc49cabe9d2bbfea8d9f51b0961c30a1081ff6fd3c4d6a9182cd65de8cea2df009181900360800190a1505050505050565b600080600061280e84612624565b9150915080600014156128265761251f600185612fc3565b60008481526101046020526040902054610100546128448284613042565b1061285b5780610100546128589190612fc3565b91505b61286685848461265b565b610100546128748284613042565b14156128835761288385612af1565b50929392505050565b60335460ff16611b1a5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610cc3565b600054610100900460ff166128fc5760405162461bcd60e51b8152600401610cc3906131ff565b6033805460ff19169055565b600054610100900460ff166123535760405162461bcd60e51b8152600401610cc3906131ff565b60006101085461010754610bc59190613042565b6060610a246001600160a01b03831660145b6060600061296483600261314a565b61296f906002613042565b67ffffffffffffffff811115612987576129876131a6565b6040519080825280601f01601f1916602001820160405280156129b1576020820181803683370190505b509050600360fc1b816000815181106129cc576129cc61302c565b60200101906001600160f81b031916908160001a905350600f60fb1b816001815181106129fb576129fb61302c565b60200101906001600160f81b031916908160001a9053506000612a1f84600261314a565b612a2a906001613042565b90505b6001811115612aa2576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110612a5e57612a5e61302c565b1a60f81b828281518110612a7457612a7461302c565b60200101906001600160f81b031916908160001a90535060049490941c93612a9b81613366565b9050612a2d565b5083156115365760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610cc3565b6000815b600161010154612b059190612fc3565b811015612c27576000818152610104602052604090206101005481541015612b2d5750612c27565b60fb546101035460405163bbe33ea560e01b81526001600160a01b039092169163bbe33ea591612b629185919060040161337d565b600060405180830381600087803b158015612b7c57600080fd5b505af1158015612b90573d6000803e3d6000fd5b5050505060006101046000846001612ba89190613042565b815260200190815260200160002090508082600081548110612bcc57612bcc61302c565b600091825260208083209091015483546001810185559383528183209093019290925584815261010490915260408120612c0591612c95565b83612c0f8161318b565b94505050508080612c1f9061318b565b915050612af5565b506000612c348284613042565b905060008161010054612c47919061313e565b60ff54612c54919061314a565b60408051868152602081018590529081018290529091507f7032ce2394fdfd8d373af7fe97df414c4002860109755d42748fd91b6a2a008290606001610bad565b5080546000825590600052602060002090810190610d1291905b80821115612cc35760008155600101612caf565b5090565b600060208284031215612cd957600080fd5b81356001600160e01b03198116811461153657600080fd5b80356001600160a01b0381168114610a7957600080fd5b600080600080600060808688031215612d2057600080fd5b612d2986612cf1565b9450612d3760208701612cf1565b935060408601359250606086013567ffffffffffffffff80821115612d5b57600080fd5b818801915088601f830112612d6f57600080fd5b813581811115612d7e57600080fd5b896020828501011115612d9057600080fd5b9699959850939650602001949392505050565b600060208284031215612db557600080fd5b5035919050565b600060208284031215612dce57600080fd5b61153682612cf1565b600080600060408486031215612dec57600080fd5b833567ffffffffffffffff80821115612e0457600080fd5b818601915086601f830112612e1857600080fd5b813581811115612e2757600080fd5b8760208260051b8501011115612e3c57600080fd5b602092830195509350612e529186019050612cf1565b90509250925092565b60008060408385031215612e6e57600080fd5b82359150612e7e60208401612cf1565b90509250929050565b60008060408385031215612e9a57600080fd5b50508035926020909101359150565b60008060008060008060008060006101208a8c031215612ec857600080fd5b612ed18a612cf1565b9850612edf60208b01612cf1565b9750612eed60408b01612cf1565b9650612efb60608b01612cf1565b9550612f0960808b01612cf1565b989b979a50959894979660a0860135965060c08601359560e0810135955061010001359350915050565b600081518084526020808501945080840160005b83811015612f6357815187529582019590820190600101612f47565b509495945050505050565b6020815260006115366020830184612f33565b600080600060608486031215612f9657600080fd5b505081359360208301359350604090920135919050565b634e487b7160e01b600052601160045260246000fd5b600082821015612fd557612fd5612fad565b500390565b6040808252810183905260006001600160fb1b03841115612ffa57600080fd5b8360051b8086606085013760009083016060019081526001600160a01b03939093166020909201919091525092915050565b634e487b7160e01b600052603260045260246000fd5b6000821982111561305557613055612fad565b500190565b600181815b8085111561309557816000190482111561307b5761307b612fad565b8085161561308857918102915b93841c939080029061305f565b509250929050565b6000826130ac57506001610a24565b816130b957506000610a24565b81600181146130cf57600281146130d9576130f5565b6001915050610a24565b60ff8411156130ea576130ea612fad565b50506001821b610a24565b5060208310610133831016604e8410600b8410161715613118575081810a610a24565b613122838361305a565b806000190482111561313657613136612fad565b029392505050565b6000611536838361309d565b600081600019048311821515161561316457613164612fad565b500290565b60006020828403121561317b57600080fd5b8151801515811461153657600080fd5b600060001982141561319f5761319f612fad565b5060010190565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b6000826131e1576131e16131bc565b500490565b6000602082840312156131f857600080fd5b5051919050565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b600082613259576132596131bc565b500690565b60018060a01b03841681528260208201526060604082015260006132856060830184612f33565b95945050505050565b60005b838110156132a9578181015183820152602001613291565b838111156132b8576000848401525b50505050565b7f416363657373436f6e74726f6c3a206163636f756e74200000000000000000008152600083516132f681601785016020880161328e565b7001034b99036b4b9b9b4b733903937b6329607d1b601791840191820152835161332781602884016020880161328e565b01602801949350505050565b602081526000825180602084015261335281604085016020870161328e565b601f01601f19169190910160400192915050565b60008161337557613375612fad565b506000190190565b6000604082016040835280855480835260608501915086600052602092508260002060005b828110156133be578154845292840192600191820191016133a2565b5050509201929092529291505056fe66098348ac86aa2c1efef4ea51eb3a0dd075bfeef7e5784ec740dc5b4ee760fda26469706673582212209fd65795c2d4a4287406b83a91bf3372d66abf0d2fdea47e0ea1bf7535fca5af64736f6c63430008090033
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.