Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
- Contract name:
- LsdNetworkFactory
- Optimization enabled
- true
- Compiler version
- v0.8.19+commit.7dd6d404
- Optimization runs
- 200
- EVM Version
- default
- Verified at
- 2024-10-17T08:32:48.140323Z
contracts/LsdNetworkFactory.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.19;
import "./LsdToken.sol";
import "./libraries/NewContractLib.sol";
import "./interfaces/ILsdToken.sol";
import "./interfaces/IFeePool.sol";
import "./interfaces/INetworkBalances.sol";
import "./interfaces/INetworkProposal.sol";
import "./interfaces/INodeDeposit.sol";
import "./interfaces/IUserDeposit.sol";
import "./interfaces/INetworkWithdraw.sol";
import "./interfaces/ILsdNetworkFactory.sol";
import "@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol";
import "@openzeppelin/contracts/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";
import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
import {SafeCast} from "@openzeppelin/contracts/utils/math/SafeCast.sol";
import "./Timelock.sol";
contract LsdNetworkFactory is Initializable, UUPSUpgradeable, ILsdNetworkFactory {
using SafeCast for *;
using EnumerableSet for EnumerableSet.AddressSet;
address public factoryAdmin;
address public ethDepositAddress;
address public feePoolLogicAddress;
address public networkBalancesLogicAddress;
address public networkProposalLogicAddress;
address public nodeDepositLogicAddress;
address public userDepositLogicAddress;
address public networkWithdrawLogicAddress;
mapping(address => NetworkContracts) public networkContractsOfLsdToken;
mapping(address => address[]) private lsdTokensOf;
mapping(address => bool) public authorizedLsdToken;
EnumerableSet.AddressSet private entrustWithVoters;
uint8 public entrustWithThreshold;
EnumerableSet.AddressSet private entrustedLsdTokens;
uint256 public totalClaimedStackFee;
bool public onlyCreationWhitelister;
EnumerableSet.AddressSet private creationWhitelister;
modifier onlyFactoryAdmin() {
if (msg.sender != factoryAdmin) {
revert CallerNotAllowed();
}
_;
}
constructor() {
_disableInitializers();
}
function init(
address _factoryAdmin,
address _ethDepositAddress,
address _feePoolLogicAddress,
address _networkBalancesLogicAddress,
address _networkProposalLogicAddress,
address _nodeDepositLogicAddress,
address _userDepositLogicAddress,
address _networkWithdrawLogicAddress
) public virtual initializer {
if (_factoryAdmin == address(0)) {
revert AddressNotAllowed();
}
factoryAdmin = _factoryAdmin;
ethDepositAddress = _ethDepositAddress;
feePoolLogicAddress = _feePoolLogicAddress;
networkBalancesLogicAddress = _networkBalancesLogicAddress;
networkProposalLogicAddress = _networkProposalLogicAddress;
nodeDepositLogicAddress = _nodeDepositLogicAddress;
userDepositLogicAddress = _userDepositLogicAddress;
networkWithdrawLogicAddress = _networkWithdrawLogicAddress;
}
function reinit() public virtual override reinitializer(1) {
_reinit();
}
function _reinit() internal virtual {}
function version() external view override returns (uint8) {
return _getInitializedVersion();
}
function _authorizeUpgrade(address newImplementation) internal override onlyFactoryAdmin {}
// Receive eth
receive() external payable {}
// ------------ getter ------------
function lsdTokensOfCreater(address _creater) public view returns (address[] memory) {
return lsdTokensOf[_creater];
}
function getCreationWhitelister() public view returns (address[] memory) {
return creationWhitelister.values();
}
// ------------ settings ------------
function transferAdmin(address _newAdmin) public onlyFactoryAdmin {
if (_newAdmin == address(0)) {
revert AddressNotAllowed();
}
factoryAdmin = _newAdmin;
}
function setNetworkBalancesLogicAddress(address _networkBalancesLogicAddress) public onlyFactoryAdmin {
networkBalancesLogicAddress = _networkBalancesLogicAddress;
}
function setNetworkProposalLogicAddress(address _networkProposalLogicAddress) public onlyFactoryAdmin {
networkProposalLogicAddress = _networkProposalLogicAddress;
}
function setNodeDepositLogicAddress(address _nodeDepositLogicAddress) public onlyFactoryAdmin {
nodeDepositLogicAddress = _nodeDepositLogicAddress;
}
function setUserDepositLogicAddress(address _userDepositLogicAddress) public onlyFactoryAdmin {
userDepositLogicAddress = _userDepositLogicAddress;
}
function setNetworkWithdrawLogicAddress(address _networkWithdrawLogicAddress) public onlyFactoryAdmin {
networkWithdrawLogicAddress = _networkWithdrawLogicAddress;
}
function addAuthorizedLsdToken(address _lsdToken) public onlyFactoryAdmin {
authorizedLsdToken[_lsdToken] = true;
}
function removeAuthorizedLsdToken(address _lsdToken) public onlyFactoryAdmin {
delete authorizedLsdToken[_lsdToken];
}
function factoryClaim(address _recipient, uint256 _amount) external onlyFactoryAdmin {
(bool success,) = _recipient.call{value: _amount}("");
if (!success) {
revert FailedToCall();
}
totalClaimedStackFee = totalClaimedStackFee + _amount;
}
function getEntrustWithVoters() public view returns (address[] memory) {
return entrustWithVoters.values();
}
function setEntrustWithVoters(address[] calldata _newVoters, uint256 _threshold) external onlyFactoryAdmin {
if (_newVoters.length < _threshold || _threshold <= _newVoters.length / 2) {
revert InvalidThreshold();
}
// Clear all
uint256 oldLen = entrustWithVoters.length();
for (uint256 i; i < oldLen; ++i) {
entrustWithVoters.remove(entrustWithVoters.at(0));
}
for (uint256 i; i < _newVoters.length; ++i) {
if (!entrustWithVoters.add(_newVoters[i])) {
revert VotersDuplicate();
}
}
entrustWithThreshold = _threshold.toUint8();
}
function getEntrustedLsdTokens() public view returns (address[] memory) {
return entrustedLsdTokens.values();
}
function addEntrustedLsdToken(address _lsdToken) external onlyFactoryAdmin returns (bool) {
return entrustedLsdTokens.add(_lsdToken);
}
function removeEntrustedLsdToken(address _lsdToken) external onlyFactoryAdmin returns (bool) {
return entrustedLsdTokens.remove(_lsdToken);
}
function setOnlyCreationWhitelister(bool _onlyCreationWhitelister) external onlyFactoryAdmin {
onlyCreationWhitelister = _onlyCreationWhitelister;
}
function addUserToCreationWhitelist(address user) external onlyFactoryAdmin returns (bool) {
return creationWhitelister.add(user);
}
function removeUserFromCreationWhitelist(address user) external onlyFactoryAdmin returns (bool) {
return creationWhitelister.remove(user);
}
// ------------ user ------------
function createLsdNetwork(
string memory _lsdTokenName,
string memory _lsdTokenSymbol,
address _networkAdmin,
address[] memory _voters,
uint256 _threshold
) external override {
address lsdToken = NewContractLib.newLsdToken(computeSalt(), _lsdTokenName, _lsdTokenSymbol);
if (address(0) == _networkAdmin) {
revert AddressNotAllowed();
}
_createLsdNetwork(lsdToken, _networkAdmin, _networkAdmin, _voters, _threshold);
}
function createLsdNetworkWithTimelock(
string memory _lsdTokenName,
string memory _lsdTokenSymbol,
address[] memory _voters,
uint256 _threshold,
uint256 _minDelay,
address[] memory _proposers
) external override {
address networkAdmin = NewContractLib.newTimelock(computeSalt(), _minDelay, _proposers, _proposers, msg.sender);
address lsdToken = NewContractLib.newLsdToken(computeSalt(), _lsdTokenName, _lsdTokenSymbol);
_createLsdNetwork(lsdToken, networkAdmin, networkAdmin, _voters, _threshold);
}
function createLsdNetworkWithEntrustedVoters(
string memory _lsdTokenName,
string memory _lsdTokenSymbol,
address _networkAdmin
) external {
if (0 == entrustWithThreshold) {
revert EmptyEntrustedVoters();
}
if (address(0) == _networkAdmin) {
revert AddressNotAllowed();
}
address lsdToken = NewContractLib.newLsdToken(computeSalt(), _lsdTokenName, _lsdTokenSymbol);
entrustedLsdTokens.add(lsdToken);
_createLsdNetwork(lsdToken, _networkAdmin, factoryAdmin, getEntrustWithVoters(), entrustWithThreshold);
}
function createLsdNetworkWithLsdToken(
address _lsdToken,
address _networkAdmin,
address[] memory _voters,
uint256 _threshold
) external override {
if (!authorizedLsdToken[_lsdToken]) {
revert NotAuthorizedLsdToken();
}
_createLsdNetwork(_lsdToken, _networkAdmin, _networkAdmin, _voters, _threshold);
}
// ------------ helper ------------
function _createLsdNetwork(address _lsdToken, address _networkAdmin, address _voterManager, address[] memory _voters, uint256 _threshold)
private
{
if (onlyCreationWhitelister && !creationWhitelister.contains(msg.sender)) {
revert CallerNotAllowed();
}
NetworkContracts memory contracts = deployNetworkContracts();
if (0 != networkContractsOfLsdToken[_lsdToken]._block) {
revert LsdTokenCanOnlyUseOnce();
}
networkContractsOfLsdToken[_lsdToken] = contracts;
lsdTokensOf[msg.sender].push(_lsdToken);
(bool success, bytes memory data) =
_lsdToken.call(abi.encodeWithSelector(ILsdToken.initMinter.selector, contracts._userDeposit));
if (!success) {
revert FailedToCall();
}
(success, data) = contracts._feePool.call(
abi.encodeWithSelector(IFeePool.init.selector, contracts._networkWithdraw, contracts._networkProposal)
);
if (!success) {
revert FailedToCall();
}
(success, data) = contracts._networkBalances.call(
abi.encodeWithSelector(INetworkBalances.init.selector, contracts._networkProposal)
);
if (!success) {
revert FailedToCall();
}
(success, data) = contracts._networkProposal.call(
abi.encodeWithSelector(INetworkProposal.init.selector, _voters, _threshold, _networkAdmin, _voterManager)
);
if (!success) {
revert FailedToCall();
}
(success, data) = contracts._nodeDeposit.call(
abi.encodeWithSelector(
INodeDeposit.init.selector,
contracts._userDeposit,
ethDepositAddress,
contracts._networkProposal,
bytes.concat(bytes1(0x01), bytes11(0), bytes20(contracts._networkWithdraw))
)
);
if (!success) {
revert FailedToCall();
}
(success, data) = contracts._userDeposit.call(
abi.encodeWithSelector(
IUserDeposit.init.selector,
_lsdToken,
contracts._nodeDeposit,
contracts._networkWithdraw,
contracts._networkProposal,
contracts._networkBalances
)
);
if (!success) {
revert FailedToCall();
}
(success, data) = contracts._networkWithdraw.call(
abi.encodeWithSelector(
INetworkWithdraw.init.selector,
_lsdToken,
contracts._userDeposit,
contracts._networkProposal,
contracts._networkBalances,
contracts._feePool,
address(this)
)
);
if (!success) {
revert FailedToCall();
}
emit LsdNetwork(contracts);
}
function deploy(address _logicAddress) private returns (address) {
return NewContractLib.newERC1967Proxy(computeSalt(), _logicAddress);
}
function deployNetworkContracts() private returns (NetworkContracts memory) {
address feePool = deploy(feePoolLogicAddress);
address networkBalances = deploy(networkBalancesLogicAddress);
address networkProposal = deploy(networkProposalLogicAddress);
address nodeDeposit = deploy(nodeDepositLogicAddress);
address userDeposit = deploy(userDepositLogicAddress);
address networkWithdraw = deploy(networkWithdrawLogicAddress);
return NetworkContracts(
feePool, networkBalances, networkProposal, nodeDeposit, userDeposit, networkWithdraw, block.number
);
}
function computeSalt() internal view returns (bytes32) {
return keccak256(abi.encodePacked(msg.sender, block.number));
}
}
@openzeppelin/contracts/utils/math/Math.sol
// SPDX-License-Identifier: MIT
// 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 Math {
enum Rounding {
Down, // Toward negative infinity
Up, // Toward infinity
Zero // Toward zero
}
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two numbers. The result is rounded towards
* zero.
*/
function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow.
return (a & b) + (a ^ b) / 2;
}
/**
* @dev Returns the ceiling of the division of two numbers.
*
* This differs from standard division with `/` in that it rounds up instead
* of rounding down.
*/
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b - 1) / b can overflow on addition, so we distribute.
return a == 0 ? 0 : (a - 1) / b + 1;
}
/**
* @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
* @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
* with further edits by Uniswap Labs also under MIT license.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
unchecked {
// 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
// use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
// variables such that product = prod1 * 2^256 + prod0.
uint256 prod0; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(x, y, not(0))
prod0 := mul(x, y)
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division.
if (prod1 == 0) {
// 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);
}
}
}
@openzeppelin/contracts/utils/introspection/IERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
@openzeppelin/contracts/utils/Strings.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol)
pragma solidity ^0.8.0;
import "./math/Math.sol";
import "./math/SignedMath.sol";
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _SYMBOLS = "0123456789abcdef";
uint8 private constant _ADDRESS_LENGTH = 20;
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
unchecked {
uint256 length = Math.log10(value) + 1;
string memory buffer = new string(length);
uint256 ptr;
/// @solidity memory-safe-assembly
assembly {
ptr := add(buffer, add(32, length))
}
while (true) {
ptr--;
/// @solidity memory-safe-assembly
assembly {
mstore8(ptr, byte(mod(value, 10), _SYMBOLS))
}
value /= 10;
if (value == 0) break;
}
return buffer;
}
}
/**
* @dev Converts a `int256` to its ASCII `string` decimal representation.
*/
function toString(int256 value) internal pure returns (string memory) {
return string(abi.encodePacked(value < 0 ? "-" : "", toString(SignedMath.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, Math.log256(value) + 1);
}
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
/**
* @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
*/
function toHexString(address addr) internal pure returns (string memory) {
return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
}
/**
* @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));
}
}
@openzeppelin/contracts/utils/Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
@openzeppelin/contracts/proxy/Proxy.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)
pragma solidity ^0.8.0;
/**
* @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM
* instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to
* be specified by overriding the virtual {_implementation} function.
*
* Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a
* different contract through the {_delegate} function.
*
* The success and return data of the delegated call will be returned back to the caller of the proxy.
*/
abstract contract Proxy {
/**
* @dev Delegates the current call to `implementation`.
*
* This function does not return to its internal call site, it will return directly to the external caller.
*/
function _delegate(address implementation) internal virtual {
assembly {
// Copy msg.data. We take full control of memory in this inline assembly
// block because it will not return to Solidity code. We overwrite the
// Solidity scratch pad at memory position 0.
calldatacopy(0, 0, calldatasize())
// Call the implementation.
// out and outsize are 0 because we don't know the size yet.
let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)
// Copy the returned data.
returndatacopy(0, 0, returndatasize())
switch result
// delegatecall returns 0 on error.
case 0 {
revert(0, returndatasize())
}
default {
return(0, returndatasize())
}
}
}
/**
* @dev This is a virtual function that should be overridden so it returns the address to which the fallback function
* and {_fallback} should delegate.
*/
function _implementation() internal view virtual returns (address);
/**
* @dev Delegates the current call to the address returned by `_implementation()`.
*
* This function does not return to its internal call site, it will return directly to the external caller.
*/
function _fallback() internal virtual {
_beforeFallback();
_delegate(_implementation());
}
/**
* @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other
* function in the contract matches the call data.
*/
fallback() external payable virtual {
_fallback();
}
/**
* @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data
* is empty.
*/
receive() external payable virtual {
_fallback();
}
/**
* @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`
* call, or as part of the Solidity `fallback` or `receive` functions.
*
* If overridden should call `super._beforeFallback()`.
*/
function _beforeFallback() internal virtual {}
}
contracts/interfaces/IFeePool.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.19;
import "./Errors.sol";
import "./IUpgrade.sol";
interface IFeePool is Errors, IUpgrade {
event EtherWithdrawn(uint256 amount, uint256 time);
function init(address _networkWithdrawAddress, address _networkProposalAddress) external;
function withdrawEther(uint256 _amount) external;
}
@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/extensions/ERC20Burnable.sol)
pragma solidity ^0.8.0;
import "../ERC20.sol";
import "../../../utils/Context.sol";
/**
* @dev Extension of {ERC20} that allows token holders to destroy both their own
* tokens and those that they have an allowance for, in a way that can be
* recognized off-chain (via event analysis).
*/
abstract contract ERC20Burnable is Context, ERC20 {
/**
* @dev Destroys `amount` tokens from the caller.
*
* See {ERC20-_burn}.
*/
function burn(uint256 amount) public virtual {
_burn(_msgSender(), amount);
}
/**
* @dev Destroys `amount` tokens from `account`, deducting from the caller's
* allowance.
*
* See {ERC20-_burn} and {ERC20-allowance}.
*
* Requirements:
*
* - the caller must have allowance for ``accounts``'s tokens of at least
* `amount`.
*/
function burnFrom(address account, uint256 amount) public virtual {
_spendAllowance(account, _msgSender(), amount);
_burn(account, amount);
}
}
@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (proxy/ERC1967/ERC1967Proxy.sol)
pragma solidity ^0.8.0;
import "../Proxy.sol";
import "./ERC1967Upgrade.sol";
/**
* @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an
* implementation address that can be changed. This address is stored in storage in the location specified by
* https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the
* implementation behind the proxy.
*/
contract ERC1967Proxy is Proxy, ERC1967Upgrade {
/**
* @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.
*
* If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded
* function call, and allows initializing the storage of the proxy like a Solidity constructor.
*/
constructor(address _logic, bytes memory _data) payable {
_upgradeToAndCall(_logic, _data, false);
}
/**
* @dev Returns the current implementation address.
*/
function _implementation() internal view virtual override returns (address impl) {
return ERC1967Upgrade._getImplementation();
}
}
@openzeppelin/contracts/access/AccessControl.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/AccessControl.sol)
pragma solidity ^0.8.0;
import "./IAccessControl.sol";
import "../utils/Context.sol";
import "../utils/Strings.sol";
import "../utils/introspection/ERC165.sol";
/**
* @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 AccessControl is Context, IAccessControl, ERC165 {
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(IAccessControl).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 ",
Strings.toHexString(account),
" is missing role ",
Strings.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());
}
}
}
@openzeppelin/contracts/interfaces/IERC1967.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC1967.sol)
pragma solidity ^0.8.0;
/**
* @dev ERC-1967: Proxy Storage Slots. This interface contains the events defined in the ERC.
*
* _Available since v4.8.3._
*/
interface IERC1967 {
/**
* @dev Emitted when the implementation is upgraded.
*/
event Upgraded(address indexed implementation);
/**
* @dev Emitted when the admin account has changed.
*/
event AdminChanged(address previousAdmin, address newAdmin);
/**
* @dev Emitted when the beacon is changed.
*/
event BeaconUpgraded(address indexed beacon);
}
contracts/Timelock.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.19;
import "@openzeppelin/contracts/governance/TimelockController.sol";
contract Timelock is TimelockController {
error MinDelayTooLarge();
constructor(uint256 minDelay, address[] memory proposers, address[] memory executors, address admin)
TimelockController(minDelay, proposers, executors, admin)
{
if (minDelay > 86400 * 30) {
revert MinDelayTooLarge();
}
}
}
@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/UUPSUpgradeable.sol)
pragma solidity ^0.8.0;
import "../../interfaces/draft-IERC1822.sol";
import "../ERC1967/ERC1967Upgrade.sol";
/**
* @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an
* {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy.
*
* A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is
* reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing
* `UUPSUpgradeable` with a custom implementation of upgrades.
*
* The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism.
*
* _Available since v4.1._
*/
abstract contract UUPSUpgradeable is IERC1822Proxiable, ERC1967Upgrade {
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment
address private immutable __self = address(this);
/**
* @dev Check that the execution is being performed through a delegatecall call and that the execution context is
* a proxy contract with an implementation (as defined in ERC1967) pointing to self. This should only be the case
* for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a
* function through ERC1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to
* fail.
*/
modifier onlyProxy() {
require(address(this) != __self, "Function must be called through delegatecall");
require(_getImplementation() == __self, "Function must be called through active proxy");
_;
}
/**
* @dev Check that the execution is not being performed through a delegate call. This allows a function to be
* callable on the implementing contract but not through proxies.
*/
modifier notDelegated() {
require(address(this) == __self, "UUPSUpgradeable: must not be called through delegatecall");
_;
}
/**
* @dev Implementation of the ERC1822 {proxiableUUID} function. This returns the storage slot used by the
* implementation. It is used to validate the implementation's compatibility when performing an upgrade.
*
* IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
* bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
* function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier.
*/
function proxiableUUID() external view virtual override notDelegated returns (bytes32) {
return _IMPLEMENTATION_SLOT;
}
/**
* @dev Upgrade the implementation of the proxy to `newImplementation`.
*
* Calls {_authorizeUpgrade}.
*
* Emits an {Upgraded} event.
*
* @custom:oz-upgrades-unsafe-allow-reachable delegatecall
*/
function upgradeTo(address newImplementation) public virtual onlyProxy {
_authorizeUpgrade(newImplementation);
_upgradeToAndCallUUPS(newImplementation, new bytes(0), false);
}
/**
* @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call
* encoded in `data`.
*
* Calls {_authorizeUpgrade}.
*
* Emits an {Upgraded} event.
*
* @custom:oz-upgrades-unsafe-allow-reachable delegatecall
*/
function upgradeToAndCall(address newImplementation, bytes memory data) public payable virtual onlyProxy {
_authorizeUpgrade(newImplementation);
_upgradeToAndCallUUPS(newImplementation, data, true);
}
/**
* @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by
* {upgradeTo} and {upgradeToAndCall}.
*
* Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.
*
* ```solidity
* function _authorizeUpgrade(address) internal override onlyOwner {}
* ```
*/
function _authorizeUpgrade(address newImplementation) internal virtual;
}
contracts/interfaces/IUserDeposit.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.19;
import "./IRateProvider.sol";
import "./Errors.sol";
import "./IUpgrade.sol";
interface IUserDeposit is IRateProvider, Errors, IUpgrade {
event DepositReceived(address indexed from, uint256 amount, uint256 time);
event DepositRecycled(address indexed from, uint256 amount, uint256 time);
event ExcessWithdrawn(address indexed to, uint256 amount, uint256 time);
function init(
address _lsdTokenAddress,
address _nodeDepositAddress,
address _networkWithdrawAddress,
address _networkProposalAddress,
address _networkBalancesAddress
) external;
function deposit() external payable;
function getBalance() external view returns (uint256);
function withdrawExcessBalance(uint256 _amount) external;
function recycleNetworkWithdrawDeposit() external payable;
}
@openzeppelin/contracts/proxy/utils/Initializable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol)
pragma solidity ^0.8.2;
import "../../utils/Address.sol";
/**
* @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
* behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
* external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
* function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
*
* The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
* reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
* case an upgrade adds a module that needs to be initialized.
*
* For example:
*
* [.hljs-theme-light.nopadding]
* ```solidity
* contract MyToken is ERC20Upgradeable {
* function initialize() initializer public {
* __ERC20_init("MyToken", "MTK");
* }
* }
*
* contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
* function initializeV2() reinitializer(2) public {
* __ERC20Permit_init("MyToken");
* }
* }
* ```
*
* TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
* possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
*
* CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
* that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
*
* [CAUTION]
* ====
* Avoid leaving a contract uninitialized.
*
* An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
* contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
* the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
*
* [.hljs-theme-light.nopadding]
* ```
* /// @custom:oz-upgrades-unsafe-allow constructor
* constructor() {
* _disableInitializers();
* }
* ```
* ====
*/
abstract contract Initializable {
/**
* @dev Indicates that the contract has been initialized.
* @custom:oz-retyped-from bool
*/
uint8 private _initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool private _initializing;
/**
* @dev Triggered when the contract has been initialized or reinitialized.
*/
event Initialized(uint8 version);
/**
* @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
* `onlyInitializing` functions can be used to initialize parent contracts.
*
* Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a
* constructor.
*
* Emits an {Initialized} event.
*/
modifier initializer() {
bool isTopLevelCall = !_initializing;
require(
(isTopLevelCall && _initialized < 1) || (!Address.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;
}
}
contracts/interfaces/IUpgrade.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.19;
interface IUpgrade {
function reinit() external;
function version() external returns (uint8);
}
contracts/libraries/NewContractLib.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.19;
import "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";
import "../Timelock.sol";
import "../LsdToken.sol";
library NewContractLib {
function newTimelock(
bytes32 salt, uint256 minDelay, address[] memory proposers, address[] memory executors, address admin
) public returns (address) {
return address(new Timelock{salt: salt}(minDelay, proposers, executors, admin));
}
function newERC1967Proxy(bytes32 salt, address _logicAddress) public returns (address) {
return address(new ERC1967Proxy{salt: salt}(_logicAddress, ""));
}
function newLsdToken(
bytes32 salt,
string memory _lsdTokenName,
string memory _lsdTokenSymbol
) public returns (address) {
return address(new LsdToken{salt: salt}(_lsdTokenName, _lsdTokenSymbol));
}
}
contracts/interfaces/IDepositEth.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.19;
interface IDepositEth {
function depositEth() external payable;
}
@openzeppelin/contracts/interfaces/draft-IERC1822.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)
pragma solidity ^0.8.0;
/**
* @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified
* proxy whose upgrades are fully controlled by the current implementation.
*/
interface IERC1822Proxiable {
/**
* @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation
* address.
*
* IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
* bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
* function revert if invoked through a proxy.
*/
function proxiableUUID() external view returns (bytes32);
}
@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)
pragma solidity ^0.8.0;
/**
* @title ERC721 token receiver interface
* @dev Interface for any contract that wants to support safeTransfers
* from ERC721 asset contracts.
*/
interface IERC721Receiver {
/**
* @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
* by `operator` from `from`, this function is called.
*
* It must return its Solidity selector to confirm the token transfer.
* If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
*
* The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.
*/
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}
@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (proxy/ERC1967/ERC1967Upgrade.sol)
pragma solidity ^0.8.2;
import "../beacon/IBeacon.sol";
import "../../interfaces/IERC1967.sol";
import "../../interfaces/draft-IERC1822.sol";
import "../../utils/Address.sol";
import "../../utils/StorageSlot.sol";
/**
* @dev This abstract contract provides getters and event emitting update functions for
* https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.
*
* _Available since v4.1._
*/
abstract contract ERC1967Upgrade is IERC1967 {
// This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1
bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;
/**
* @dev Storage slot with the address of the current implementation.
* This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is
* validated in the constructor.
*/
bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
/**
* @dev Returns the current implementation address.
*/
function _getImplementation() internal view returns (address) {
return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
}
/**
* @dev Stores a new address in the EIP1967 implementation slot.
*/
function _setImplementation(address newImplementation) private {
require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
}
/**
* @dev Perform implementation upgrade
*
* Emits an {Upgraded} event.
*/
function _upgradeTo(address newImplementation) internal {
_setImplementation(newImplementation);
emit Upgraded(newImplementation);
}
/**
* @dev Perform implementation upgrade with additional setup call.
*
* Emits an {Upgraded} event.
*/
function _upgradeToAndCall(address newImplementation, bytes memory data, bool forceCall) internal {
_upgradeTo(newImplementation);
if (data.length > 0 || forceCall) {
Address.functionDelegateCall(newImplementation, data);
}
}
/**
* @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.
*
* Emits an {Upgraded} event.
*/
function _upgradeToAndCallUUPS(address newImplementation, bytes memory data, bool forceCall) internal {
// Upgrades from old implementations will perform a rollback test. This test requires the new
// implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing
// this special case will break upgrade paths from old UUPS implementation to new ones.
if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {
_setImplementation(newImplementation);
} else {
try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {
require(slot == _IMPLEMENTATION_SLOT, "ERC1967Upgrade: unsupported proxiableUUID");
} catch {
revert("ERC1967Upgrade: new implementation is not UUPS");
}
_upgradeToAndCall(newImplementation, data, forceCall);
}
}
/**
* @dev Storage slot with the admin of the contract.
* This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is
* validated in the constructor.
*/
bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
/**
* @dev Returns the current admin.
*/
function _getAdmin() internal view returns (address) {
return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;
}
/**
* @dev Stores a new address in the EIP1967 admin slot.
*/
function _setAdmin(address newAdmin) private {
require(newAdmin != address(0), "ERC1967: new admin is the zero address");
StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;
}
/**
* @dev Changes the admin of the proxy.
*
* Emits an {AdminChanged} event.
*/
function _changeAdmin(address newAdmin) internal {
emit AdminChanged(_getAdmin(), newAdmin);
_setAdmin(newAdmin);
}
/**
* @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
* This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.
*/
bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;
/**
* @dev Returns the current beacon.
*/
function _getBeacon() internal view returns (address) {
return StorageSlot.getAddressSlot(_BEACON_SLOT).value;
}
/**
* @dev Stores a new beacon in the EIP1967 beacon slot.
*/
function _setBeacon(address newBeacon) private {
require(Address.isContract(newBeacon), "ERC1967: new beacon is not a contract");
require(
Address.isContract(IBeacon(newBeacon).implementation()),
"ERC1967: beacon implementation is not a contract"
);
StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;
}
/**
* @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does
* not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).
*
* Emits a {BeaconUpgraded} event.
*/
function _upgradeBeaconToAndCall(address newBeacon, bytes memory data, bool forceCall) internal {
_setBeacon(newBeacon);
emit BeaconUpgraded(newBeacon);
if (data.length > 0 || forceCall) {
Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);
}
}
}
@openzeppelin/contracts/utils/StorageSlot.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/StorageSlot.sol)
// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.
pragma solidity ^0.8.0;
/**
* @dev Library for reading and writing primitive types to specific storage slots.
*
* Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
* This library helps with reading and writing to such slots without the need for inline assembly.
*
* The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
*
* Example usage to set ERC1967 implementation slot:
* ```solidity
* contract ERC1967 {
* bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
*
* function _getImplementation() internal view returns (address) {
* return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
* }
*
* function _setImplementation(address newImplementation) internal {
* require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
* StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
* }
* }
* ```
*
* _Available since v4.1 for `address`, `bool`, `bytes32`, `uint256`._
* _Available since v4.9 for `string`, `bytes`._
*/
library StorageSlot {
struct AddressSlot {
address value;
}
struct BooleanSlot {
bool value;
}
struct Bytes32Slot {
bytes32 value;
}
struct Uint256Slot {
uint256 value;
}
struct StringSlot {
string value;
}
struct BytesSlot {
bytes value;
}
/**
* @dev Returns an `AddressSlot` with member `value` located at `slot`.
*/
function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `BooleanSlot` with member `value` located at `slot`.
*/
function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `Bytes32Slot` with member `value` located at `slot`.
*/
function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `Uint256Slot` with member `value` located at `slot`.
*/
function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `StringSlot` with member `value` located at `slot`.
*/
function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `StringSlot` representation of the string storage pointer `store`.
*/
function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := store.slot
}
}
/**
* @dev Returns an `BytesSlot` with member `value` located at `slot`.
*/
function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.
*/
function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := store.slot
}
}
}
contracts/LsdToken.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.19;
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol";
import "./interfaces/ILsdToken.sol";
import "./interfaces/IRateProvider.sol";
contract LsdToken is ILsdToken, ERC20Burnable {
address public minter;
event MinterChanged(address oldMinter, address newMinter);
modifier onlyMinter() {
if (msg.sender != minter) {
revert CallerNotAllowed();
}
_;
}
constructor(string memory _name, string memory _symbol) ERC20(_name, _symbol) {}
function getRate() external view override returns (uint256) {
return IRateProvider(minter).getRate();
}
function initMinter(address _minter) external override {
if (minter != address(0)) {
revert AlreadyInitialized();
}
minter = _minter;
}
// Mint lsdToken
// Only accepts calls from minter
function mint(address _to, uint256 _lsdTokenAmount) external override onlyMinter {
// Check lsdToken amount
if (_lsdTokenAmount == 0) {
revert AmountZero();
}
// Update balance & supply
_mint(_to, _lsdTokenAmount);
}
function updateMinter(address _newMinter) external override onlyMinter {
if (_newMinter == address(0)) revert AddressNotAllowed();
emit MinterChanged(minter, _newMinter);
minter = _newMinter;
}
}
@openzeppelin/contracts/utils/math/SafeCast.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SafeCast.sol)
// This file was procedurally generated from scripts/generate/templates/SafeCast.js.
pragma solidity ^0.8.0;
/**
* @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow
* checks.
*
* Downcasting from uint256/int256 in Solidity does not revert on overflow. This can
* easily result in undesired exploitation or bugs, since developers usually
* assume that overflows raise errors. `SafeCast` restores this intuition by
* reverting the transaction when such an operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*
* Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing
* all math on `uint256` and `int256` and then downcasting.
*/
library SafeCast {
/**
* @dev Returns the downcasted uint248 from uint256, reverting on
* overflow (when the input is greater than largest uint248).
*
* Counterpart to Solidity's `uint248` operator.
*
* Requirements:
*
* - input must fit into 248 bits
*
* _Available since v4.7._
*/
function toUint248(uint256 value) internal pure returns (uint248) {
require(value <= type(uint248).max, "SafeCast: value doesn't fit in 248 bits");
return uint248(value);
}
/**
* @dev Returns the downcasted uint240 from uint256, reverting on
* overflow (when the input is greater than largest uint240).
*
* Counterpart to Solidity's `uint240` operator.
*
* Requirements:
*
* - input must fit into 240 bits
*
* _Available since v4.7._
*/
function toUint240(uint256 value) internal pure returns (uint240) {
require(value <= type(uint240).max, "SafeCast: value doesn't fit in 240 bits");
return uint240(value);
}
/**
* @dev Returns the downcasted uint232 from uint256, reverting on
* overflow (when the input is greater than largest uint232).
*
* Counterpart to Solidity's `uint232` operator.
*
* Requirements:
*
* - input must fit into 232 bits
*
* _Available since v4.7._
*/
function toUint232(uint256 value) internal pure returns (uint232) {
require(value <= type(uint232).max, "SafeCast: value doesn't fit in 232 bits");
return uint232(value);
}
/**
* @dev Returns the downcasted uint224 from uint256, reverting on
* overflow (when the input is greater than largest uint224).
*
* Counterpart to Solidity's `uint224` operator.
*
* Requirements:
*
* - input must fit into 224 bits
*
* _Available since v4.2._
*/
function toUint224(uint256 value) internal pure returns (uint224) {
require(value <= type(uint224).max, "SafeCast: value doesn't fit in 224 bits");
return uint224(value);
}
/**
* @dev Returns the downcasted uint216 from uint256, reverting on
* overflow (when the input is greater than largest uint216).
*
* Counterpart to Solidity's `uint216` operator.
*
* Requirements:
*
* - input must fit into 216 bits
*
* _Available since v4.7._
*/
function toUint216(uint256 value) internal pure returns (uint216) {
require(value <= type(uint216).max, "SafeCast: value doesn't fit in 216 bits");
return uint216(value);
}
/**
* @dev Returns the downcasted uint208 from uint256, reverting on
* overflow (when the input is greater than largest uint208).
*
* Counterpart to Solidity's `uint208` operator.
*
* Requirements:
*
* - input must fit into 208 bits
*
* _Available since v4.7._
*/
function toUint208(uint256 value) internal pure returns (uint208) {
require(value <= type(uint208).max, "SafeCast: value doesn't fit in 208 bits");
return uint208(value);
}
/**
* @dev Returns the downcasted uint200 from uint256, reverting on
* overflow (when the input is greater than largest uint200).
*
* Counterpart to Solidity's `uint200` operator.
*
* Requirements:
*
* - input must fit into 200 bits
*
* _Available since v4.7._
*/
function toUint200(uint256 value) internal pure returns (uint200) {
require(value <= type(uint200).max, "SafeCast: value doesn't fit in 200 bits");
return uint200(value);
}
/**
* @dev Returns the downcasted uint192 from uint256, reverting on
* overflow (when the input is greater than largest uint192).
*
* Counterpart to Solidity's `uint192` operator.
*
* Requirements:
*
* - input must fit into 192 bits
*
* _Available since v4.7._
*/
function toUint192(uint256 value) internal pure returns (uint192) {
require(value <= type(uint192).max, "SafeCast: value doesn't fit in 192 bits");
return uint192(value);
}
/**
* @dev Returns the downcasted uint184 from uint256, reverting on
* overflow (when the input is greater than largest uint184).
*
* Counterpart to Solidity's `uint184` operator.
*
* Requirements:
*
* - input must fit into 184 bits
*
* _Available since v4.7._
*/
function toUint184(uint256 value) internal pure returns (uint184) {
require(value <= type(uint184).max, "SafeCast: value doesn't fit in 184 bits");
return uint184(value);
}
/**
* @dev Returns the downcasted uint176 from uint256, reverting on
* overflow (when the input is greater than largest uint176).
*
* Counterpart to Solidity's `uint176` operator.
*
* Requirements:
*
* - input must fit into 176 bits
*
* _Available since v4.7._
*/
function toUint176(uint256 value) internal pure returns (uint176) {
require(value <= type(uint176).max, "SafeCast: value doesn't fit in 176 bits");
return uint176(value);
}
/**
* @dev Returns the downcasted uint168 from uint256, reverting on
* overflow (when the input is greater than largest uint168).
*
* Counterpart to Solidity's `uint168` operator.
*
* Requirements:
*
* - input must fit into 168 bits
*
* _Available since v4.7._
*/
function toUint168(uint256 value) internal pure returns (uint168) {
require(value <= type(uint168).max, "SafeCast: value doesn't fit in 168 bits");
return uint168(value);
}
/**
* @dev Returns the downcasted uint160 from uint256, reverting on
* overflow (when the input is greater than largest uint160).
*
* Counterpart to Solidity's `uint160` operator.
*
* Requirements:
*
* - input must fit into 160 bits
*
* _Available since v4.7._
*/
function toUint160(uint256 value) internal pure returns (uint160) {
require(value <= type(uint160).max, "SafeCast: value doesn't fit in 160 bits");
return uint160(value);
}
/**
* @dev Returns the downcasted uint152 from uint256, reverting on
* overflow (when the input is greater than largest uint152).
*
* Counterpart to Solidity's `uint152` operator.
*
* Requirements:
*
* - input must fit into 152 bits
*
* _Available since v4.7._
*/
function toUint152(uint256 value) internal pure returns (uint152) {
require(value <= type(uint152).max, "SafeCast: value doesn't fit in 152 bits");
return uint152(value);
}
/**
* @dev Returns the downcasted uint144 from uint256, reverting on
* overflow (when the input is greater than largest uint144).
*
* Counterpart to Solidity's `uint144` operator.
*
* Requirements:
*
* - input must fit into 144 bits
*
* _Available since v4.7._
*/
function toUint144(uint256 value) internal pure returns (uint144) {
require(value <= type(uint144).max, "SafeCast: value doesn't fit in 144 bits");
return uint144(value);
}
/**
* @dev Returns the downcasted uint136 from uint256, reverting on
* overflow (when the input is greater than largest uint136).
*
* Counterpart to Solidity's `uint136` operator.
*
* Requirements:
*
* - input must fit into 136 bits
*
* _Available since v4.7._
*/
function toUint136(uint256 value) internal pure returns (uint136) {
require(value <= type(uint136).max, "SafeCast: value doesn't fit in 136 bits");
return uint136(value);
}
/**
* @dev Returns the downcasted uint128 from uint256, reverting on
* overflow (when the input is greater than largest uint128).
*
* Counterpart to Solidity's `uint128` operator.
*
* Requirements:
*
* - input must fit into 128 bits
*
* _Available since v2.5._
*/
function toUint128(uint256 value) internal pure returns (uint128) {
require(value <= type(uint128).max, "SafeCast: value doesn't fit in 128 bits");
return uint128(value);
}
/**
* @dev Returns the downcasted uint120 from uint256, reverting on
* overflow (when the input is greater than largest uint120).
*
* Counterpart to Solidity's `uint120` operator.
*
* Requirements:
*
* - input must fit into 120 bits
*
* _Available since v4.7._
*/
function toUint120(uint256 value) internal pure returns (uint120) {
require(value <= type(uint120).max, "SafeCast: value doesn't fit in 120 bits");
return uint120(value);
}
/**
* @dev Returns the downcasted uint112 from uint256, reverting on
* overflow (when the input is greater than largest uint112).
*
* Counterpart to Solidity's `uint112` operator.
*
* Requirements:
*
* - input must fit into 112 bits
*
* _Available since v4.7._
*/
function toUint112(uint256 value) internal pure returns (uint112) {
require(value <= type(uint112).max, "SafeCast: value doesn't fit in 112 bits");
return uint112(value);
}
/**
* @dev Returns the downcasted uint104 from uint256, reverting on
* overflow (when the input is greater than largest uint104).
*
* Counterpart to Solidity's `uint104` operator.
*
* Requirements:
*
* - input must fit into 104 bits
*
* _Available since v4.7._
*/
function toUint104(uint256 value) internal pure returns (uint104) {
require(value <= type(uint104).max, "SafeCast: value doesn't fit in 104 bits");
return uint104(value);
}
/**
* @dev Returns the downcasted uint96 from uint256, reverting on
* overflow (when the input is greater than largest uint96).
*
* Counterpart to Solidity's `uint96` operator.
*
* Requirements:
*
* - input must fit into 96 bits
*
* _Available since v4.2._
*/
function toUint96(uint256 value) internal pure returns (uint96) {
require(value <= type(uint96).max, "SafeCast: value doesn't fit in 96 bits");
return uint96(value);
}
/**
* @dev Returns the downcasted uint88 from uint256, reverting on
* overflow (when the input is greater than largest uint88).
*
* Counterpart to Solidity's `uint88` operator.
*
* Requirements:
*
* - input must fit into 88 bits
*
* _Available since v4.7._
*/
function toUint88(uint256 value) internal pure returns (uint88) {
require(value <= type(uint88).max, "SafeCast: value doesn't fit in 88 bits");
return uint88(value);
}
/**
* @dev Returns the downcasted uint80 from uint256, reverting on
* overflow (when the input is greater than largest uint80).
*
* Counterpart to Solidity's `uint80` operator.
*
* Requirements:
*
* - input must fit into 80 bits
*
* _Available since v4.7._
*/
function toUint80(uint256 value) internal pure returns (uint80) {
require(value <= type(uint80).max, "SafeCast: value doesn't fit in 80 bits");
return uint80(value);
}
/**
* @dev Returns the downcasted uint72 from uint256, reverting on
* overflow (when the input is greater than largest uint72).
*
* Counterpart to Solidity's `uint72` operator.
*
* Requirements:
*
* - input must fit into 72 bits
*
* _Available since v4.7._
*/
function toUint72(uint256 value) internal pure returns (uint72) {
require(value <= type(uint72).max, "SafeCast: value doesn't fit in 72 bits");
return uint72(value);
}
/**
* @dev Returns the downcasted uint64 from uint256, reverting on
* overflow (when the input is greater than largest uint64).
*
* Counterpart to Solidity's `uint64` operator.
*
* Requirements:
*
* - input must fit into 64 bits
*
* _Available since v2.5._
*/
function toUint64(uint256 value) internal pure returns (uint64) {
require(value <= type(uint64).max, "SafeCast: value doesn't fit in 64 bits");
return uint64(value);
}
/**
* @dev Returns the downcasted uint56 from uint256, reverting on
* overflow (when the input is greater than largest uint56).
*
* Counterpart to Solidity's `uint56` operator.
*
* Requirements:
*
* - input must fit into 56 bits
*
* _Available since v4.7._
*/
function toUint56(uint256 value) internal pure returns (uint56) {
require(value <= type(uint56).max, "SafeCast: value doesn't fit in 56 bits");
return uint56(value);
}
/**
* @dev Returns the downcasted uint48 from uint256, reverting on
* overflow (when the input is greater than largest uint48).
*
* Counterpart to Solidity's `uint48` operator.
*
* Requirements:
*
* - input must fit into 48 bits
*
* _Available since v4.7._
*/
function toUint48(uint256 value) internal pure returns (uint48) {
require(value <= type(uint48).max, "SafeCast: value doesn't fit in 48 bits");
return uint48(value);
}
/**
* @dev Returns the downcasted uint40 from uint256, reverting on
* overflow (when the input is greater than largest uint40).
*
* Counterpart to Solidity's `uint40` operator.
*
* Requirements:
*
* - input must fit into 40 bits
*
* _Available since v4.7._
*/
function toUint40(uint256 value) internal pure returns (uint40) {
require(value <= type(uint40).max, "SafeCast: value doesn't fit in 40 bits");
return uint40(value);
}
/**
* @dev Returns the downcasted uint32 from uint256, reverting on
* overflow (when the input is greater than largest uint32).
*
* Counterpart to Solidity's `uint32` operator.
*
* Requirements:
*
* - input must fit into 32 bits
*
* _Available since v2.5._
*/
function toUint32(uint256 value) internal pure returns (uint32) {
require(value <= type(uint32).max, "SafeCast: value doesn't fit in 32 bits");
return uint32(value);
}
/**
* @dev Returns the downcasted uint24 from uint256, reverting on
* overflow (when the input is greater than largest uint24).
*
* Counterpart to Solidity's `uint24` operator.
*
* Requirements:
*
* - input must fit into 24 bits
*
* _Available since v4.7._
*/
function toUint24(uint256 value) internal pure returns (uint24) {
require(value <= type(uint24).max, "SafeCast: value doesn't fit in 24 bits");
return uint24(value);
}
/**
* @dev Returns the downcasted uint16 from uint256, reverting on
* overflow (when the input is greater than largest uint16).
*
* Counterpart to Solidity's `uint16` operator.
*
* Requirements:
*
* - input must fit into 16 bits
*
* _Available since v2.5._
*/
function toUint16(uint256 value) internal pure returns (uint16) {
require(value <= type(uint16).max, "SafeCast: value doesn't fit in 16 bits");
return uint16(value);
}
/**
* @dev Returns the downcasted uint8 from uint256, reverting on
* overflow (when the input is greater than largest uint8).
*
* Counterpart to Solidity's `uint8` operator.
*
* Requirements:
*
* - input must fit into 8 bits
*
* _Available since v2.5._
*/
function toUint8(uint256 value) internal pure returns (uint8) {
require(value <= type(uint8).max, "SafeCast: value doesn't fit in 8 bits");
return uint8(value);
}
/**
* @dev Converts a signed int256 into an unsigned uint256.
*
* Requirements:
*
* - input must be greater than or equal to 0.
*
* _Available since v3.0._
*/
function toUint256(int256 value) internal pure returns (uint256) {
require(value >= 0, "SafeCast: value must be positive");
return uint256(value);
}
/**
* @dev Returns the downcasted int248 from int256, reverting on
* overflow (when the input is less than smallest int248 or
* greater than largest int248).
*
* Counterpart to Solidity's `int248` operator.
*
* Requirements:
*
* - input must fit into 248 bits
*
* _Available since v4.7._
*/
function toInt248(int256 value) internal pure returns (int248 downcasted) {
downcasted = int248(value);
require(downcasted == value, "SafeCast: value doesn't fit in 248 bits");
}
/**
* @dev Returns the downcasted int240 from int256, reverting on
* overflow (when the input is less than smallest int240 or
* greater than largest int240).
*
* Counterpart to Solidity's `int240` operator.
*
* Requirements:
*
* - input must fit into 240 bits
*
* _Available since v4.7._
*/
function toInt240(int256 value) internal pure returns (int240 downcasted) {
downcasted = int240(value);
require(downcasted == value, "SafeCast: value doesn't fit in 240 bits");
}
/**
* @dev Returns the downcasted int232 from int256, reverting on
* overflow (when the input is less than smallest int232 or
* greater than largest int232).
*
* Counterpart to Solidity's `int232` operator.
*
* Requirements:
*
* - input must fit into 232 bits
*
* _Available since v4.7._
*/
function toInt232(int256 value) internal pure returns (int232 downcasted) {
downcasted = int232(value);
require(downcasted == value, "SafeCast: value doesn't fit in 232 bits");
}
/**
* @dev Returns the downcasted int224 from int256, reverting on
* overflow (when the input is less than smallest int224 or
* greater than largest int224).
*
* Counterpart to Solidity's `int224` operator.
*
* Requirements:
*
* - input must fit into 224 bits
*
* _Available since v4.7._
*/
function toInt224(int256 value) internal pure returns (int224 downcasted) {
downcasted = int224(value);
require(downcasted == value, "SafeCast: value doesn't fit in 224 bits");
}
/**
* @dev Returns the downcasted int216 from int256, reverting on
* overflow (when the input is less than smallest int216 or
* greater than largest int216).
*
* Counterpart to Solidity's `int216` operator.
*
* Requirements:
*
* - input must fit into 216 bits
*
* _Available since v4.7._
*/
function toInt216(int256 value) internal pure returns (int216 downcasted) {
downcasted = int216(value);
require(downcasted == value, "SafeCast: value doesn't fit in 216 bits");
}
/**
* @dev Returns the downcasted int208 from int256, reverting on
* overflow (when the input is less than smallest int208 or
* greater than largest int208).
*
* Counterpart to Solidity's `int208` operator.
*
* Requirements:
*
* - input must fit into 208 bits
*
* _Available since v4.7._
*/
function toInt208(int256 value) internal pure returns (int208 downcasted) {
downcasted = int208(value);
require(downcasted == value, "SafeCast: value doesn't fit in 208 bits");
}
/**
* @dev Returns the downcasted int200 from int256, reverting on
* overflow (when the input is less than smallest int200 or
* greater than largest int200).
*
* Counterpart to Solidity's `int200` operator.
*
* Requirements:
*
* - input must fit into 200 bits
*
* _Available since v4.7._
*/
function toInt200(int256 value) internal pure returns (int200 downcasted) {
downcasted = int200(value);
require(downcasted == value, "SafeCast: value doesn't fit in 200 bits");
}
/**
* @dev Returns the downcasted int192 from int256, reverting on
* overflow (when the input is less than smallest int192 or
* greater than largest int192).
*
* Counterpart to Solidity's `int192` operator.
*
* Requirements:
*
* - input must fit into 192 bits
*
* _Available since v4.7._
*/
function toInt192(int256 value) internal pure returns (int192 downcasted) {
downcasted = int192(value);
require(downcasted == value, "SafeCast: value doesn't fit in 192 bits");
}
/**
* @dev Returns the downcasted int184 from int256, reverting on
* overflow (when the input is less than smallest int184 or
* greater than largest int184).
*
* Counterpart to Solidity's `int184` operator.
*
* Requirements:
*
* - input must fit into 184 bits
*
* _Available since v4.7._
*/
function toInt184(int256 value) internal pure returns (int184 downcasted) {
downcasted = int184(value);
require(downcasted == value, "SafeCast: value doesn't fit in 184 bits");
}
/**
* @dev Returns the downcasted int176 from int256, reverting on
* overflow (when the input is less than smallest int176 or
* greater than largest int176).
*
* Counterpart to Solidity's `int176` operator.
*
* Requirements:
*
* - input must fit into 176 bits
*
* _Available since v4.7._
*/
function toInt176(int256 value) internal pure returns (int176 downcasted) {
downcasted = int176(value);
require(downcasted == value, "SafeCast: value doesn't fit in 176 bits");
}
/**
* @dev Returns the downcasted int168 from int256, reverting on
* overflow (when the input is less than smallest int168 or
* greater than largest int168).
*
* Counterpart to Solidity's `int168` operator.
*
* Requirements:
*
* - input must fit into 168 bits
*
* _Available since v4.7._
*/
function toInt168(int256 value) internal pure returns (int168 downcasted) {
downcasted = int168(value);
require(downcasted == value, "SafeCast: value doesn't fit in 168 bits");
}
/**
* @dev Returns the downcasted int160 from int256, reverting on
* overflow (when the input is less than smallest int160 or
* greater than largest int160).
*
* Counterpart to Solidity's `int160` operator.
*
* Requirements:
*
* - input must fit into 160 bits
*
* _Available since v4.7._
*/
function toInt160(int256 value) internal pure returns (int160 downcasted) {
downcasted = int160(value);
require(downcasted == value, "SafeCast: value doesn't fit in 160 bits");
}
/**
* @dev Returns the downcasted int152 from int256, reverting on
* overflow (when the input is less than smallest int152 or
* greater than largest int152).
*
* Counterpart to Solidity's `int152` operator.
*
* Requirements:
*
* - input must fit into 152 bits
*
* _Available since v4.7._
*/
function toInt152(int256 value) internal pure returns (int152 downcasted) {
downcasted = int152(value);
require(downcasted == value, "SafeCast: value doesn't fit in 152 bits");
}
/**
* @dev Returns the downcasted int144 from int256, reverting on
* overflow (when the input is less than smallest int144 or
* greater than largest int144).
*
* Counterpart to Solidity's `int144` operator.
*
* Requirements:
*
* - input must fit into 144 bits
*
* _Available since v4.7._
*/
function toInt144(int256 value) internal pure returns (int144 downcasted) {
downcasted = int144(value);
require(downcasted == value, "SafeCast: value doesn't fit in 144 bits");
}
/**
* @dev Returns the downcasted int136 from int256, reverting on
* overflow (when the input is less than smallest int136 or
* greater than largest int136).
*
* Counterpart to Solidity's `int136` operator.
*
* Requirements:
*
* - input must fit into 136 bits
*
* _Available since v4.7._
*/
function toInt136(int256 value) internal pure returns (int136 downcasted) {
downcasted = int136(value);
require(downcasted == value, "SafeCast: value doesn't fit in 136 bits");
}
/**
* @dev Returns the downcasted int128 from int256, reverting on
* overflow (when the input is less than smallest int128 or
* greater than largest int128).
*
* Counterpart to Solidity's `int128` operator.
*
* Requirements:
*
* - input must fit into 128 bits
*
* _Available since v3.1._
*/
function toInt128(int256 value) internal pure returns (int128 downcasted) {
downcasted = int128(value);
require(downcasted == value, "SafeCast: value doesn't fit in 128 bits");
}
/**
* @dev Returns the downcasted int120 from int256, reverting on
* overflow (when the input is less than smallest int120 or
* greater than largest int120).
*
* Counterpart to Solidity's `int120` operator.
*
* Requirements:
*
* - input must fit into 120 bits
*
* _Available since v4.7._
*/
function toInt120(int256 value) internal pure returns (int120 downcasted) {
downcasted = int120(value);
require(downcasted == value, "SafeCast: value doesn't fit in 120 bits");
}
/**
* @dev Returns the downcasted int112 from int256, reverting on
* overflow (when the input is less than smallest int112 or
* greater than largest int112).
*
* Counterpart to Solidity's `int112` operator.
*
* Requirements:
*
* - input must fit into 112 bits
*
* _Available since v4.7._
*/
function toInt112(int256 value) internal pure returns (int112 downcasted) {
downcasted = int112(value);
require(downcasted == value, "SafeCast: value doesn't fit in 112 bits");
}
/**
* @dev Returns the downcasted int104 from int256, reverting on
* overflow (when the input is less than smallest int104 or
* greater than largest int104).
*
* Counterpart to Solidity's `int104` operator.
*
* Requirements:
*
* - input must fit into 104 bits
*
* _Available since v4.7._
*/
function toInt104(int256 value) internal pure returns (int104 downcasted) {
downcasted = int104(value);
require(downcasted == value, "SafeCast: value doesn't fit in 104 bits");
}
/**
* @dev Returns the downcasted int96 from int256, reverting on
* overflow (when the input is less than smallest int96 or
* greater than largest int96).
*
* Counterpart to Solidity's `int96` operator.
*
* Requirements:
*
* - input must fit into 96 bits
*
* _Available since v4.7._
*/
function toInt96(int256 value) internal pure returns (int96 downcasted) {
downcasted = int96(value);
require(downcasted == value, "SafeCast: value doesn't fit in 96 bits");
}
/**
* @dev Returns the downcasted int88 from int256, reverting on
* overflow (when the input is less than smallest int88 or
* greater than largest int88).
*
* Counterpart to Solidity's `int88` operator.
*
* Requirements:
*
* - input must fit into 88 bits
*
* _Available since v4.7._
*/
function toInt88(int256 value) internal pure returns (int88 downcasted) {
downcasted = int88(value);
require(downcasted == value, "SafeCast: value doesn't fit in 88 bits");
}
/**
* @dev Returns the downcasted int80 from int256, reverting on
* overflow (when the input is less than smallest int80 or
* greater than largest int80).
*
* Counterpart to Solidity's `int80` operator.
*
* Requirements:
*
* - input must fit into 80 bits
*
* _Available since v4.7._
*/
function toInt80(int256 value) internal pure returns (int80 downcasted) {
downcasted = int80(value);
require(downcasted == value, "SafeCast: value doesn't fit in 80 bits");
}
/**
* @dev Returns the downcasted int72 from int256, reverting on
* overflow (when the input is less than smallest int72 or
* greater than largest int72).
*
* Counterpart to Solidity's `int72` operator.
*
* Requirements:
*
* - input must fit into 72 bits
*
* _Available since v4.7._
*/
function toInt72(int256 value) internal pure returns (int72 downcasted) {
downcasted = int72(value);
require(downcasted == value, "SafeCast: value doesn't fit in 72 bits");
}
/**
* @dev Returns the downcasted int64 from int256, reverting on
* overflow (when the input is less than smallest int64 or
* greater than largest int64).
*
* Counterpart to Solidity's `int64` operator.
*
* Requirements:
*
* - input must fit into 64 bits
*
* _Available since v3.1._
*/
function toInt64(int256 value) internal pure returns (int64 downcasted) {
downcasted = int64(value);
require(downcasted == value, "SafeCast: value doesn't fit in 64 bits");
}
/**
* @dev Returns the downcasted int56 from int256, reverting on
* overflow (when the input is less than smallest int56 or
* greater than largest int56).
*
* Counterpart to Solidity's `int56` operator.
*
* Requirements:
*
* - input must fit into 56 bits
*
* _Available since v4.7._
*/
function toInt56(int256 value) internal pure returns (int56 downcasted) {
downcasted = int56(value);
require(downcasted == value, "SafeCast: value doesn't fit in 56 bits");
}
/**
* @dev Returns the downcasted int48 from int256, reverting on
* overflow (when the input is less than smallest int48 or
* greater than largest int48).
*
* Counterpart to Solidity's `int48` operator.
*
* Requirements:
*
* - input must fit into 48 bits
*
* _Available since v4.7._
*/
function toInt48(int256 value) internal pure returns (int48 downcasted) {
downcasted = int48(value);
require(downcasted == value, "SafeCast: value doesn't fit in 48 bits");
}
/**
* @dev Returns the downcasted int40 from int256, reverting on
* overflow (when the input is less than smallest int40 or
* greater than largest int40).
*
* Counterpart to Solidity's `int40` operator.
*
* Requirements:
*
* - input must fit into 40 bits
*
* _Available since v4.7._
*/
function toInt40(int256 value) internal pure returns (int40 downcasted) {
downcasted = int40(value);
require(downcasted == value, "SafeCast: value doesn't fit in 40 bits");
}
/**
* @dev Returns the downcasted int32 from int256, reverting on
* overflow (when the input is less than smallest int32 or
* greater than largest int32).
*
* Counterpart to Solidity's `int32` operator.
*
* Requirements:
*
* - input must fit into 32 bits
*
* _Available since v3.1._
*/
function toInt32(int256 value) internal pure returns (int32 downcasted) {
downcasted = int32(value);
require(downcasted == value, "SafeCast: value doesn't fit in 32 bits");
}
/**
* @dev Returns the downcasted int24 from int256, reverting on
* overflow (when the input is less than smallest int24 or
* greater than largest int24).
*
* Counterpart to Solidity's `int24` operator.
*
* Requirements:
*
* - input must fit into 24 bits
*
* _Available since v4.7._
*/
function toInt24(int256 value) internal pure returns (int24 downcasted) {
downcasted = int24(value);
require(downcasted == value, "SafeCast: value doesn't fit in 24 bits");
}
/**
* @dev Returns the downcasted int16 from int256, reverting on
* overflow (when the input is less than smallest int16 or
* greater than largest int16).
*
* Counterpart to Solidity's `int16` operator.
*
* Requirements:
*
* - input must fit into 16 bits
*
* _Available since v3.1._
*/
function toInt16(int256 value) internal pure returns (int16 downcasted) {
downcasted = int16(value);
require(downcasted == value, "SafeCast: value doesn't fit in 16 bits");
}
/**
* @dev Returns the downcasted int8 from int256, reverting on
* overflow (when the input is less than smallest int8 or
* greater than largest int8).
*
* Counterpart to Solidity's `int8` operator.
*
* Requirements:
*
* - input must fit into 8 bits
*
* _Available since v3.1._
*/
function toInt8(int256 value) internal pure returns (int8 downcasted) {
downcasted = int8(value);
require(downcasted == value, "SafeCast: value doesn't fit in 8 bits");
}
/**
* @dev Converts an unsigned uint256 into a signed int256.
*
* Requirements:
*
* - input must be less than or equal to maxInt256.
*
* _Available since v3.0._
*/
function toInt256(uint256 value) internal pure returns (int256) {
// Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive
require(value <= uint256(type(int256).max), "SafeCast: value doesn't fit in an int256");
return int256(value);
}
}
contracts/interfaces/INetworkBalances.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.19;
import "./Errors.sol";
import "./IUpgrade.sol";
interface INetworkBalances is Errors, IUpgrade {
struct BalancesSnapshot {
uint256 _block;
uint256 _totalEth;
uint256 _totalLsdToken;
}
event BalancesUpdated(uint256 block, uint256 totalEth, uint256 lsdTokenSupply, uint256 time);
function init(address _networkProposalAddress) external;
function getEthValue(uint256 _lsdTokenAmount) external view returns (uint256);
function getLsdTokenValue(uint256 _ethAmount) external view returns (uint256);
function getExchangeRate() external view returns (uint256);
function submitBalances(uint256 _block, uint256 _totalEth, uint256 _totalLsdToken) external;
}
@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/IERC1155Receiver.sol)
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.sol";
/**
* @dev _Available since v3.1._
*/
interface IERC1155Receiver is IERC165 {
/**
* @dev Handles the receipt of a single ERC1155 token type. This function is
* called at the end of a `safeTransferFrom` after the balance has been updated.
*
* NOTE: To accept the transfer, this must return
* `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))`
* (i.e. 0xf23a6e61, or its own function selector).
*
* @param operator The address which initiated the transfer (i.e. msg.sender)
* @param from The address which previously owned the token
* @param id The ID of the token being transferred
* @param value The amount of tokens being transferred
* @param data Additional data with no specified format
* @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed
*/
function onERC1155Received(
address operator,
address from,
uint256 id,
uint256 value,
bytes calldata data
) external returns (bytes4);
/**
* @dev Handles the receipt of a multiple ERC1155 token types. This function
* is called at the end of a `safeBatchTransferFrom` after the balances have
* been updated.
*
* NOTE: To accept the transfer(s), this must return
* `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))`
* (i.e. 0xbc197c81, or its own function selector).
*
* @param operator The address which initiated the batch transfer (i.e. msg.sender)
* @param from The address which previously owned the token
* @param ids An array containing ids of each token being transferred (order and length must match values array)
* @param values An array containing amounts of each token being transferred (order and length must match ids array)
* @param data Additional data with no specified format
* @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed
*/
function onERC1155BatchReceived(
address operator,
address from,
uint256[] calldata ids,
uint256[] calldata values,
bytes calldata data
) external returns (bytes4);
}
contracts/interfaces/ILsdToken.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.19;
import "./IRateProvider.sol";
import "./Errors.sol";
interface ILsdToken is IRateProvider, Errors {
function initMinter(address) external;
function mint(address, uint256) external;
function updateMinter(address _newMinter) external;
}
contracts/interfaces/ILsdNetworkFactory.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.19;
import "./Errors.sol";
import "./IUpgrade.sol";
interface ILsdNetworkFactory is Errors, IUpgrade {
struct NetworkContracts {
address _feePool;
address _networkBalances;
address _networkProposal;
address _nodeDeposit;
address _userDeposit;
address _networkWithdraw;
uint256 _block;
}
event LsdNetwork(NetworkContracts contracts);
function createLsdNetwork(
string memory _lsdTokenName,
string memory _lsdTokenSymbol,
address _networkAdmin,
address[] memory _voters,
uint256 _threshold
) external;
function createLsdNetworkWithTimelock(
string memory _lsdTokenName,
string memory _lsdTokenSymbol,
address[] memory _voters,
uint256 _threshold,
uint256 minDelay,
address[] memory proposers
) external;
function createLsdNetworkWithLsdToken(
address _lsdToken,
address _networkAdmin,
address[] memory _voters,
uint256 _threshold
) external;
}
contracts/interfaces/INetworkWithdraw.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.19;
import "./IDepositEth.sol";
import "./Errors.sol";
import "./IUpgrade.sol";
interface INetworkWithdraw is IDepositEth, Errors, IUpgrade {
enum ClaimType {
None,
ClaimReward,
ClaimDeposit,
ClaimTotal
}
enum DistributeType {
None,
DistributeWithdrawals,
DistributePriorityFee
}
struct Withdrawal {
address _address;
uint256 _amount;
}
event NodeClaimed(
uint256 index, address account, uint256 claimableReward, uint256 claimableDeposit, ClaimType claimType
);
event SetWithdrawCycleSeconds(uint256 cycleSeconds);
event SetMerkleRoot(uint256 indexed dealedEpoch, bytes32 merkleRoot, string nodeRewardsFileCid);
event EtherDeposited(address indexed from, uint256 amount, uint256 time);
event Unstake(
address indexed from, uint256 lsdTokenAmount, uint256 ethAmount, uint256 withdrawIndex, bool instantly
);
event Withdraw(address indexed from, uint256[] withdrawIndexList);
event DistributeRewards(
DistributeType distributeType,
uint256 dealedHeight,
uint256 userAmount,
uint256 nodeAmount,
uint256 platformAmount,
uint256 maxClaimableWithdrawIndex,
uint256 mvAmount
);
event NotifyValidatorExit(uint256 withdrawCycle, uint256 ejectedStartWithdrawCycle, uint256[] ejectedValidators);
function init(
address _lsdTokenAddress,
address _userDepositAddress,
address _networkProposalAddress,
address _networkBalancesAddress,
address _feePoolAddress,
address _factoryAddress
) external;
// getter
function getUnclaimedWithdrawalsOfUser(address _user) external view returns (uint256[] memory);
function getEjectedValidatorsAtCycle(uint256 _cycle) external view returns (uint256[] memory);
function totalMissingAmountForWithdraw() external view returns (uint256);
// user
function unstake(uint256 _lsdTokenAmount) external;
function withdraw(uint256[] calldata _withdrawIndexList) external;
// ejector
function notifyValidatorExit(
uint256 _withdrawCycle,
uint256 _ejectedStartWithdrawCycle,
uint256[] calldata _validatorIndex
) external;
// voter
function distribute(
DistributeType _distributeType,
uint256 _dealedHeight,
uint256 _userAmount,
uint256 _nodeAmount,
uint256 _platformAmount,
uint256 _maxClaimableWithdrawIndex
) external;
function depositEthAndUpdateTotalMissingAmount() external payable;
}
@openzeppelin/contracts/utils/math/SignedMath.sol
// SPDX-License-Identifier: MIT
// 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 SignedMath {
/**
* @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);
}
}
}
@openzeppelin/contracts/utils/Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
*
* Furthermore, `isContract` will also return true if the target contract within
* the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
* which only has an effect at the end of a transaction.
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
* the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
*
* _Available since v4.8._
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
// only check isContract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
/**
* @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason or using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
contracts/interfaces/INodeDeposit.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.19;
import "./IDepositEth.sol";
import "./Errors.sol";
import "./IUpgrade.sol";
interface INodeDeposit is IDepositEth, Errors, IUpgrade {
enum NodeType {
Undefined,
SoloNode,
TrustNode
}
enum PubkeyStatus {
UnInitial,
Deposited,
Match,
Staked,
UnMatch
}
struct PubkeyInfo {
PubkeyStatus _status;
address _owner;
uint256 _nodeDepositAmount;
uint256 _depositBlock;
}
struct NodeInfo {
NodeType _nodeType;
bool _removed;
}
event EtherDeposited(address indexed from, uint256 amount, uint256 time);
event Deposited(address node, NodeType nodeType, bytes pubkey, bytes validatorSignature, uint256 amount);
event Staked(address node, bytes pubkey);
event SetPubkeyStatus(bytes pubkey, PubkeyStatus status);
function deposit(
bytes[] calldata _validatorPubkeys,
bytes[] calldata _validatorSignatures,
bytes32[] calldata _depositDataRoots
) external payable;
function stake(
bytes[] calldata _validatorPubkeys,
bytes[] calldata _validatorSignatures,
bytes32[] calldata _depositDataRoots
) external;
function init(
address _userDepositAddress,
address _ethDepositAddress,
address _networkProposalAddress,
bytes calldata _withdrawCredentials
) external;
function voteWithdrawCredentials(bytes calldata _pubkey, bool _match) external;
}
contracts/interfaces/IRateProvider.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.19;
interface IRateProvider {
function getRate() external view returns (uint256);
}
contracts/interfaces/INetworkProposal.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.19;
import "./Errors.sol";
import "./IUpgrade.sol";
interface INetworkProposal is Errors, IUpgrade {
enum ProposalStatus {
Inactive,
Active,
Executed
}
struct Proposal {
ProposalStatus _status;
uint16 _yesVotes; // bitmap, 16 maximum votes
uint8 _yesVotesTotal;
}
event VoteProposal(bytes32 indexed _proposalId, address _voter);
event ProposalExecuted(bytes32 indexed _proposalId);
event VoterManagementTakenOver(address indexed _oldManager, address indexed _newManager);
function init(address[] memory _voters, uint256 _initialThreshold, address _adminAddress, address _voterManagerAddress) external;
function isAdmin(address _sender) external view returns (bool);
}
@openzeppelin/contracts/token/ERC20/ERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/ERC20.sol)
pragma solidity ^0.8.0;
import "./IERC20.sol";
import "./extensions/IERC20Metadata.sol";
import "../../utils/Context.sol";
/**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* The default value of {decimals} is 18. To change this, you should override
* this function so it returns a different value.
*
* We have followed general OpenZeppelin Contracts guidelines: functions revert
* instead returning `false` on failure. This behavior is nonetheless
* conventional and does not conflict with the expectations of ERC20
* applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/
contract ERC20 is Context, IERC20, IERC20Metadata {
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* All two of these values are immutable: they can only be set once during
* construction.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5.05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the default value returned by this function, unless
* it's overridden.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual override returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address to, uint256 amount) public virtual override returns (bool) {
address owner = _msgSender();
_transfer(owner, to, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on
* `transferFrom`. This is semantically equivalent to an infinite approval.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
address owner = _msgSender();
_approve(owner, spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* NOTE: Does not update the allowance if the current allowance
* is the maximum `uint256`.
*
* Requirements:
*
* - `from` and `to` cannot be the zero address.
* - `from` must have a balance of at least `amount`.
* - the caller must have allowance for ``from``'s tokens of at least
* `amount`.
*/
function transferFrom(address from, address to, uint256 amount) public virtual override returns (bool) {
address spender = _msgSender();
_spendAllowance(from, spender, amount);
_transfer(from, to, amount);
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
address owner = _msgSender();
_approve(owner, spender, allowance(owner, spender) + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
address owner = _msgSender();
uint256 currentAllowance = allowance(owner, spender);
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
unchecked {
_approve(owner, spender, currentAllowance - subtractedValue);
}
return true;
}
/**
* @dev Moves `amount` of tokens from `from` to `to`.
*
* This internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `from` must have a balance of at least `amount`.
*/
function _transfer(address from, address to, uint256 amount) internal virtual {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(from, to, amount);
uint256 fromBalance = _balances[from];
require(fromBalance >= amount, "ERC20: transfer amount exceeds balance");
unchecked {
_balances[from] = fromBalance - amount;
// Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by
// decrementing then incrementing.
_balances[to] += amount;
}
emit Transfer(from, to, amount);
_afterTokenTransfer(from, to, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
unchecked {
// Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.
_balances[account] += amount;
}
emit Transfer(address(0), account, amount);
_afterTokenTransfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
unchecked {
_balances[account] = accountBalance - amount;
// Overflow not possible: amount <= accountBalance <= totalSupply.
_totalSupply -= amount;
}
emit Transfer(account, address(0), amount);
_afterTokenTransfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Updates `owner` s allowance for `spender` based on spent `amount`.
*
* Does not update the allowance amount in case of infinite allowance.
* Revert if not enough allowance is available.
*
* Might emit an {Approval} event.
*/
function _spendAllowance(address owner, address spender, uint256 amount) internal virtual {
uint256 currentAllowance = allowance(owner, spender);
if (currentAllowance != type(uint256).max) {
require(currentAllowance >= amount, "ERC20: insufficient allowance");
unchecked {
_approve(owner, spender, currentAllowance - amount);
}
}
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual {}
/**
* @dev Hook that is called after any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* has been transferred to `to`.
* - when `from` is zero, `amount` tokens have been minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens have been burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _afterTokenTransfer(address from, address to, uint256 amount) internal virtual {}
}
@openzeppelin/contracts/utils/structs/EnumerableSet.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/structs/EnumerableSet.sol)
// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.
pragma solidity ^0.8.0;
/**
* @dev Library for managing
* https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
* types.
*
* Sets have the following properties:
*
* - Elements are added, removed, and checked for existence in constant time
* (O(1)).
* - Elements are enumerated in O(n). No guarantees are made on the ordering.
*
* ```solidity
* contract Example {
* // Add the library methods
* using EnumerableSet for EnumerableSet.AddressSet;
*
* // Declare a set state variable
* EnumerableSet.AddressSet private mySet;
* }
* ```
*
* As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
* and `uint256` (`UintSet`) are supported.
*
* [WARNING]
* ====
* Trying to delete such a structure from storage will likely result in data corruption, rendering the structure
* unusable.
* See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.
*
* In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an
* array of EnumerableSet.
* ====
*/
library EnumerableSet {
// To implement this library for multiple types with as little code
// repetition as possible, we write it in terms of a generic Set type with
// bytes32 values.
// The Set implementation uses private functions, and user-facing
// implementations (such as AddressSet) are just wrappers around the
// underlying Set.
// This means that we can only create new EnumerableSets for types that fit
// in bytes32.
struct Set {
// Storage of set values
bytes32[] _values;
// Position of the value in the `values` array, plus 1 because index 0
// means a value is not in the set.
mapping(bytes32 => uint256) _indexes;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function _add(Set storage set, bytes32 value) private returns (bool) {
if (!_contains(set, value)) {
set._values.push(value);
// The value is stored at length-1, but we add 1 to all indexes
// and use 0 as a sentinel value
set._indexes[value] = set._values.length;
return true;
} else {
return false;
}
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function _remove(Set storage set, bytes32 value) private returns (bool) {
// We read and store the value's index to prevent multiple reads from the same storage slot
uint256 valueIndex = set._indexes[value];
if (valueIndex != 0) {
// Equivalent to contains(set, value)
// To delete an element from the _values array in O(1), we swap the element to delete with the last one in
// the array, and then remove the last element (sometimes called as 'swap and pop').
// This modifies the order of the array, as noted in {at}.
uint256 toDeleteIndex = valueIndex - 1;
uint256 lastIndex = set._values.length - 1;
if (lastIndex != toDeleteIndex) {
bytes32 lastValue = set._values[lastIndex];
// Move the last value to the index where the value to delete is
set._values[toDeleteIndex] = lastValue;
// Update the index for the moved value
set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex
}
// Delete the slot where the moved value was stored
set._values.pop();
// Delete the index for the deleted slot
delete set._indexes[value];
return true;
} else {
return false;
}
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function _contains(Set storage set, bytes32 value) private view returns (bool) {
return set._indexes[value] != 0;
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function _at(Set storage set, uint256 index) private view returns (bytes32) {
return set._values[index];
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function _values(Set storage set) private view returns (bytes32[] memory) {
return set._values;
}
// Bytes32Set
struct Bytes32Set {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _add(set._inner, value);
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _remove(set._inner, value);
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
return _contains(set._inner, value);
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(Bytes32Set storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
return _at(set._inner, index);
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
bytes32[] memory store = _values(set._inner);
bytes32[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
// AddressSet
struct AddressSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(AddressSet storage set, address value) internal returns (bool) {
return _add(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(AddressSet storage set, address value) internal returns (bool) {
return _remove(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(AddressSet storage set, address value) internal view returns (bool) {
return _contains(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(AddressSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(AddressSet storage set, uint256 index) internal view returns (address) {
return address(uint160(uint256(_at(set._inner, index))));
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(AddressSet storage set) internal view returns (address[] memory) {
bytes32[] memory store = _values(set._inner);
address[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
// UintSet
struct UintSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(UintSet storage set, uint256 value) internal returns (bool) {
return _add(set._inner, bytes32(value));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(UintSet storage set, uint256 value) internal returns (bool) {
return _remove(set._inner, bytes32(value));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(UintSet storage set, uint256 value) internal view returns (bool) {
return _contains(set._inner, bytes32(value));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(UintSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(UintSet storage set, uint256 index) internal view returns (uint256) {
return uint256(_at(set._inner, index));
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(UintSet storage set) internal view returns (uint256[] memory) {
bytes32[] memory store = _values(set._inner);
uint256[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
}
contracts/interfaces/Errors.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.19;
interface Errors {
error FailedToCall();
error AddressNotAllowed();
error CallerNotAllowed();
error AmountUnmatch();
error AmountZero();
error AmountNotZero();
error AlreadyInitialized();
error NotAuthorizedLsdToken();
error LsdTokenCanOnlyUseOnce();
error EmptyEntrustedVoters();
error SubmitBalancesDisabled();
error BlockNotMatch();
error RateChangeOverLimit();
error InvalidThreshold();
error VotersNotEnough();
error VotersDuplicate();
error VotersNotExist();
error ProposalExecFailed();
error AlreadyVoted();
error WithdrawIndexEmpty();
error NotClaimable();
error AlreadyClaimed();
error InvalidMerkleProof();
error ClaimableRewardZero();
error ClaimableDepositZero();
error ClaimableAmountZero();
error AlreadyDealedHeight();
error ClaimableWithdrawIndexOverflow();
error BalanceNotEnough();
error LengthNotMatch();
error CycleNotMatch();
error AlreadyNotifiedCycle();
error AlreadyDealedEpoch();
error LsdTokenAmountZero();
error EthAmountZero();
error TooLow(uint256 min);
error NodeNotClaimable();
error CommissionRateInvalid();
error PubkeyNotExist();
error PubkeyAlreadyExist();
error PubkeyStatusUnmatch();
error NodeAlreadyExist();
error NotTrustNode();
error NodeAlreadyRemoved();
error TrustNodeDepositDisabled();
error SoloNodeDepositDisabled();
error SoloNodeDepositAmountZero();
error PubkeyNumberOverLimit();
error NotPubkeyOwner();
error UserDepositDisabled();
error DepositAmountLTMinAmount();
error DepositAmountGTMaxAmount();
error UnknownClaimType();
error UnknownDistributeType();
error UnknownNodeType();
}
@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
/**
* @dev Interface for the optional metadata functions from the ERC20 standard.
*
* _Available since v4.1._
*/
interface IERC20Metadata is IERC20 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
}
@openzeppelin/contracts/governance/TimelockController.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (governance/TimelockController.sol)
pragma solidity ^0.8.0;
import "../access/AccessControl.sol";
import "../token/ERC721/IERC721Receiver.sol";
import "../token/ERC1155/IERC1155Receiver.sol";
/**
* @dev Contract module which acts as a timelocked controller. When set as the
* owner of an `Ownable` smart contract, it enforces a timelock on all
* `onlyOwner` maintenance operations. This gives time for users of the
* controlled contract to exit before a potentially dangerous maintenance
* operation is applied.
*
* By default, this contract is self administered, meaning administration tasks
* have to go through the timelock process. The proposer (resp executor) role
* is in charge of proposing (resp executing) operations. A common use case is
* to position this {TimelockController} as the owner of a smart contract, with
* a multisig or a DAO as the sole proposer.
*
* _Available since v3.3._
*/
contract TimelockController is AccessControl, IERC721Receiver, IERC1155Receiver {
bytes32 public constant TIMELOCK_ADMIN_ROLE = keccak256("TIMELOCK_ADMIN_ROLE");
bytes32 public constant PROPOSER_ROLE = keccak256("PROPOSER_ROLE");
bytes32 public constant EXECUTOR_ROLE = keccak256("EXECUTOR_ROLE");
bytes32 public constant CANCELLER_ROLE = keccak256("CANCELLER_ROLE");
uint256 internal constant _DONE_TIMESTAMP = uint256(1);
mapping(bytes32 => uint256) private _timestamps;
uint256 private _minDelay;
/**
* @dev Emitted when a call is scheduled as part of operation `id`.
*/
event CallScheduled(
bytes32 indexed id,
uint256 indexed index,
address target,
uint256 value,
bytes data,
bytes32 predecessor,
uint256 delay
);
/**
* @dev Emitted when a call is performed as part of operation `id`.
*/
event CallExecuted(bytes32 indexed id, uint256 indexed index, address target, uint256 value, bytes data);
/**
* @dev Emitted when new proposal is scheduled with non-zero salt.
*/
event CallSalt(bytes32 indexed id, bytes32 salt);
/**
* @dev Emitted when operation `id` is cancelled.
*/
event Cancelled(bytes32 indexed id);
/**
* @dev Emitted when the minimum delay for future operations is modified.
*/
event MinDelayChange(uint256 oldDuration, uint256 newDuration);
/**
* @dev Initializes the contract with the following parameters:
*
* - `minDelay`: initial minimum delay for operations
* - `proposers`: accounts to be granted proposer and canceller roles
* - `executors`: accounts to be granted executor role
* - `admin`: optional account to be granted admin role; disable with zero address
*
* IMPORTANT: The optional admin can aid with initial configuration of roles after deployment
* without being subject to delay, but this role should be subsequently renounced in favor of
* administration through timelocked proposals. Previous versions of this contract would assign
* this admin to the deployer automatically and should be renounced as well.
*/
constructor(uint256 minDelay, address[] memory proposers, address[] memory executors, address admin) {
_setRoleAdmin(TIMELOCK_ADMIN_ROLE, TIMELOCK_ADMIN_ROLE);
_setRoleAdmin(PROPOSER_ROLE, TIMELOCK_ADMIN_ROLE);
_setRoleAdmin(EXECUTOR_ROLE, TIMELOCK_ADMIN_ROLE);
_setRoleAdmin(CANCELLER_ROLE, TIMELOCK_ADMIN_ROLE);
// self administration
_setupRole(TIMELOCK_ADMIN_ROLE, address(this));
// optional admin
if (admin != address(0)) {
_setupRole(TIMELOCK_ADMIN_ROLE, admin);
}
// register proposers and cancellers
for (uint256 i = 0; i < proposers.length; ++i) {
_setupRole(PROPOSER_ROLE, proposers[i]);
_setupRole(CANCELLER_ROLE, proposers[i]);
}
// register executors
for (uint256 i = 0; i < executors.length; ++i) {
_setupRole(EXECUTOR_ROLE, executors[i]);
}
_minDelay = minDelay;
emit MinDelayChange(0, minDelay);
}
/**
* @dev Modifier to make a function callable only by a certain role. In
* addition to checking the sender's role, `address(0)` 's role is also
* considered. Granting a role to `address(0)` is equivalent to enabling
* this role for everyone.
*/
modifier onlyRoleOrOpenRole(bytes32 role) {
if (!hasRole(role, address(0))) {
_checkRole(role, _msgSender());
}
_;
}
/**
* @dev Contract might receive/hold ETH as part of the maintenance process.
*/
receive() external payable {}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, AccessControl) returns (bool) {
return interfaceId == type(IERC1155Receiver).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev Returns whether an id correspond to a registered operation. This
* includes both Pending, Ready and Done operations.
*/
function isOperation(bytes32 id) public view virtual returns (bool) {
return getTimestamp(id) > 0;
}
/**
* @dev Returns whether an operation is pending or not. Note that a "pending" operation may also be "ready".
*/
function isOperationPending(bytes32 id) public view virtual returns (bool) {
return getTimestamp(id) > _DONE_TIMESTAMP;
}
/**
* @dev Returns whether an operation is ready for execution. Note that a "ready" operation is also "pending".
*/
function isOperationReady(bytes32 id) public view virtual returns (bool) {
uint256 timestamp = getTimestamp(id);
return timestamp > _DONE_TIMESTAMP && timestamp <= block.timestamp;
}
/**
* @dev Returns whether an operation is done or not.
*/
function isOperationDone(bytes32 id) public view virtual returns (bool) {
return getTimestamp(id) == _DONE_TIMESTAMP;
}
/**
* @dev Returns the timestamp at which an operation becomes ready (0 for
* unset operations, 1 for done operations).
*/
function getTimestamp(bytes32 id) public view virtual returns (uint256) {
return _timestamps[id];
}
/**
* @dev Returns the minimum delay for an operation to become valid.
*
* This value can be changed by executing an operation that calls `updateDelay`.
*/
function getMinDelay() public view virtual returns (uint256) {
return _minDelay;
}
/**
* @dev Returns the identifier of an operation containing a single
* transaction.
*/
function hashOperation(
address target,
uint256 value,
bytes calldata data,
bytes32 predecessor,
bytes32 salt
) public pure virtual returns (bytes32) {
return keccak256(abi.encode(target, value, data, predecessor, salt));
}
/**
* @dev Returns the identifier of an operation containing a batch of
* transactions.
*/
function hashOperationBatch(
address[] calldata targets,
uint256[] calldata values,
bytes[] calldata payloads,
bytes32 predecessor,
bytes32 salt
) public pure virtual returns (bytes32) {
return keccak256(abi.encode(targets, values, payloads, predecessor, salt));
}
/**
* @dev Schedule an operation containing a single transaction.
*
* Emits {CallSalt} if salt is nonzero, and {CallScheduled}.
*
* Requirements:
*
* - the caller must have the 'proposer' role.
*/
function schedule(
address target,
uint256 value,
bytes calldata data,
bytes32 predecessor,
bytes32 salt,
uint256 delay
) public virtual onlyRole(PROPOSER_ROLE) {
bytes32 id = hashOperation(target, value, data, predecessor, salt);
_schedule(id, delay);
emit CallScheduled(id, 0, target, value, data, predecessor, delay);
if (salt != bytes32(0)) {
emit CallSalt(id, salt);
}
}
/**
* @dev Schedule an operation containing a batch of transactions.
*
* Emits {CallSalt} if salt is nonzero, and one {CallScheduled} event per transaction in the batch.
*
* Requirements:
*
* - the caller must have the 'proposer' role.
*/
function scheduleBatch(
address[] calldata targets,
uint256[] calldata values,
bytes[] calldata payloads,
bytes32 predecessor,
bytes32 salt,
uint256 delay
) public virtual onlyRole(PROPOSER_ROLE) {
require(targets.length == values.length, "TimelockController: length mismatch");
require(targets.length == payloads.length, "TimelockController: length mismatch");
bytes32 id = hashOperationBatch(targets, values, payloads, predecessor, salt);
_schedule(id, delay);
for (uint256 i = 0; i < targets.length; ++i) {
emit CallScheduled(id, i, targets[i], values[i], payloads[i], predecessor, delay);
}
if (salt != bytes32(0)) {
emit CallSalt(id, salt);
}
}
/**
* @dev Schedule an operation that is to become valid after a given delay.
*/
function _schedule(bytes32 id, uint256 delay) private {
require(!isOperation(id), "TimelockController: operation already scheduled");
require(delay >= getMinDelay(), "TimelockController: insufficient delay");
_timestamps[id] = block.timestamp + delay;
}
/**
* @dev Cancel an operation.
*
* Requirements:
*
* - the caller must have the 'canceller' role.
*/
function cancel(bytes32 id) public virtual onlyRole(CANCELLER_ROLE) {
require(isOperationPending(id), "TimelockController: operation cannot be cancelled");
delete _timestamps[id];
emit Cancelled(id);
}
/**
* @dev Execute an (ready) operation containing a single transaction.
*
* Emits a {CallExecuted} event.
*
* Requirements:
*
* - the caller must have the 'executor' role.
*/
// This function can reenter, but it doesn't pose a risk because _afterCall checks that the proposal is pending,
// thus any modifications to the operation during reentrancy should be caught.
// slither-disable-next-line reentrancy-eth
function execute(
address target,
uint256 value,
bytes calldata payload,
bytes32 predecessor,
bytes32 salt
) public payable virtual onlyRoleOrOpenRole(EXECUTOR_ROLE) {
bytes32 id = hashOperation(target, value, payload, predecessor, salt);
_beforeCall(id, predecessor);
_execute(target, value, payload);
emit CallExecuted(id, 0, target, value, payload);
_afterCall(id);
}
/**
* @dev Execute an (ready) operation containing a batch of transactions.
*
* Emits one {CallExecuted} event per transaction in the batch.
*
* Requirements:
*
* - the caller must have the 'executor' role.
*/
// This function can reenter, but it doesn't pose a risk because _afterCall checks that the proposal is pending,
// thus any modifications to the operation during reentrancy should be caught.
// slither-disable-next-line reentrancy-eth
function executeBatch(
address[] calldata targets,
uint256[] calldata values,
bytes[] calldata payloads,
bytes32 predecessor,
bytes32 salt
) public payable virtual onlyRoleOrOpenRole(EXECUTOR_ROLE) {
require(targets.length == values.length, "TimelockController: length mismatch");
require(targets.length == payloads.length, "TimelockController: length mismatch");
bytes32 id = hashOperationBatch(targets, values, payloads, predecessor, salt);
_beforeCall(id, predecessor);
for (uint256 i = 0; i < targets.length; ++i) {
address target = targets[i];
uint256 value = values[i];
bytes calldata payload = payloads[i];
_execute(target, value, payload);
emit CallExecuted(id, i, target, value, payload);
}
_afterCall(id);
}
/**
* @dev Execute an operation's call.
*/
function _execute(address target, uint256 value, bytes calldata data) internal virtual {
(bool success, ) = target.call{value: value}(data);
require(success, "TimelockController: underlying transaction reverted");
}
/**
* @dev Checks before execution of an operation's calls.
*/
function _beforeCall(bytes32 id, bytes32 predecessor) private view {
require(isOperationReady(id), "TimelockController: operation is not ready");
require(predecessor == bytes32(0) || isOperationDone(predecessor), "TimelockController: missing dependency");
}
/**
* @dev Checks after execution of an operation's calls.
*/
function _afterCall(bytes32 id) private {
require(isOperationReady(id), "TimelockController: operation is not ready");
_timestamps[id] = _DONE_TIMESTAMP;
}
/**
* @dev Changes the minimum timelock duration for future operations.
*
* Emits a {MinDelayChange} event.
*
* Requirements:
*
* - the caller must be the timelock itself. This can only be achieved by scheduling and later executing
* an operation where the timelock is the target and the data is the ABI-encoded call to this function.
*/
function updateDelay(uint256 newDelay) external virtual {
require(msg.sender == address(this), "TimelockController: caller must be timelock");
emit MinDelayChange(_minDelay, newDelay);
_minDelay = newDelay;
}
/**
* @dev See {IERC721Receiver-onERC721Received}.
*/
function onERC721Received(address, address, uint256, bytes memory) public virtual override returns (bytes4) {
return this.onERC721Received.selector;
}
/**
* @dev See {IERC1155Receiver-onERC1155Received}.
*/
function onERC1155Received(
address,
address,
uint256,
uint256,
bytes memory
) public virtual override returns (bytes4) {
return this.onERC1155Received.selector;
}
/**
* @dev See {IERC1155Receiver-onERC1155BatchReceived}.
*/
function onERC1155BatchReceived(
address,
address,
uint256[] memory,
uint256[] memory,
bytes memory
) public virtual override returns (bytes4) {
return this.onERC1155BatchReceived.selector;
}
}
@openzeppelin/contracts/utils/introspection/ERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)
pragma solidity ^0.8.0;
import "./IERC165.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
@openzeppelin/contracts/proxy/beacon/IBeacon.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)
pragma solidity ^0.8.0;
/**
* @dev This is the interface that {BeaconProxy} expects of its beacon.
*/
interface IBeacon {
/**
* @dev Must return an address that can be used as a delegate call target.
*
* {BeaconProxy} will check that this address is a contract.
*/
function implementation() external view returns (address);
}
@openzeppelin/contracts/token/ERC20/IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 amount) external returns (bool);
}
@openzeppelin/contracts/access/IAccessControl.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)
pragma solidity ^0.8.0;
/**
* @dev External interface of AccessControl declared to support ERC165 detection.
*/
interface IAccessControl {
/**
* @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;
}
Compiler Settings
{"outputSelection":{"*":{"*":["abi","evm.bytecode","evm.deployedBytecode","evm.methodIdentifiers","metadata"],"":["ast"]}},"optimizer":{"runs":200,"enabled":true},"libraries":{"contracts/libraries/NewContractLib.sol":{"NewContractLib":"0x3c5ea15f6e702fcc0351605b867e9ff33e1fd6bf"}}}
Contract ABI
[{"type":"constructor","stateMutability":"nonpayable","inputs":[]},{"type":"error","name":"AddressNotAllowed","inputs":[]},{"type":"error","name":"AlreadyClaimed","inputs":[]},{"type":"error","name":"AlreadyDealedEpoch","inputs":[]},{"type":"error","name":"AlreadyDealedHeight","inputs":[]},{"type":"error","name":"AlreadyInitialized","inputs":[]},{"type":"error","name":"AlreadyNotifiedCycle","inputs":[]},{"type":"error","name":"AlreadyVoted","inputs":[]},{"type":"error","name":"AmountNotZero","inputs":[]},{"type":"error","name":"AmountUnmatch","inputs":[]},{"type":"error","name":"AmountZero","inputs":[]},{"type":"error","name":"BalanceNotEnough","inputs":[]},{"type":"error","name":"BlockNotMatch","inputs":[]},{"type":"error","name":"CallerNotAllowed","inputs":[]},{"type":"error","name":"ClaimableAmountZero","inputs":[]},{"type":"error","name":"ClaimableDepositZero","inputs":[]},{"type":"error","name":"ClaimableRewardZero","inputs":[]},{"type":"error","name":"ClaimableWithdrawIndexOverflow","inputs":[]},{"type":"error","name":"CommissionRateInvalid","inputs":[]},{"type":"error","name":"CycleNotMatch","inputs":[]},{"type":"error","name":"DepositAmountGTMaxAmount","inputs":[]},{"type":"error","name":"DepositAmountLTMinAmount","inputs":[]},{"type":"error","name":"EmptyEntrustedVoters","inputs":[]},{"type":"error","name":"EthAmountZero","inputs":[]},{"type":"error","name":"FailedToCall","inputs":[]},{"type":"error","name":"InvalidMerkleProof","inputs":[]},{"type":"error","name":"InvalidThreshold","inputs":[]},{"type":"error","name":"LengthNotMatch","inputs":[]},{"type":"error","name":"LsdTokenAmountZero","inputs":[]},{"type":"error","name":"LsdTokenCanOnlyUseOnce","inputs":[]},{"type":"error","name":"NodeAlreadyExist","inputs":[]},{"type":"error","name":"NodeAlreadyRemoved","inputs":[]},{"type":"error","name":"NodeNotClaimable","inputs":[]},{"type":"error","name":"NotAuthorizedLsdToken","inputs":[]},{"type":"error","name":"NotClaimable","inputs":[]},{"type":"error","name":"NotPubkeyOwner","inputs":[]},{"type":"error","name":"NotTrustNode","inputs":[]},{"type":"error","name":"ProposalExecFailed","inputs":[]},{"type":"error","name":"PubkeyAlreadyExist","inputs":[]},{"type":"error","name":"PubkeyNotExist","inputs":[]},{"type":"error","name":"PubkeyNumberOverLimit","inputs":[]},{"type":"error","name":"PubkeyStatusUnmatch","inputs":[]},{"type":"error","name":"RateChangeOverLimit","inputs":[]},{"type":"error","name":"SoloNodeDepositAmountZero","inputs":[]},{"type":"error","name":"SoloNodeDepositDisabled","inputs":[]},{"type":"error","name":"SubmitBalancesDisabled","inputs":[]},{"type":"error","name":"TooLow","inputs":[{"type":"uint256","name":"min","internalType":"uint256"}]},{"type":"error","name":"TrustNodeDepositDisabled","inputs":[]},{"type":"error","name":"UnknownClaimType","inputs":[]},{"type":"error","name":"UnknownDistributeType","inputs":[]},{"type":"error","name":"UnknownNodeType","inputs":[]},{"type":"error","name":"UserDepositDisabled","inputs":[]},{"type":"error","name":"VotersDuplicate","inputs":[]},{"type":"error","name":"VotersNotEnough","inputs":[]},{"type":"error","name":"VotersNotExist","inputs":[]},{"type":"error","name":"WithdrawIndexEmpty","inputs":[]},{"type":"event","name":"AdminChanged","inputs":[{"type":"address","name":"previousAdmin","internalType":"address","indexed":false},{"type":"address","name":"newAdmin","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"BeaconUpgraded","inputs":[{"type":"address","name":"beacon","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"Initialized","inputs":[{"type":"uint8","name":"version","internalType":"uint8","indexed":false}],"anonymous":false},{"type":"event","name":"LsdNetwork","inputs":[{"type":"tuple","name":"contracts","internalType":"struct ILsdNetworkFactory.NetworkContracts","indexed":false,"components":[{"type":"address","name":"_feePool","internalType":"address"},{"type":"address","name":"_networkBalances","internalType":"address"},{"type":"address","name":"_networkProposal","internalType":"address"},{"type":"address","name":"_nodeDeposit","internalType":"address"},{"type":"address","name":"_userDeposit","internalType":"address"},{"type":"address","name":"_networkWithdraw","internalType":"address"},{"type":"uint256","name":"_block","internalType":"uint256"}]}],"anonymous":false},{"type":"event","name":"Upgraded","inputs":[{"type":"address","name":"implementation","internalType":"address","indexed":true}],"anonymous":false},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"addAuthorizedLsdToken","inputs":[{"type":"address","name":"_lsdToken","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"addEntrustedLsdToken","inputs":[{"type":"address","name":"_lsdToken","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"addUserToCreationWhitelist","inputs":[{"type":"address","name":"user","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"authorizedLsdToken","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"createLsdNetwork","inputs":[{"type":"string","name":"_lsdTokenName","internalType":"string"},{"type":"string","name":"_lsdTokenSymbol","internalType":"string"},{"type":"address","name":"_networkAdmin","internalType":"address"},{"type":"address[]","name":"_voters","internalType":"address[]"},{"type":"uint256","name":"_threshold","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"createLsdNetworkWithEntrustedVoters","inputs":[{"type":"string","name":"_lsdTokenName","internalType":"string"},{"type":"string","name":"_lsdTokenSymbol","internalType":"string"},{"type":"address","name":"_networkAdmin","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"createLsdNetworkWithLsdToken","inputs":[{"type":"address","name":"_lsdToken","internalType":"address"},{"type":"address","name":"_networkAdmin","internalType":"address"},{"type":"address[]","name":"_voters","internalType":"address[]"},{"type":"uint256","name":"_threshold","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"createLsdNetworkWithTimelock","inputs":[{"type":"string","name":"_lsdTokenName","internalType":"string"},{"type":"string","name":"_lsdTokenSymbol","internalType":"string"},{"type":"address[]","name":"_voters","internalType":"address[]"},{"type":"uint256","name":"_threshold","internalType":"uint256"},{"type":"uint256","name":"_minDelay","internalType":"uint256"},{"type":"address[]","name":"_proposers","internalType":"address[]"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint8","name":"","internalType":"uint8"}],"name":"entrustWithThreshold","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"ethDepositAddress","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"factoryAdmin","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"factoryClaim","inputs":[{"type":"address","name":"_recipient","internalType":"address"},{"type":"uint256","name":"_amount","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"feePoolLogicAddress","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address[]","name":"","internalType":"address[]"}],"name":"getCreationWhitelister","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address[]","name":"","internalType":"address[]"}],"name":"getEntrustWithVoters","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address[]","name":"","internalType":"address[]"}],"name":"getEntrustedLsdTokens","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"init","inputs":[{"type":"address","name":"_factoryAdmin","internalType":"address"},{"type":"address","name":"_ethDepositAddress","internalType":"address"},{"type":"address","name":"_feePoolLogicAddress","internalType":"address"},{"type":"address","name":"_networkBalancesLogicAddress","internalType":"address"},{"type":"address","name":"_networkProposalLogicAddress","internalType":"address"},{"type":"address","name":"_nodeDepositLogicAddress","internalType":"address"},{"type":"address","name":"_userDepositLogicAddress","internalType":"address"},{"type":"address","name":"_networkWithdrawLogicAddress","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address[]","name":"","internalType":"address[]"}],"name":"lsdTokensOfCreater","inputs":[{"type":"address","name":"_creater","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"networkBalancesLogicAddress","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"_feePool","internalType":"address"},{"type":"address","name":"_networkBalances","internalType":"address"},{"type":"address","name":"_networkProposal","internalType":"address"},{"type":"address","name":"_nodeDeposit","internalType":"address"},{"type":"address","name":"_userDeposit","internalType":"address"},{"type":"address","name":"_networkWithdraw","internalType":"address"},{"type":"uint256","name":"_block","internalType":"uint256"}],"name":"networkContractsOfLsdToken","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"networkProposalLogicAddress","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"networkWithdrawLogicAddress","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"nodeDepositLogicAddress","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"onlyCreationWhitelister","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"proxiableUUID","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"reinit","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"removeAuthorizedLsdToken","inputs":[{"type":"address","name":"_lsdToken","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"removeEntrustedLsdToken","inputs":[{"type":"address","name":"_lsdToken","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"removeUserFromCreationWhitelist","inputs":[{"type":"address","name":"user","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setEntrustWithVoters","inputs":[{"type":"address[]","name":"_newVoters","internalType":"address[]"},{"type":"uint256","name":"_threshold","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setNetworkBalancesLogicAddress","inputs":[{"type":"address","name":"_networkBalancesLogicAddress","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setNetworkProposalLogicAddress","inputs":[{"type":"address","name":"_networkProposalLogicAddress","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setNetworkWithdrawLogicAddress","inputs":[{"type":"address","name":"_networkWithdrawLogicAddress","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setNodeDepositLogicAddress","inputs":[{"type":"address","name":"_nodeDepositLogicAddress","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setOnlyCreationWhitelister","inputs":[{"type":"bool","name":"_onlyCreationWhitelister","internalType":"bool"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setUserDepositLogicAddress","inputs":[{"type":"address","name":"_userDepositLogicAddress","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"totalClaimedStackFee","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferAdmin","inputs":[{"type":"address","name":"_newAdmin","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"upgradeTo","inputs":[{"type":"address","name":"newImplementation","internalType":"address"}]},{"type":"function","stateMutability":"payable","outputs":[],"name":"upgradeToAndCall","inputs":[{"type":"address","name":"newImplementation","internalType":"address"},{"type":"bytes","name":"data","internalType":"bytes"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"userDepositLogicAddress","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint8","name":"","internalType":"uint8"}],"name":"version","inputs":[]},{"type":"receive","stateMutability":"payable"}]
Contract Creation Code
0x60a0604052306080523480156200001557600080fd5b506200002062000026565b620000e7565b600054610100900460ff1615620000935760405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b606482015260840160405180910390fd5b60005460ff90811614620000e5576000805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b6080516130cc6200011f6000396000818161095e015281816109a701528181610a9901528181610ad90152610d2701526130cc6000f3fe6080604052600436106102555760003560e01c80638ac0dcd011610139578063bf55c8c6116100b6578063cc6957311161007a578063cc69573114610799578063d99ef5a8146107b9578063db7e2d18146107ce578063f319c30d146107ee578063f5bdfa7e1461080e578063fe9174651461082e57600080fd5b8063bf55c8c61461070f578063c05a6b6f14610724578063c083f1c214610744578063c0c66c3d14610764578063c482ceaf1461078457600080fd5b806398590dfb116100fd57806398590dfb1461067a578063b0bc87e71461069a578063b0ee3ab2146106ba578063b420feb2146106cf578063b4ab7953146106ef57600080fd5b80638ac0dcd0146105da5780638d5c2d42146105fa5780638e96ce621461061a578063920f8f8f1461063a57806393ba45061461065a57600080fd5b8063520430a0116101d25780636dd611a3116101965780636dd611a3146104895780636ec78cc5146104a95780637066986e146104c957806375829def146104e35780637a3ddd321461050357806389e56b801461052357600080fd5b8063520430a0146103ee578063525240c01461040e57806352d1902d1461042e57806354fd4d501461044357806369955d811461046957600080fd5b806330d7338a1161021957806330d7338a1461034b5780633659cfe61461036b57806338b952fa1461038b5780634604cb85146103ab5780634f1ef286146103db57600080fd5b8063100f740d1461026157806315ae831a1461028357806317d8ec7f146102b95780631afb2481146102f75780632255ada11461031b57600080fd5b3661025c57005b600080fd5b34801561026d57600080fd5b5061028161027c366004612755565b610848565b005b34801561028f57600080fd5b506102a361029e366004612755565b61089b565b6040516102b091906127b6565b60405180910390f35b3480156102c557600080fd5b506000546102df906201000090046001600160a01b031681565b6040516001600160a01b0390911681526020016102b0565b34801561030357600080fd5b5061030d60105481565b6040519081526020016102b0565b34801561032757600080fd5b5061033b610336366004612755565b610911565b60405190151581526020016102b0565b34801561035757600080fd5b506006546102df906001600160a01b031681565b34801561037757600080fd5b50610281610386366004612755565b610954565b34801561039757600080fd5b506102816103a6366004612755565b610a3c565b3480156103b757600080fd5b5061033b6103c6366004612755565b600a6020526000908152604090205460ff1681565b6102816103e9366004612868565b610a8f565b3480156103fa57600080fd5b5061033b610409366004612755565b610b5f565b34801561041a57600080fd5b506102816104293660046128cc565b610b9c565b34801561043a57600080fd5b5061030d610d1a565b34801561044f57600080fd5b5060005460ff165b60405160ff90911681526020016102b0565b34801561047557600080fd5b50610281610484366004612975565b610dd2565b34801561049557600080fd5b506102816104a4366004612755565b610e8d565b3480156104b557600080fd5b506102816104c4366004612a4a565b610ee0565b3480156104d557600080fd5b5060115461033b9060ff1681565b3480156104ef57600080fd5b506102816104fe366004612755565b611009565b34801561050f57600080fd5b506004546102df906001600160a01b031681565b34801561052f57600080fd5b5061059061053e366004612755565b60086020526000908152604090208054600182015460028301546003840154600485015460058601546006909601546001600160a01b0395861696948616959384169492841693918216929091169087565b604080516001600160a01b03988916815296881660208801529487169486019490945291851660608501528416608084015290921660a082015260c081019190915260e0016102b0565b3480156105e657600080fd5b506102816105f5366004612755565b61108b565b34801561060657600080fd5b5061033b610615366004612755565b6110dd565b34801561062657600080fd5b506007546102df906001600160a01b031681565b34801561064657600080fd5b50610281610655366004612755565b61111a565b34801561066657600080fd5b506002546102df906001600160a01b031681565b34801561068657600080fd5b50610281610695366004612b09565b61116d565b3480156106a657600080fd5b506102816106b5366004612b84565b6112a4565b3480156106c657600080fd5b506102a361136a565b3480156106db57600080fd5b506001546102df906001600160a01b031681565b3480156106fb57600080fd5b5061028161070a366004612c29565b611376565b34801561071b57600080fd5b506102a36113ba565b34801561073057600080fd5b5061028161073f366004612c4b565b6113c6565b34801561075057600080fd5b5061028161075f366004612755565b611412565b34801561077057600080fd5b506003546102df906001600160a01b031681565b34801561079057600080fd5b50610281611465565b3480156107a557600080fd5b5061033b6107b4366004612755565b6114f4565b3480156107c557600080fd5b506102a3611531565b3480156107da57600080fd5b506005546102df906001600160a01b031681565b3480156107fa57600080fd5b50610281610809366004612cb5565b61153d565b34801561081a57600080fd5b50610281610829366004612755565b61164e565b34801561083a57600080fd5b50600d546104579060ff1681565b6000546201000090046001600160a01b031633146108795760405163015783e960e51b815260040160405180910390fd5b600680546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b03811660009081526009602090815260409182902080548351818402810184019094528084526060939283018282801561090557602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116108e7575b50505050509050919050565b600080546201000090046001600160a01b031633146109435760405163015783e960e51b815260040160405180910390fd5b61094e600e836116a3565b92915050565b6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001630036109a55760405162461bcd60e51b815260040161099c90612d2d565b60405180910390fd5b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166109ee600080516020613050833981519152546001600160a01b031690565b6001600160a01b031614610a145760405162461bcd60e51b815260040161099c90612d79565b610a1d816116bf565b60408051600080825260208201909252610a39918391906116f0565b50565b6000546201000090046001600160a01b03163314610a6d5760405163015783e960e51b815260040160405180910390fd5b600480546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000163003610ad75760405162461bcd60e51b815260040161099c90612d2d565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316610b20600080516020613050833981519152546001600160a01b031690565b6001600160a01b031614610b465760405162461bcd60e51b815260040161099c90612d79565b610b4f826116bf565b610b5b828260016116f0565b5050565b600080546201000090046001600160a01b03163314610b915760405163015783e960e51b815260040160405180910390fd5b61094e6012836116a3565b600054610100900460ff1615808015610bbc5750600054600160ff909116105b80610bd65750303b158015610bd6575060005460ff166001145b610bf25760405162461bcd60e51b815260040161099c90612dc5565b6000805460ff191660011790558015610c15576000805461ff0019166101001790555b6001600160a01b038916610c3c576040516315a9bc2760e11b815260040160405180910390fd5b6000805462010000600160b01b031916620100006001600160a01b038c81169190910291909117909155600180546001600160a01b03199081168b8416179091556002805482168a8416179055600380548216898416179055600480548216888416179055600580548216878416179055600680548216868416179055600780549091169184169190911790558015610d0f576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b505050505050505050565b6000306001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614610dba5760405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c60448201527f6c6564207468726f7567682064656c656761746563616c6c0000000000000000606482015260840161099c565b5060008051602061305083398151915290565b905090565b6000546201000090046001600160a01b03163314610e035760405163015783e960e51b815260040160405180910390fd5b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114610e50576040519150601f19603f3d011682016040523d82523d6000602084013e610e55565b606091505b5050905080610e7757604051635cc4532160e01b815260040160405180910390fd5b81601054610e859190612e29565b601055505050565b6000546201000090046001600160a01b03163314610ebe5760405163015783e960e51b815260040160405180910390fd5b600780546001600160a01b0319166001600160a01b0392909216919091179055565b6000733c5ea15f6e702fcc0351605b867e9ff33e1fd6bf63a9061c62610f04611860565b858586336040518663ffffffff1660e01b8152600401610f28959493929190612e3c565b602060405180830381865af4158015610f45573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f699190612e88565b90506000733c5ea15f6e702fcc0351605b867e9ff33e1fd6bf6311a1363b610f8f611860565b8a8a6040518463ffffffff1660e01b8152600401610faf93929190612ef5565b602060405180830381865af4158015610fcc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ff09190612e88565b9050610fff81838489896118a2565b5050505050505050565b6000546201000090046001600160a01b0316331461103a5760405163015783e960e51b815260040160405180910390fd5b6001600160a01b038116611061576040516315a9bc2760e11b815260040160405180910390fd5b600080546001600160a01b03909216620100000262010000600160b01b0319909216919091179055565b6000546201000090046001600160a01b031633146110bc5760405163015783e960e51b815260040160405180910390fd5b6001600160a01b03166000908152600a60205260409020805460ff19169055565b600080546201000090046001600160a01b0316331461110f5760405163015783e960e51b815260040160405180910390fd5b61094e600e836120ba565b6000546201000090046001600160a01b0316331461114b5760405163015783e960e51b815260040160405180910390fd5b600580546001600160a01b0319166001600160a01b0392909216919091179055565b6000546201000090046001600160a01b0316331461119e5760405163015783e960e51b815260040160405180910390fd5b808210806111b657506111b2600283612f20565b8111155b156111d45760405163aabd5a0960e01b815260040160405180910390fd5b60006111e0600b6120cf565b905060005b81811015611215576112046111fc600b60006120d9565b600b906116a3565b5061120e81612f42565b90506111e5565b5060005b838110156112805761125385858381811061123657611236612f5b565b905060200201602081019061124b9190612755565b600b906120ba565b6112705760405163790d2f3f60e01b815260040160405180910390fd5b61127981612f42565b9050611219565b5061128a826120e5565b600d805460ff191660ff9290921691909117905550505050565b6000733c5ea15f6e702fcc0351605b867e9ff33e1fd6bf6311a1363b6112c8611860565b88886040518463ffffffff1660e01b81526004016112e893929190612ef5565b602060405180830381865af4158015611305573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113299190612e88565b90506001600160a01b038416600003611355576040516315a9bc2760e11b815260040160405180910390fd5b61136281858686866118a2565b505050505050565b6060610dcd601261214a565b6000546201000090046001600160a01b031633146113a75760405163015783e960e51b815260040160405180910390fd5b6011805460ff1916911515919091179055565b6060610dcd600e61214a565b6001600160a01b0384166000908152600a602052604090205460ff166113ff576040516356c7dbe560e01b815260040160405180910390fd5b61140c84848585856118a2565b50505050565b6000546201000090046001600160a01b031633146114435760405163015783e960e51b815260040160405180910390fd5b600380546001600160a01b0319166001600160a01b0392909216919091179055565b600054600190610100900460ff16158015611487575060005460ff8083169116105b6114a35760405162461bcd60e51b815260040161099c90612dc5565b6000805461ffff191660ff83169081176101001761ff00191690915560408051918252517f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989181900360200190a150565b600080546201000090046001600160a01b031633146115265760405163015783e960e51b815260040160405180910390fd5b61094e6012836120ba565b6060610dcd600b61214a565b600d5460ff16600003611563576040516361c797b760e01b815260040160405180910390fd5b6001600160a01b03811660000361158d576040516315a9bc2760e11b815260040160405180910390fd5b6000733c5ea15f6e702fcc0351605b867e9ff33e1fd6bf6311a1363b6115b1611860565b86866040518463ffffffff1660e01b81526004016115d193929190612ef5565b602060405180830381865af41580156115ee573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116129190612e88565b905061161f600e826120ba565b5061140c8183600060029054906101000a90046001600160a01b0316611643611531565b600d5460ff166118a2565b6000546201000090046001600160a01b0316331461167f5760405163015783e960e51b815260040160405180910390fd5b6001600160a01b03166000908152600a60205260409020805460ff19166001179055565b60006116b8836001600160a01b038416612157565b9392505050565b6000546201000090046001600160a01b03163314610a395760405163015783e960e51b815260040160405180910390fd5b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff1615611728576117238361224a565b505050565b826001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015611782575060408051601f3d908101601f1916820190925261177f91810190612f71565b60015b6117e55760405162461bcd60e51b815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201526d6f6e206973206e6f74205555505360901b606482015260840161099c565b60008051602061305083398151915281146118545760405162461bcd60e51b815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f786044820152681a58589b195555525160ba1b606482015260840161099c565b506117238383836122e6565b6040516bffffffffffffffffffffffff193360601b16602082015243603482015260009060540160405160208183030381529060405280519060200120905090565b60115460ff1680156118bc57506118ba60123361230b565b155b156118da5760405163015783e960e51b815260040160405180910390fd5b60006118e461232d565b6001600160a01b0387166000908152600860205260409020600601549091501561192157604051631f37a9c360e31b815260040160405180910390fd5b6001600160a01b038681166000818152600860209081526040808320865181549087166001600160a01b03199182161782558784015160018084018054928a169284169290921790915588840151600284018054918a169184169190911790556060890151600384018054918a16918416919091179055608089018051600485018054918b1691851691909117905560a08a0151600585018054918b1691851691909117905560c08a015160069094019390935533865260098552838620805491820181558652848620018054909116861790555181519516602480870191909152815180870390910181526044909501815290840180516001600160e01b0316630bcf420560e21b179052519092839291611a3d9190612f8a565b6000604051808303816000865af19150503d8060008114611a7a576040519150601f19603f3d011682016040523d82523d6000602084013e611a7f565b606091505b509150915081611aa257604051635cc4532160e01b815260040160405180910390fd5b825160a084015160408086015181516001600160a01b03938416602482015290831660448083019190915282518083039091018152606490910182526020810180516001600160e01b031663784d200b60e11b17905290519190921691611b0891612f8a565b6000604051808303816000865af19150503d8060008114611b45576040519150601f19603f3d011682016040523d82523d6000602084013e611b4a565b606091505b50909250905081611b6e57604051635cc4532160e01b815260040160405180910390fd5b60208381015160408086015181516001600160a01b03918216602480830191909152835180830390910181526044909101835293840180516001600160e01b031663066ad14f60e21b1790529051911691611bc891612f8a565b6000604051808303816000865af19150503d8060008114611c05576040519150601f19603f3d011682016040523d82523d6000602084013e611c0a565b606091505b50909250905081611c2e57604051635cc4532160e01b815260040160405180910390fd5b82604001516001600160a01b0316636d844b5c60e01b86868a8a604051602401611c5b9493929190612fa6565b60408051601f198184030181529181526020820180516001600160e01b03166001600160e01b0319909416939093179092529051611c999190612f8a565b6000604051808303816000865af19150503d8060008114611cd6576040519150601f19603f3d011682016040523d82523d6000602084013e611cdb565b606091505b50909250905081611cff57604051635cc4532160e01b815260040160405180910390fd5b606083810151608085015160015460408088015160a08901518251600160f81b602082015260006021820152961b6bffffffffffffffffffffffff1916602c8701526001600160a01b039485169563dfdfbd0b60e01b959093169290910160408051601f1981840301815290829052611d7d94939291602401612fdf565b60408051601f198184030181529181526020820180516001600160e01b03166001600160e01b0319909416939093179092529051611dbb9190612f8a565b6000604051808303816000865af19150503d8060008114611df8576040519150601f19603f3d011682016040523d82523d6000602084013e611dfd565b606091505b50909250905081611e2157604051635cc4532160e01b815260040160405180910390fd5b6080830151606084015160a0850151604080870151602088015191516001600160a01b038e811660248301529485166044820152928416606484015283166084830152821660a482015291169063359ef75b60e01b9060c40160408051601f198184030181529181526020820180516001600160e01b03166001600160e01b0319909416939093179092529051611eb89190612f8a565b6000604051808303816000865af19150503d8060008114611ef5576040519150601f19603f3d011682016040523d82523d6000602084013e611efa565b606091505b50909250905081611f1e57604051635cc4532160e01b815260040160405180910390fd5b60a083015160808401516040808601516020870151875192516001600160a01b038e81166024830152948516604482015291841660648301528316608482015290821660a48201523060c48201529116906399e133f960e01b9060e40160408051601f198184030181529181526020820180516001600160e01b03166001600160e01b0319909416939093179092529051611fb99190612f8a565b6000604051808303816000865af19150503d8060008114611ff6576040519150601f19603f3d011682016040523d82523d6000602084013e611ffb565b606091505b5090925090508161201f57604051635cc4532160e01b815260040160405180910390fd5b7ff7cbb1cf6eca48c0113b14a7641681a2d00da8b555b0057a823450d08874b048836040516120a8919081516001600160a01b03908116825260208084015182169083015260408084015182169083015260608084015182169083015260808084015182169083015260a0838101519091169082015260c0918201519181019190915260e00190565b60405180910390a15050505050505050565b60006116b8836001600160a01b038416612451565b600061094e825490565b60006116b883836124a0565b600060ff8211156121465760405162461bcd60e51b815260206004820152602560248201527f53616665436173743a2076616c756520646f65736e27742066697420696e2038604482015264206269747360d81b606482015260840161099c565b5090565b606060006116b8836124ca565b6000818152600183016020526040812054801561224057600061217b600183613013565b855490915060009061218f90600190613013565b90508181146121f45760008660000182815481106121af576121af612f5b565b90600052602060002001549050808760000184815481106121d2576121d2612f5b565b6000918252602080832090910192909255918252600188019052604090208390555b855486908061220557612205613026565b60019003818190600052602060002001600090559055856001016000868152602001908152602001600020600090556001935050505061094e565b600091505061094e565b6001600160a01b0381163b6122b75760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b606482015260840161099c565b60008051602061305083398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b6122ef83612525565b6000825111806122fc5750805b156117235761140c8383612565565b6001600160a01b038116600090815260018301602052604081205415156116b8565b6040805160e081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c081019190915260025460009061237e906001600160a01b031661258a565b600354909150600090612399906001600160a01b031661258a565b6004549091506000906123b4906001600160a01b031661258a565b6005549091506000906123cf906001600160a01b031661258a565b6006549091506000906123ea906001600160a01b031661258a565b600754909150600090612405906001600160a01b031661258a565b6040805160e0810182526001600160a01b0398891681529688166020880152948716948601949094525090841660608401528316608083015290911660a08201524360c0820152919050565b60008181526001830160205260408120546124985750815460018181018455600084815260208082209093018490558454848252828601909352604090209190915561094e565b50600061094e565b60008260000182815481106124b7576124b7612f5b565b9060005260206000200154905092915050565b60608160000180548060200260200160405190810160405280929190818152602001828054801561090557602002820191906000526020600020905b8154815260200190600101908083116125065750505050509050919050565b61252e8161224a565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606116b883836040518060600160405280602781526020016130706027913961261d565b6000733c5ea15f6e702fcc0351605b867e9ff33e1fd6bf6394137bef6125ae611860565b6040516001600160e01b031960e084901b16815260048101919091526001600160a01b0385166024820152604401602060405180830381865af41580156125f9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061094e9190612e88565b6060600080856001600160a01b03168560405161263a9190612f8a565b600060405180830381855af49150503d8060008114612675576040519150601f19603f3d011682016040523d82523d6000602084013e61267a565b606091505b509150915061268b86838387612695565b9695505050505050565b606083156127045782516000036126fd576001600160a01b0385163b6126fd5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161099c565b508161270e565b61270e8383612716565b949350505050565b8151156127265781518083602001fd5b8060405162461bcd60e51b815260040161099c919061303c565b6001600160a01b0381168114610a3957600080fd5b60006020828403121561276757600080fd5b81356116b881612740565b600081518084526020808501945080840160005b838110156127ab5781516001600160a01b031687529582019590820190600101612786565b509495945050505050565b6020815260006116b86020830184612772565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715612808576128086127c9565b604052919050565b600067ffffffffffffffff83111561282a5761282a6127c9565b61283d601f8401601f19166020016127df565b905082815283838301111561285157600080fd5b828260208301376000602084830101529392505050565b6000806040838503121561287b57600080fd5b823561288681612740565b9150602083013567ffffffffffffffff8111156128a257600080fd5b8301601f810185136128b357600080fd5b6128c285823560208401612810565b9150509250929050565b600080600080600080600080610100898b0312156128e957600080fd5b88356128f481612740565b9750602089013561290481612740565b9650604089013561291481612740565b9550606089013561292481612740565b9450608089013561293481612740565b935060a089013561294481612740565b925060c089013561295481612740565b915060e089013561296481612740565b809150509295985092959890939650565b6000806040838503121561298857600080fd5b823561299381612740565b946020939093013593505050565b600082601f8301126129b257600080fd5b6116b883833560208501612810565b600082601f8301126129d257600080fd5b8135602067ffffffffffffffff8211156129ee576129ee6127c9565b8160051b6129fd8282016127df565b9283528481018201928281019087851115612a1757600080fd5b83870192505b84831015612a3f578235612a3081612740565b82529183019190830190612a1d565b979650505050505050565b60008060008060008060c08789031215612a6357600080fd5b863567ffffffffffffffff80821115612a7b57600080fd5b612a878a838b016129a1565b97506020890135915080821115612a9d57600080fd5b612aa98a838b016129a1565b96506040890135915080821115612abf57600080fd5b612acb8a838b016129c1565b9550606089013594506080890135935060a0890135915080821115612aef57600080fd5b50612afc89828a016129c1565b9150509295509295509295565b600080600060408486031215612b1e57600080fd5b833567ffffffffffffffff80821115612b3657600080fd5b818601915086601f830112612b4a57600080fd5b813581811115612b5957600080fd5b8760208260051b8501011115612b6e57600080fd5b6020928301989097509590910135949350505050565b600080600080600060a08688031215612b9c57600080fd5b853567ffffffffffffffff80821115612bb457600080fd5b612bc089838a016129a1565b96506020880135915080821115612bd657600080fd5b612be289838a016129a1565b955060408801359150612bf482612740565b90935060608701359080821115612c0a57600080fd5b50612c17888289016129c1565b95989497509295608001359392505050565b600060208284031215612c3b57600080fd5b813580151581146116b857600080fd5b60008060008060808587031215612c6157600080fd5b8435612c6c81612740565b93506020850135612c7c81612740565b9250604085013567ffffffffffffffff811115612c9857600080fd5b612ca4878288016129c1565b949793965093946060013593505050565b600080600060608486031215612cca57600080fd5b833567ffffffffffffffff80821115612ce257600080fd5b612cee878388016129a1565b94506020860135915080821115612d0457600080fd5b50612d11868287016129a1565b9250506040840135612d2281612740565b809150509250925092565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b19195b1959d85d1958d85b1b60a21b606082015260800190565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b6163746976652070726f787960a01b606082015260800190565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b634e487b7160e01b600052601160045260246000fd5b8082018082111561094e5761094e612e13565b85815284602082015260a060408201526000612e5b60a0830186612772565b8281036060840152612e6d8186612772565b91505060018060a01b03831660808301529695505050505050565b600060208284031215612e9a57600080fd5b81516116b881612740565b60005b83811015612ec0578181015183820152602001612ea8565b50506000910152565b60008151808452612ee1816020860160208601612ea5565b601f01601f19169290920160200192915050565b838152606060208201526000612f0e6060830185612ec9565b828103604084015261268b8185612ec9565b600082612f3d57634e487b7160e01b600052601260045260246000fd5b500490565b600060018201612f5457612f54612e13565b5060010190565b634e487b7160e01b600052603260045260246000fd5b600060208284031215612f8357600080fd5b5051919050565b60008251612f9c818460208701612ea5565b9190910192915050565b608081526000612fb96080830187612772565b6020830195909552506001600160a01b0392831660408201529116606090910152919050565b6001600160a01b03858116825284811660208301528316604082015260806060820181905260009061268b90830184612ec9565b8181038181111561094e5761094e612e13565b634e487b7160e01b600052603160045260246000fd5b6020815260006116b86020830184612ec956fe360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a264697066735822122030cc5c3e5c58f8fa4f400ca0b9af02f1dc775b86acd05f35af3cdbef6a10786664736f6c63430008130033
Deployed ByteCode
0x6080604052600436106102555760003560e01c80638ac0dcd011610139578063bf55c8c6116100b6578063cc6957311161007a578063cc69573114610799578063d99ef5a8146107b9578063db7e2d18146107ce578063f319c30d146107ee578063f5bdfa7e1461080e578063fe9174651461082e57600080fd5b8063bf55c8c61461070f578063c05a6b6f14610724578063c083f1c214610744578063c0c66c3d14610764578063c482ceaf1461078457600080fd5b806398590dfb116100fd57806398590dfb1461067a578063b0bc87e71461069a578063b0ee3ab2146106ba578063b420feb2146106cf578063b4ab7953146106ef57600080fd5b80638ac0dcd0146105da5780638d5c2d42146105fa5780638e96ce621461061a578063920f8f8f1461063a57806393ba45061461065a57600080fd5b8063520430a0116101d25780636dd611a3116101965780636dd611a3146104895780636ec78cc5146104a95780637066986e146104c957806375829def146104e35780637a3ddd321461050357806389e56b801461052357600080fd5b8063520430a0146103ee578063525240c01461040e57806352d1902d1461042e57806354fd4d501461044357806369955d811461046957600080fd5b806330d7338a1161021957806330d7338a1461034b5780633659cfe61461036b57806338b952fa1461038b5780634604cb85146103ab5780634f1ef286146103db57600080fd5b8063100f740d1461026157806315ae831a1461028357806317d8ec7f146102b95780631afb2481146102f75780632255ada11461031b57600080fd5b3661025c57005b600080fd5b34801561026d57600080fd5b5061028161027c366004612755565b610848565b005b34801561028f57600080fd5b506102a361029e366004612755565b61089b565b6040516102b091906127b6565b60405180910390f35b3480156102c557600080fd5b506000546102df906201000090046001600160a01b031681565b6040516001600160a01b0390911681526020016102b0565b34801561030357600080fd5b5061030d60105481565b6040519081526020016102b0565b34801561032757600080fd5b5061033b610336366004612755565b610911565b60405190151581526020016102b0565b34801561035757600080fd5b506006546102df906001600160a01b031681565b34801561037757600080fd5b50610281610386366004612755565b610954565b34801561039757600080fd5b506102816103a6366004612755565b610a3c565b3480156103b757600080fd5b5061033b6103c6366004612755565b600a6020526000908152604090205460ff1681565b6102816103e9366004612868565b610a8f565b3480156103fa57600080fd5b5061033b610409366004612755565b610b5f565b34801561041a57600080fd5b506102816104293660046128cc565b610b9c565b34801561043a57600080fd5b5061030d610d1a565b34801561044f57600080fd5b5060005460ff165b60405160ff90911681526020016102b0565b34801561047557600080fd5b50610281610484366004612975565b610dd2565b34801561049557600080fd5b506102816104a4366004612755565b610e8d565b3480156104b557600080fd5b506102816104c4366004612a4a565b610ee0565b3480156104d557600080fd5b5060115461033b9060ff1681565b3480156104ef57600080fd5b506102816104fe366004612755565b611009565b34801561050f57600080fd5b506004546102df906001600160a01b031681565b34801561052f57600080fd5b5061059061053e366004612755565b60086020526000908152604090208054600182015460028301546003840154600485015460058601546006909601546001600160a01b0395861696948616959384169492841693918216929091169087565b604080516001600160a01b03988916815296881660208801529487169486019490945291851660608501528416608084015290921660a082015260c081019190915260e0016102b0565b3480156105e657600080fd5b506102816105f5366004612755565b61108b565b34801561060657600080fd5b5061033b610615366004612755565b6110dd565b34801561062657600080fd5b506007546102df906001600160a01b031681565b34801561064657600080fd5b50610281610655366004612755565b61111a565b34801561066657600080fd5b506002546102df906001600160a01b031681565b34801561068657600080fd5b50610281610695366004612b09565b61116d565b3480156106a657600080fd5b506102816106b5366004612b84565b6112a4565b3480156106c657600080fd5b506102a361136a565b3480156106db57600080fd5b506001546102df906001600160a01b031681565b3480156106fb57600080fd5b5061028161070a366004612c29565b611376565b34801561071b57600080fd5b506102a36113ba565b34801561073057600080fd5b5061028161073f366004612c4b565b6113c6565b34801561075057600080fd5b5061028161075f366004612755565b611412565b34801561077057600080fd5b506003546102df906001600160a01b031681565b34801561079057600080fd5b50610281611465565b3480156107a557600080fd5b5061033b6107b4366004612755565b6114f4565b3480156107c557600080fd5b506102a3611531565b3480156107da57600080fd5b506005546102df906001600160a01b031681565b3480156107fa57600080fd5b50610281610809366004612cb5565b61153d565b34801561081a57600080fd5b50610281610829366004612755565b61164e565b34801561083a57600080fd5b50600d546104579060ff1681565b6000546201000090046001600160a01b031633146108795760405163015783e960e51b815260040160405180910390fd5b600680546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b03811660009081526009602090815260409182902080548351818402810184019094528084526060939283018282801561090557602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116108e7575b50505050509050919050565b600080546201000090046001600160a01b031633146109435760405163015783e960e51b815260040160405180910390fd5b61094e600e836116a3565b92915050565b6001600160a01b037f000000000000000000000000e27df917b7557f0b427c768e90819d1e6db70f1e1630036109a55760405162461bcd60e51b815260040161099c90612d2d565b60405180910390fd5b7f000000000000000000000000e27df917b7557f0b427c768e90819d1e6db70f1e6001600160a01b03166109ee600080516020613050833981519152546001600160a01b031690565b6001600160a01b031614610a145760405162461bcd60e51b815260040161099c90612d79565b610a1d816116bf565b60408051600080825260208201909252610a39918391906116f0565b50565b6000546201000090046001600160a01b03163314610a6d5760405163015783e960e51b815260040160405180910390fd5b600480546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b037f000000000000000000000000e27df917b7557f0b427c768e90819d1e6db70f1e163003610ad75760405162461bcd60e51b815260040161099c90612d2d565b7f000000000000000000000000e27df917b7557f0b427c768e90819d1e6db70f1e6001600160a01b0316610b20600080516020613050833981519152546001600160a01b031690565b6001600160a01b031614610b465760405162461bcd60e51b815260040161099c90612d79565b610b4f826116bf565b610b5b828260016116f0565b5050565b600080546201000090046001600160a01b03163314610b915760405163015783e960e51b815260040160405180910390fd5b61094e6012836116a3565b600054610100900460ff1615808015610bbc5750600054600160ff909116105b80610bd65750303b158015610bd6575060005460ff166001145b610bf25760405162461bcd60e51b815260040161099c90612dc5565b6000805460ff191660011790558015610c15576000805461ff0019166101001790555b6001600160a01b038916610c3c576040516315a9bc2760e11b815260040160405180910390fd5b6000805462010000600160b01b031916620100006001600160a01b038c81169190910291909117909155600180546001600160a01b03199081168b8416179091556002805482168a8416179055600380548216898416179055600480548216888416179055600580548216878416179055600680548216868416179055600780549091169184169190911790558015610d0f576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b505050505050505050565b6000306001600160a01b037f000000000000000000000000e27df917b7557f0b427c768e90819d1e6db70f1e1614610dba5760405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c60448201527f6c6564207468726f7567682064656c656761746563616c6c0000000000000000606482015260840161099c565b5060008051602061305083398151915290565b905090565b6000546201000090046001600160a01b03163314610e035760405163015783e960e51b815260040160405180910390fd5b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114610e50576040519150601f19603f3d011682016040523d82523d6000602084013e610e55565b606091505b5050905080610e7757604051635cc4532160e01b815260040160405180910390fd5b81601054610e859190612e29565b601055505050565b6000546201000090046001600160a01b03163314610ebe5760405163015783e960e51b815260040160405180910390fd5b600780546001600160a01b0319166001600160a01b0392909216919091179055565b6000733c5ea15f6e702fcc0351605b867e9ff33e1fd6bf63a9061c62610f04611860565b858586336040518663ffffffff1660e01b8152600401610f28959493929190612e3c565b602060405180830381865af4158015610f45573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f699190612e88565b90506000733c5ea15f6e702fcc0351605b867e9ff33e1fd6bf6311a1363b610f8f611860565b8a8a6040518463ffffffff1660e01b8152600401610faf93929190612ef5565b602060405180830381865af4158015610fcc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ff09190612e88565b9050610fff81838489896118a2565b5050505050505050565b6000546201000090046001600160a01b0316331461103a5760405163015783e960e51b815260040160405180910390fd5b6001600160a01b038116611061576040516315a9bc2760e11b815260040160405180910390fd5b600080546001600160a01b03909216620100000262010000600160b01b0319909216919091179055565b6000546201000090046001600160a01b031633146110bc5760405163015783e960e51b815260040160405180910390fd5b6001600160a01b03166000908152600a60205260409020805460ff19169055565b600080546201000090046001600160a01b0316331461110f5760405163015783e960e51b815260040160405180910390fd5b61094e600e836120ba565b6000546201000090046001600160a01b0316331461114b5760405163015783e960e51b815260040160405180910390fd5b600580546001600160a01b0319166001600160a01b0392909216919091179055565b6000546201000090046001600160a01b0316331461119e5760405163015783e960e51b815260040160405180910390fd5b808210806111b657506111b2600283612f20565b8111155b156111d45760405163aabd5a0960e01b815260040160405180910390fd5b60006111e0600b6120cf565b905060005b81811015611215576112046111fc600b60006120d9565b600b906116a3565b5061120e81612f42565b90506111e5565b5060005b838110156112805761125385858381811061123657611236612f5b565b905060200201602081019061124b9190612755565b600b906120ba565b6112705760405163790d2f3f60e01b815260040160405180910390fd5b61127981612f42565b9050611219565b5061128a826120e5565b600d805460ff191660ff9290921691909117905550505050565b6000733c5ea15f6e702fcc0351605b867e9ff33e1fd6bf6311a1363b6112c8611860565b88886040518463ffffffff1660e01b81526004016112e893929190612ef5565b602060405180830381865af4158015611305573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113299190612e88565b90506001600160a01b038416600003611355576040516315a9bc2760e11b815260040160405180910390fd5b61136281858686866118a2565b505050505050565b6060610dcd601261214a565b6000546201000090046001600160a01b031633146113a75760405163015783e960e51b815260040160405180910390fd5b6011805460ff1916911515919091179055565b6060610dcd600e61214a565b6001600160a01b0384166000908152600a602052604090205460ff166113ff576040516356c7dbe560e01b815260040160405180910390fd5b61140c84848585856118a2565b50505050565b6000546201000090046001600160a01b031633146114435760405163015783e960e51b815260040160405180910390fd5b600380546001600160a01b0319166001600160a01b0392909216919091179055565b600054600190610100900460ff16158015611487575060005460ff8083169116105b6114a35760405162461bcd60e51b815260040161099c90612dc5565b6000805461ffff191660ff83169081176101001761ff00191690915560408051918252517f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989181900360200190a150565b600080546201000090046001600160a01b031633146115265760405163015783e960e51b815260040160405180910390fd5b61094e6012836120ba565b6060610dcd600b61214a565b600d5460ff16600003611563576040516361c797b760e01b815260040160405180910390fd5b6001600160a01b03811660000361158d576040516315a9bc2760e11b815260040160405180910390fd5b6000733c5ea15f6e702fcc0351605b867e9ff33e1fd6bf6311a1363b6115b1611860565b86866040518463ffffffff1660e01b81526004016115d193929190612ef5565b602060405180830381865af41580156115ee573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116129190612e88565b905061161f600e826120ba565b5061140c8183600060029054906101000a90046001600160a01b0316611643611531565b600d5460ff166118a2565b6000546201000090046001600160a01b0316331461167f5760405163015783e960e51b815260040160405180910390fd5b6001600160a01b03166000908152600a60205260409020805460ff19166001179055565b60006116b8836001600160a01b038416612157565b9392505050565b6000546201000090046001600160a01b03163314610a395760405163015783e960e51b815260040160405180910390fd5b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff1615611728576117238361224a565b505050565b826001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015611782575060408051601f3d908101601f1916820190925261177f91810190612f71565b60015b6117e55760405162461bcd60e51b815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201526d6f6e206973206e6f74205555505360901b606482015260840161099c565b60008051602061305083398151915281146118545760405162461bcd60e51b815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f786044820152681a58589b195555525160ba1b606482015260840161099c565b506117238383836122e6565b6040516bffffffffffffffffffffffff193360601b16602082015243603482015260009060540160405160208183030381529060405280519060200120905090565b60115460ff1680156118bc57506118ba60123361230b565b155b156118da5760405163015783e960e51b815260040160405180910390fd5b60006118e461232d565b6001600160a01b0387166000908152600860205260409020600601549091501561192157604051631f37a9c360e31b815260040160405180910390fd5b6001600160a01b038681166000818152600860209081526040808320865181549087166001600160a01b03199182161782558784015160018084018054928a169284169290921790915588840151600284018054918a169184169190911790556060890151600384018054918a16918416919091179055608089018051600485018054918b1691851691909117905560a08a0151600585018054918b1691851691909117905560c08a015160069094019390935533865260098552838620805491820181558652848620018054909116861790555181519516602480870191909152815180870390910181526044909501815290840180516001600160e01b0316630bcf420560e21b179052519092839291611a3d9190612f8a565b6000604051808303816000865af19150503d8060008114611a7a576040519150601f19603f3d011682016040523d82523d6000602084013e611a7f565b606091505b509150915081611aa257604051635cc4532160e01b815260040160405180910390fd5b825160a084015160408086015181516001600160a01b03938416602482015290831660448083019190915282518083039091018152606490910182526020810180516001600160e01b031663784d200b60e11b17905290519190921691611b0891612f8a565b6000604051808303816000865af19150503d8060008114611b45576040519150601f19603f3d011682016040523d82523d6000602084013e611b4a565b606091505b50909250905081611b6e57604051635cc4532160e01b815260040160405180910390fd5b60208381015160408086015181516001600160a01b03918216602480830191909152835180830390910181526044909101835293840180516001600160e01b031663066ad14f60e21b1790529051911691611bc891612f8a565b6000604051808303816000865af19150503d8060008114611c05576040519150601f19603f3d011682016040523d82523d6000602084013e611c0a565b606091505b50909250905081611c2e57604051635cc4532160e01b815260040160405180910390fd5b82604001516001600160a01b0316636d844b5c60e01b86868a8a604051602401611c5b9493929190612fa6565b60408051601f198184030181529181526020820180516001600160e01b03166001600160e01b0319909416939093179092529051611c999190612f8a565b6000604051808303816000865af19150503d8060008114611cd6576040519150601f19603f3d011682016040523d82523d6000602084013e611cdb565b606091505b50909250905081611cff57604051635cc4532160e01b815260040160405180910390fd5b606083810151608085015160015460408088015160a08901518251600160f81b602082015260006021820152961b6bffffffffffffffffffffffff1916602c8701526001600160a01b039485169563dfdfbd0b60e01b959093169290910160408051601f1981840301815290829052611d7d94939291602401612fdf565b60408051601f198184030181529181526020820180516001600160e01b03166001600160e01b0319909416939093179092529051611dbb9190612f8a565b6000604051808303816000865af19150503d8060008114611df8576040519150601f19603f3d011682016040523d82523d6000602084013e611dfd565b606091505b50909250905081611e2157604051635cc4532160e01b815260040160405180910390fd5b6080830151606084015160a0850151604080870151602088015191516001600160a01b038e811660248301529485166044820152928416606484015283166084830152821660a482015291169063359ef75b60e01b9060c40160408051601f198184030181529181526020820180516001600160e01b03166001600160e01b0319909416939093179092529051611eb89190612f8a565b6000604051808303816000865af19150503d8060008114611ef5576040519150601f19603f3d011682016040523d82523d6000602084013e611efa565b606091505b50909250905081611f1e57604051635cc4532160e01b815260040160405180910390fd5b60a083015160808401516040808601516020870151875192516001600160a01b038e81166024830152948516604482015291841660648301528316608482015290821660a48201523060c48201529116906399e133f960e01b9060e40160408051601f198184030181529181526020820180516001600160e01b03166001600160e01b0319909416939093179092529051611fb99190612f8a565b6000604051808303816000865af19150503d8060008114611ff6576040519150601f19603f3d011682016040523d82523d6000602084013e611ffb565b606091505b5090925090508161201f57604051635cc4532160e01b815260040160405180910390fd5b7ff7cbb1cf6eca48c0113b14a7641681a2d00da8b555b0057a823450d08874b048836040516120a8919081516001600160a01b03908116825260208084015182169083015260408084015182169083015260608084015182169083015260808084015182169083015260a0838101519091169082015260c0918201519181019190915260e00190565b60405180910390a15050505050505050565b60006116b8836001600160a01b038416612451565b600061094e825490565b60006116b883836124a0565b600060ff8211156121465760405162461bcd60e51b815260206004820152602560248201527f53616665436173743a2076616c756520646f65736e27742066697420696e2038604482015264206269747360d81b606482015260840161099c565b5090565b606060006116b8836124ca565b6000818152600183016020526040812054801561224057600061217b600183613013565b855490915060009061218f90600190613013565b90508181146121f45760008660000182815481106121af576121af612f5b565b90600052602060002001549050808760000184815481106121d2576121d2612f5b565b6000918252602080832090910192909255918252600188019052604090208390555b855486908061220557612205613026565b60019003818190600052602060002001600090559055856001016000868152602001908152602001600020600090556001935050505061094e565b600091505061094e565b6001600160a01b0381163b6122b75760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b606482015260840161099c565b60008051602061305083398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b6122ef83612525565b6000825111806122fc5750805b156117235761140c8383612565565b6001600160a01b038116600090815260018301602052604081205415156116b8565b6040805160e081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c081019190915260025460009061237e906001600160a01b031661258a565b600354909150600090612399906001600160a01b031661258a565b6004549091506000906123b4906001600160a01b031661258a565b6005549091506000906123cf906001600160a01b031661258a565b6006549091506000906123ea906001600160a01b031661258a565b600754909150600090612405906001600160a01b031661258a565b6040805160e0810182526001600160a01b0398891681529688166020880152948716948601949094525090841660608401528316608083015290911660a08201524360c0820152919050565b60008181526001830160205260408120546124985750815460018181018455600084815260208082209093018490558454848252828601909352604090209190915561094e565b50600061094e565b60008260000182815481106124b7576124b7612f5b565b9060005260206000200154905092915050565b60608160000180548060200260200160405190810160405280929190818152602001828054801561090557602002820191906000526020600020905b8154815260200190600101908083116125065750505050509050919050565b61252e8161224a565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606116b883836040518060600160405280602781526020016130706027913961261d565b6000733c5ea15f6e702fcc0351605b867e9ff33e1fd6bf6394137bef6125ae611860565b6040516001600160e01b031960e084901b16815260048101919091526001600160a01b0385166024820152604401602060405180830381865af41580156125f9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061094e9190612e88565b6060600080856001600160a01b03168560405161263a9190612f8a565b600060405180830381855af49150503d8060008114612675576040519150601f19603f3d011682016040523d82523d6000602084013e61267a565b606091505b509150915061268b86838387612695565b9695505050505050565b606083156127045782516000036126fd576001600160a01b0385163b6126fd5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161099c565b508161270e565b61270e8383612716565b949350505050565b8151156127265781518083602001fd5b8060405162461bcd60e51b815260040161099c919061303c565b6001600160a01b0381168114610a3957600080fd5b60006020828403121561276757600080fd5b81356116b881612740565b600081518084526020808501945080840160005b838110156127ab5781516001600160a01b031687529582019590820190600101612786565b509495945050505050565b6020815260006116b86020830184612772565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715612808576128086127c9565b604052919050565b600067ffffffffffffffff83111561282a5761282a6127c9565b61283d601f8401601f19166020016127df565b905082815283838301111561285157600080fd5b828260208301376000602084830101529392505050565b6000806040838503121561287b57600080fd5b823561288681612740565b9150602083013567ffffffffffffffff8111156128a257600080fd5b8301601f810185136128b357600080fd5b6128c285823560208401612810565b9150509250929050565b600080600080600080600080610100898b0312156128e957600080fd5b88356128f481612740565b9750602089013561290481612740565b9650604089013561291481612740565b9550606089013561292481612740565b9450608089013561293481612740565b935060a089013561294481612740565b925060c089013561295481612740565b915060e089013561296481612740565b809150509295985092959890939650565b6000806040838503121561298857600080fd5b823561299381612740565b946020939093013593505050565b600082601f8301126129b257600080fd5b6116b883833560208501612810565b600082601f8301126129d257600080fd5b8135602067ffffffffffffffff8211156129ee576129ee6127c9565b8160051b6129fd8282016127df565b9283528481018201928281019087851115612a1757600080fd5b83870192505b84831015612a3f578235612a3081612740565b82529183019190830190612a1d565b979650505050505050565b60008060008060008060c08789031215612a6357600080fd5b863567ffffffffffffffff80821115612a7b57600080fd5b612a878a838b016129a1565b97506020890135915080821115612a9d57600080fd5b612aa98a838b016129a1565b96506040890135915080821115612abf57600080fd5b612acb8a838b016129c1565b9550606089013594506080890135935060a0890135915080821115612aef57600080fd5b50612afc89828a016129c1565b9150509295509295509295565b600080600060408486031215612b1e57600080fd5b833567ffffffffffffffff80821115612b3657600080fd5b818601915086601f830112612b4a57600080fd5b813581811115612b5957600080fd5b8760208260051b8501011115612b6e57600080fd5b6020928301989097509590910135949350505050565b600080600080600060a08688031215612b9c57600080fd5b853567ffffffffffffffff80821115612bb457600080fd5b612bc089838a016129a1565b96506020880135915080821115612bd657600080fd5b612be289838a016129a1565b955060408801359150612bf482612740565b90935060608701359080821115612c0a57600080fd5b50612c17888289016129c1565b95989497509295608001359392505050565b600060208284031215612c3b57600080fd5b813580151581146116b857600080fd5b60008060008060808587031215612c6157600080fd5b8435612c6c81612740565b93506020850135612c7c81612740565b9250604085013567ffffffffffffffff811115612c9857600080fd5b612ca4878288016129c1565b949793965093946060013593505050565b600080600060608486031215612cca57600080fd5b833567ffffffffffffffff80821115612ce257600080fd5b612cee878388016129a1565b94506020860135915080821115612d0457600080fd5b50612d11868287016129a1565b9250506040840135612d2281612740565b809150509250925092565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b19195b1959d85d1958d85b1b60a21b606082015260800190565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b6163746976652070726f787960a01b606082015260800190565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b634e487b7160e01b600052601160045260246000fd5b8082018082111561094e5761094e612e13565b85815284602082015260a060408201526000612e5b60a0830186612772565b8281036060840152612e6d8186612772565b91505060018060a01b03831660808301529695505050505050565b600060208284031215612e9a57600080fd5b81516116b881612740565b60005b83811015612ec0578181015183820152602001612ea8565b50506000910152565b60008151808452612ee1816020860160208601612ea5565b601f01601f19169290920160200192915050565b838152606060208201526000612f0e6060830185612ec9565b828103604084015261268b8185612ec9565b600082612f3d57634e487b7160e01b600052601260045260246000fd5b500490565b600060018201612f5457612f54612e13565b5060010190565b634e487b7160e01b600052603260045260246000fd5b600060208284031215612f8357600080fd5b5051919050565b60008251612f9c818460208701612ea5565b9190910192915050565b608081526000612fb96080830187612772565b6020830195909552506001600160a01b0392831660408201529116606090910152919050565b6001600160a01b03858116825284811660208301528316604082015260806060820181905260009061268b90830184612ec9565b8181038181111561094e5761094e612e13565b634e487b7160e01b600052603160045260246000fd5b6020815260006116b86020830184612ec956fe360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a264697066735822122030cc5c3e5c58f8fa4f400ca0b9af02f1dc775b86acd05f35af3cdbef6a10786664736f6c63430008130033
External libraries
NewContractLib : 0x3c5ea15f6e702fcc0351605b867e9ff33e1fd6bf