Contract is not verified. However, we found a verified contract with the same bytecode in Blockscout DB 0x23b8c7dbd533fde866eb14287bf64d9880dfe63c.
All metadata displayed below is from that contract. In order to verify current contract, click Verify & Publish button
Verify & Publish
All metadata displayed below is from that contract. In order to verify current contract, click Verify & Publish button
- Contract name:
- StakingBalancesFacet
- Optimization enabled
- false
- Compiler version
- v0.8.17+commit.8df45f5f
- Verified at
- 2024-02-13T00:57:26.222977Z
contracts/lit-node/StakingBalances/StakingBalancesFacet.sol
//SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.17; import { ERC20Burnable } from "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol"; import { EnumerableSet } from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; import { ContractResolver } from "../../lit-core/ContractResolver.sol"; import { Staking } from "../Staking.sol"; import { StakingFacet } from "../Staking/StakingFacet.sol"; import { StakingViewsFacet } from "../Staking/StakingViewsFacet.sol"; import { LibStakingBalancesStorage } from "./LibStakingBalancesStorage.sol"; import { LibDiamond } from "../../libraries/LibDiamond.sol"; import "hardhat/console.sol"; contract StakingBalancesFacet { using EnumerableSet for EnumerableSet.AddressSet; error CannotStakeZero(); error StakeMustBeGreaterThanMinimumStake( uint256 amountStaked, uint256 minimumStake ); error StakeMustBeLessThanMaximumStake( uint256 amountStaked, uint256 maximumStake ); error TryingToWithdrawMoreThanStaked( uint256 yourBalance, uint256 requestedWithdrawlAmount ); error CannotWithdrawZero(); error OnlyStakingContract(address sender); error StakerNotPermitted(address stakerAddress); error ActiveValidatorsCannotLeave(); error MaxAliasCountReached(uint256 aliasCount); error AliasNotOwnedBySender(address aliasAccount, address stakerAddress); error CannotRemoveAliasOfActiveValidator(address aliasAccount); error CallerNotOwner(); modifier onlyStakingContract() { if (msg.sender != getStakingAddress()) { revert OnlyStakingContract(msg.sender); } _; } modifier onlyOwner() { if (msg.sender != LibDiamond.contractOwner()) revert CallerNotOwner(); _; } /* ========== VIEWS ========== */ function s() internal pure returns (LibStakingBalancesStorage.StakingBalancesStorage storage) { return LibStakingBalancesStorage.getStorage(); } function contractResolver() external view returns (address) { return address(s().contractResolver); } /// get the staking address from the resolver function getStakingAddress() public view returns (address) { return s().contractResolver.getContract( s().contractResolver.STAKING_CONTRACT(), s().env ); } /// get the token address from the resolver function getTokenAddress() public view returns (address) { return s().contractResolver.getContract( s().contractResolver.LIT_TOKEN_CONTRACT(), s().env ); } function permittedStakersOn() public view returns (bool) { return s().permittedStakersOn; } function minimumStake() public view returns (uint256) { return s().minimumStake; } function maximumStake() public view returns (uint256) { return s().maximumStake; } function totalStaked() public view returns (uint256) { return s().totalStaked; } function balanceOf(address account) external view returns (uint256) { // support aliases if (s().aliases[account] != address(0)) { account = s().aliases[account]; } return s().balances[account]; } function rewardOf(address account) external view returns (uint256) { // support aliases if (s().aliases[account] != address(0)) { account = s().aliases[account]; } return s().rewards[account]; } function isPermittedStaker(address staker) public view returns (bool) { // support aliases if (s().aliases[staker] != address(0)) { staker = s().aliases[staker]; } return s().permittedStakers[staker]; } function checkStakingAmounts(address account) public view returns (bool) { // support aliases if (s().aliases[account] != address(0)) { account = s().aliases[account]; } uint256 amountStaked = s().balances[account]; if (amountStaked < s().minimumStake) { revert StakeMustBeGreaterThanMinimumStake( amountStaked, s().minimumStake ); } if (amountStaked > s().maximumStake) { revert StakeMustBeLessThanMaximumStake( amountStaked, s().maximumStake ); } return true; } /* ========== MUTATIVE FUNCTIONS ========== */ /// Stake tokens for a validator function stake(uint256 amount, address account) public onlyStakingContract { if (amount == 0) { revert CannotStakeZero(); } if (s().permittedStakersOn && !s().permittedStakers[account]) { revert StakerNotPermitted(account); } ERC20Burnable stakingToken = ERC20Burnable(getTokenAddress()); stakingToken.transferFrom(account, address(this), amount); s().balances[account] += amount; s().totalStaked += amount; emit Staked(account, amount); } /// Withdraw staked tokens. This can only be done by users who are not active in the validator set. /// @param amount The amount of tokens to withdraw function withdraw( uint256 amount, address account ) public onlyStakingContract { if (amount == 0) { revert CannotWithdrawZero(); } StakingViewsFacet staking = StakingViewsFacet(getStakingAddress()); address[] memory validatorsInCurrentEpoch = staking .getValidatorsInCurrentEpoch(); bool isValidatorInCurrentEpoch = false; for (uint256 i = 0; i < validatorsInCurrentEpoch.length; i++) { if (validatorsInCurrentEpoch[i] == account) { isValidatorInCurrentEpoch = true; break; } } if (isValidatorInCurrentEpoch) { revert ActiveValidatorsCannotLeave(); } if (s().balances[account] < amount) { revert TryingToWithdrawMoreThanStaked( s().balances[account], amount ); } s().totalStaked = s().totalStaked - amount; s().balances[account] = s().balances[account] - amount; ERC20Burnable stakingToken = ERC20Burnable(getTokenAddress()); stakingToken.transfer(account, amount); emit Withdrawn(account, amount); } function rewardValidator( uint256 amount, address account ) public onlyStakingContract { // support aliases if (s().aliases[account] != address(0)) { // only reward if the main staking account is not an active validator, too StakingViewsFacet staking = StakingViewsFacet(getStakingAddress()); if (staking.isActiveValidator(s().aliases[account])) { emit ValidatorNotRewardedBecauseAlias( s().aliases[account], account ); return; } account = s().aliases[account]; } s().rewards[account] += amount; emit ValidatorRewarded(account, amount); } function penalizeTokens( uint256 amount, address account ) public onlyStakingContract { if (s().aliases[account] != address(0)) { account = s().aliases[account]; } s().balances[account] -= amount; s().totalStaked -= amount; s().penaltyBalance += amount; emit ValidatorTokensPenalized(account, amount); } /// Transfer any outstanding reward tokens function getReward(address account) public onlyStakingContract { if (s().aliases[account] != address(0)) { account = s().aliases[account]; } uint256 reward = s().rewards[account]; if (reward > 0) { s().rewards[account] = 0; ERC20Burnable stakingToken = ERC20Burnable(getStakingAddress()); stakingToken.transfer(account, reward); emit RewardPaid(account, reward); } } /// Add an alias. Must come from staker address. function addAlias(address aliasAccount) public { if (s().aliasCounts[msg.sender] >= s().maxAliasCount) { revert MaxAliasCountReached(s().aliasCounts[msg.sender]); } s().aliases[aliasAccount] = msg.sender; s().aliasCounts[msg.sender] += 1; emit AliasAdded(msg.sender, aliasAccount); } /// Remove an alias. Must come from staker address. function removeAlias(address aliasAccount) public { // auth if (s().aliases[aliasAccount] != msg.sender) { revert AliasNotOwnedBySender(aliasAccount, msg.sender); } // don't let them remove an alias of an active validator StakingViewsFacet staking = StakingViewsFacet(getStakingAddress()); if (staking.isActiveValidator(aliasAccount)) { revert CannotRemoveAliasOfActiveValidator(aliasAccount); } delete s().aliases[aliasAccount]; s().aliasCounts[msg.sender] -= 1; emit AliasRemoved(msg.sender, aliasAccount); } function withdrawPenaltyTokens(uint256 balance) public onlyOwner { require(balance <= s().penaltyBalance, "Not enough penalty balance"); s().penaltyBalance -= balance; ERC20Burnable stakingToken = ERC20Burnable(getTokenAddress()); stakingToken.transfer(msg.sender, balance); } function transferPenaltyTokens( uint256 balance, address recipient ) public onlyOwner { require(balance <= s().penaltyBalance, "Not enough penalty balance"); s().penaltyBalance -= balance; ERC20Burnable stakingToken = ERC20Burnable(getTokenAddress()); stakingToken.transfer(recipient, balance); } function restakePenaltyTokens( address staker, uint256 balance ) public onlyOwner { require(balance <= s().penaltyBalance, "Not enough penalty balance"); s().totalStaked += balance; s().penaltyBalance -= balance; s().balances[staker] += balance; ERC20Burnable stakingToken = ERC20Burnable(getTokenAddress()); stakingToken.transfer(address(this), balance); } /// this is for if someone accidently sends unwrapped tokens function withdraw() public onlyOwner { uint256 withdrawAmount = address(this).balance; (bool sent, ) = payable(msg.sender).call{ value: withdrawAmount }(""); require(sent); } function addPermittedStakers(address[] memory stakers) public onlyOwner { for (uint256 i = 0; i < stakers.length; i++) { addPermittedStaker(stakers[i]); } } function addPermittedStaker(address staker) public onlyOwner { s().permittedStakers[staker] = true; emit PermittedStakerAdded(staker); } function removePermittedStaker(address staker) public onlyOwner { s().permittedStakers[staker] = false; emit PermittedStakerRemoved(staker); } function setPermittedStakersOn(bool permitted) public onlyOwner { s().permittedStakersOn = permitted; emit PermittedStakersOnChanged(permitted); } function setMinimumStake(uint256 newMinimumStake) public onlyOwner { s().minimumStake = newMinimumStake; emit MinimumStakeSet(newMinimumStake); } function setMaximumStake(uint256 newMaximumStake) public onlyOwner { s().maximumStake = newMaximumStake; emit MaximumStakeSet(newMaximumStake); } function setContractResolver(address newResolverAddress) public onlyOwner { s().contractResolver = ContractResolver(newResolverAddress); emit ResolverContractAddressSet(newResolverAddress); } function setMaxAliasCount(uint256 newMaxAliasCount) public onlyOwner { s().maxAliasCount = newMaxAliasCount; emit MaxAliasCountSet(newMaxAliasCount); } /* ========== EVENTS ========== */ event Staked(address indexed staker, uint256 amount); event Withdrawn(address indexed staker, uint256 amount); event ValidatorRewarded(address indexed staker, uint256 amount); event ValidatorTokensPenalized(address indexed staker, uint256 amount); event RewardPaid(address indexed staker, uint256 reward); event AliasAdded(address indexed staker, address aliasAccount); event AliasRemoved(address indexed staker, address aliasAccount); event ValidatorNotRewardedBecauseAlias( address indexed staker, address aliasAccount ); // onlyOwner events event TokenRewardPerTokenPerEpochSet( uint256 newTokenRewardPerTokenPerEpoch ); event MinimumStakeSet(uint256 newMinimumStake); event MaximumStakeSet(uint256 newMaximumStake); event PermittedStakerAdded(address staker); event PermittedStakerRemoved(address staker); event PermittedStakersOnChanged(bool permittedStakersOn); event ResolverContractAddressSet(address newResolverAddress); event MaxAliasCountSet(uint newMaxAliasCount); }
@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/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; }
@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/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/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/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/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/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/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/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/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/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/structs/BitMaps.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/structs/BitMaps.sol) pragma solidity ^0.8.0; /** * @dev Library for managing uint256 to bool mapping in a compact and efficient way, providing the keys are sequential. * Largely inspired by Uniswap's https://github.com/Uniswap/merkle-distributor/blob/master/contracts/MerkleDistributor.sol[merkle-distributor]. */ library BitMaps { struct BitMap { mapping(uint256 => uint256) _data; } /** * @dev Returns whether the bit at `index` is set. */ function get(BitMap storage bitmap, uint256 index) internal view returns (bool) { uint256 bucket = index >> 8; uint256 mask = 1 << (index & 0xff); return bitmap._data[bucket] & mask != 0; } /** * @dev Sets the bit at `index` to the boolean `value`. */ function setTo(BitMap storage bitmap, uint256 index, bool value) internal { if (value) { set(bitmap, index); } else { unset(bitmap, index); } } /** * @dev Sets the bit at `index`. */ function set(BitMap storage bitmap, uint256 index) internal { uint256 bucket = index >> 8; uint256 mask = 1 << (index & 0xff); bitmap._data[bucket] |= mask; } /** * @dev Unsets the bit at `index`. */ function unset(BitMap storage bitmap, uint256 index) internal { uint256 bucket = index >> 8; uint256 mask = 1 << (index & 0xff); bitmap._data[bucket] &= ~mask; } }
@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/IDiamond.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /******************************************************************************\ * Author: Nick Mudge <nick@perfectabstractions.com> (https://twitter.com/mudgen) * EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535 /******************************************************************************/ interface IDiamond { enum FacetCutAction { Add, Replace, Remove } // Add=0, Replace=1, Remove=2 struct FacetCut { address facetAddress; FacetCutAction action; bytes4[] functionSelectors; } event DiamondCut(FacetCut[] _diamondCut, address _init, bytes _calldata); }
contracts/interfaces/IDiamondCut.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /******************************************************************************\ * Author: Nick Mudge <nick@perfectabstractions.com> (https://twitter.com/mudgen) * EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535 /******************************************************************************/ import { IDiamond } from "./IDiamond.sol"; interface IDiamondCut is IDiamond { /// @notice Add/replace/remove any number of functions and optionally execute /// a function with delegatecall /// @param _diamondCut Contains the facet addresses and function selectors /// @param _init The address of the contract or facet to execute _calldata /// @param _calldata A function call, including function selector and arguments /// _calldata is executed with delegatecall on _init function diamondCut( FacetCut[] calldata _diamondCut, address _init, bytes calldata _calldata ) external; }
contracts/interfaces/IDiamondLoupe.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /******************************************************************************\ * Author: Nick Mudge <nick@perfectabstractions.com> (https://twitter.com/mudgen) * EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535 /******************************************************************************/ // A loupe is a small magnifying glass used to look at diamonds. // These functions look at diamonds interface IDiamondLoupe { /// These functions are expected to be called frequently /// by tools. struct Facet { address facetAddress; bytes4[] functionSelectors; } /// @notice Gets all facet addresses and their four byte function selectors. /// @return facets_ Facet function facets() external view returns (Facet[] memory facets_); /// @notice Gets all the function selectors supported by a specific facet. /// @param _facet The facet address. /// @return facetFunctionSelectors_ function facetFunctionSelectors( address _facet ) external view returns (bytes4[] memory facetFunctionSelectors_); /// @notice Get all the facet addresses used by a diamond. /// @return facetAddresses_ function facetAddresses() external view returns (address[] memory facetAddresses_); /// @notice Gets the facet that supports the given selector. /// @dev If facet is not found return address(0). /// @param _functionSelector The function selector. /// @return facetAddress_ The facet address. function facetAddress( bytes4 _functionSelector ) external view returns (address facetAddress_); }
contracts/interfaces/IERC165.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface IERC165 { /// @notice Query if a contract implements an interface /// @param interfaceId The interface identifier, as specified in ERC-165 /// @dev Interface identification is specified in ERC-165. This function /// uses less than 30,000 gas. /// @return `true` if the contract implements `interfaceID` and /// `interfaceID` is not 0xffffffff, `false` otherwise function supportsInterface(bytes4 interfaceId) external view returns (bool); }
contracts/interfaces/IERC173.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @title ERC-173 Contract Ownership Standard /// Note: the ERC-165 identifier for this interface is 0x7f5828d0 /* is ERC165 */ interface IERC173 { /// @dev This emits when ownership of a contract changes. event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); /// @notice Get the address of the owner /// @return owner_ The address of the owner. function owner() external view returns (address owner_); /// @notice Set the address of the new owner of the contract /// @dev Set _newOwner to address(0) to renounce any ownership. /// @param _newOwner The address of the new owner of the contract function transferOwnership(address _newOwner) external; }
contracts/libraries/LibDiamond.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /******************************************************************************\ * Author: Nick Mudge <nick@perfectabstractions.com> (https://twitter.com/mudgen) * EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535 /******************************************************************************/ import { IDiamond } from "../interfaces/IDiamond.sol"; import { IDiamondCut } from "../interfaces/IDiamondCut.sol"; // Remember to add the loupe functions from DiamondLoupeFacet to the diamond. // The loupe functions are required by the EIP2535 Diamonds standard error NoSelectorsGivenToAdd(); error NotContractOwner(address _user, address _contractOwner); error NoSelectorsProvidedForFacetForCut(address _facetAddress); error CannotAddSelectorsToZeroAddress(bytes4[] _selectors); error NoBytecodeAtAddress(address _contractAddress, string _message); error IncorrectFacetCutAction(uint8 _action); error CannotAddFunctionToDiamondThatAlreadyExists(bytes4 _selector); error CannotReplaceFunctionsFromFacetWithZeroAddress(bytes4[] _selectors); error CannotReplaceImmutableFunction(bytes4 _selector); error CannotReplaceFunctionWithTheSameFunctionFromTheSameFacet( bytes4 _selector ); error CannotReplaceFunctionThatDoesNotExists(bytes4 _selector); error RemoveFacetAddressMustBeZeroAddress(address _facetAddress); error CannotRemoveFunctionThatDoesNotExist(bytes4 _selector); error CannotRemoveImmutableFunction(bytes4 _selector); error InitializationFunctionReverted( address _initializationContractAddress, bytes _calldata ); library LibDiamond { bytes32 constant DIAMOND_STORAGE_POSITION = keccak256("diamond.standard.diamond.storage"); struct FacetAddressAndSelectorPosition { address facetAddress; uint16 selectorPosition; } struct DiamondStorage { // function selector => facet address and selector position in selectors array mapping(bytes4 => FacetAddressAndSelectorPosition) facetAddressAndSelectorPosition; bytes4[] selectors; mapping(bytes4 => bool) supportedInterfaces; // owner of the contract address contractOwner; } function diamondStorage() internal pure returns (DiamondStorage storage ds) { bytes32 position = DIAMOND_STORAGE_POSITION; assembly { ds.slot := position } } event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); function setContractOwner(address _newOwner) internal { DiamondStorage storage ds = diamondStorage(); address previousOwner = ds.contractOwner; ds.contractOwner = _newOwner; emit OwnershipTransferred(previousOwner, _newOwner); } function contractOwner() internal view returns (address contractOwner_) { contractOwner_ = diamondStorage().contractOwner; } function enforceIsContractOwner() internal view { if (msg.sender != diamondStorage().contractOwner) { revert NotContractOwner(msg.sender, diamondStorage().contractOwner); } } event DiamondCut( IDiamondCut.FacetCut[] _diamondCut, address _init, bytes _calldata ); // Internal function version of diamondCut function diamondCut( IDiamondCut.FacetCut[] memory _diamondCut, address _init, bytes memory _calldata ) internal { for ( uint256 facetIndex; facetIndex < _diamondCut.length; facetIndex++ ) { bytes4[] memory functionSelectors = _diamondCut[facetIndex] .functionSelectors; address facetAddress = _diamondCut[facetIndex].facetAddress; if (functionSelectors.length == 0) { revert NoSelectorsProvidedForFacetForCut(facetAddress); } IDiamondCut.FacetCutAction action = _diamondCut[facetIndex].action; if (action == IDiamond.FacetCutAction.Add) { addFunctions(facetAddress, functionSelectors); } else if (action == IDiamond.FacetCutAction.Replace) { replaceFunctions(facetAddress, functionSelectors); } else if (action == IDiamond.FacetCutAction.Remove) { removeFunctions(facetAddress, functionSelectors); } else { revert IncorrectFacetCutAction(uint8(action)); } } emit DiamondCut(_diamondCut, _init, _calldata); initializeDiamondCut(_init, _calldata); } function addFunctions( address _facetAddress, bytes4[] memory _functionSelectors ) internal { if (_facetAddress == address(0)) { revert CannotAddSelectorsToZeroAddress(_functionSelectors); } DiamondStorage storage ds = diamondStorage(); uint16 selectorCount = uint16(ds.selectors.length); enforceHasContractCode( _facetAddress, "LibDiamondCut: Add facet has no code" ); for ( uint256 selectorIndex; selectorIndex < _functionSelectors.length; selectorIndex++ ) { bytes4 selector = _functionSelectors[selectorIndex]; address oldFacetAddress = ds .facetAddressAndSelectorPosition[selector] .facetAddress; if (oldFacetAddress != address(0)) { revert CannotAddFunctionToDiamondThatAlreadyExists(selector); } ds.facetAddressAndSelectorPosition[ selector ] = FacetAddressAndSelectorPosition(_facetAddress, selectorCount); ds.selectors.push(selector); selectorCount++; } } function replaceFunctions( address _facetAddress, bytes4[] memory _functionSelectors ) internal { DiamondStorage storage ds = diamondStorage(); if (_facetAddress == address(0)) { revert CannotReplaceFunctionsFromFacetWithZeroAddress( _functionSelectors ); } enforceHasContractCode( _facetAddress, "LibDiamondCut: Replace facet has no code" ); for ( uint256 selectorIndex; selectorIndex < _functionSelectors.length; selectorIndex++ ) { bytes4 selector = _functionSelectors[selectorIndex]; address oldFacetAddress = ds .facetAddressAndSelectorPosition[selector] .facetAddress; // can't replace immutable functions -- functions defined directly in the diamond in this case if (oldFacetAddress == address(this)) { revert CannotReplaceImmutableFunction(selector); } if (oldFacetAddress == _facetAddress) { revert CannotReplaceFunctionWithTheSameFunctionFromTheSameFacet( selector ); } if (oldFacetAddress == address(0)) { revert CannotReplaceFunctionThatDoesNotExists(selector); } // replace old facet address ds .facetAddressAndSelectorPosition[selector] .facetAddress = _facetAddress; } } function removeFunctions( address _facetAddress, bytes4[] memory _functionSelectors ) internal { DiamondStorage storage ds = diamondStorage(); uint256 selectorCount = ds.selectors.length; if (_facetAddress != address(0)) { revert RemoveFacetAddressMustBeZeroAddress(_facetAddress); } for ( uint256 selectorIndex; selectorIndex < _functionSelectors.length; selectorIndex++ ) { bytes4 selector = _functionSelectors[selectorIndex]; FacetAddressAndSelectorPosition memory oldFacetAddressAndSelectorPosition = ds .facetAddressAndSelectorPosition[selector]; if (oldFacetAddressAndSelectorPosition.facetAddress == address(0)) { revert CannotRemoveFunctionThatDoesNotExist(selector); } // can't remove immutable functions -- functions defined directly in the diamond if ( oldFacetAddressAndSelectorPosition.facetAddress == address(this) ) { revert CannotRemoveImmutableFunction(selector); } // replace selector with last selector selectorCount--; if ( oldFacetAddressAndSelectorPosition.selectorPosition != selectorCount ) { bytes4 lastSelector = ds.selectors[selectorCount]; ds.selectors[ oldFacetAddressAndSelectorPosition.selectorPosition ] = lastSelector; ds .facetAddressAndSelectorPosition[lastSelector] .selectorPosition = oldFacetAddressAndSelectorPosition .selectorPosition; } // delete last selector ds.selectors.pop(); delete ds.facetAddressAndSelectorPosition[selector]; } } function initializeDiamondCut( address _init, bytes memory _calldata ) internal { if (_init == address(0)) { return; } enforceHasContractCode( _init, "LibDiamondCut: _init address has no code" ); (bool success, bytes memory error) = _init.delegatecall(_calldata); if (!success) { if (error.length > 0) { // bubble up error /// @solidity memory-safe-assembly assembly { let returndata_size := mload(error) revert(add(32, error), returndata_size) } } else { revert InitializationFunctionReverted(_init, _calldata); } } } function enforceHasContractCode( address _contract, string memory _errorMessage ) internal view { uint256 contractSize; assembly { contractSize := extcodesize(_contract) } if (contractSize == 0) { revert NoBytecodeAtAddress(_contract, _errorMessage); } } }
contracts/lit-core/ContractResolver.sol
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.0; import "@openzeppelin/contracts/access/AccessControl.sol"; import "hardhat/console.sol"; contract ContractResolver is AccessControl { /* ========== TYPE DEFINITIONS ========== */ // the comments following each one of these are the keccak256 hashes of the string values // this is very useful if you have to manually set any of these, so that you // don't have to calculate the hahes yourself. bytes32 public constant ADMIN_ROLE = keccak256("ADMIN"); // 0xdf8b4c520ffe197c5343c6f5aec59570151ef9a492f2c624fd45ddde6135ec42 bytes32 public constant RELEASE_REGISTER_CONTRACT = keccak256("RELEASE_REGISTER"); // 0x3a68dbfd8bbb64015c42bc131c388dea7965e28c1004d09b39f59500c3a763ec bytes32 public constant STAKING_CONTRACT = keccak256("STAKING"); // 0x080909c18c958ce5a2d36481697824e477319323d03154ceba3b78f28a61887b bytes32 public constant STAKING_BALANCES_CONTRACT = keccak256("STAKING_BALANCES"); // 0xaa06d108dbd7bf976b16b7bf5adb29d2d0ef2c385ca8b9d833cc802f33942d72 bytes32 public constant MULTI_SENDER_CONTRACT = keccak256("MULTI_SENDER"); // 0xdd5b9b8a5e8e01f2962ed7e983d58fe32e1f66aa88dd7ab30770fa9b77da7243 bytes32 public constant LIT_TOKEN_CONTRACT = keccak256("LIT_TOKEN"); bytes32 public constant PUB_KEY_ROUTER_CONTRACT = keccak256("PUB_KEY_ROUTER"); // 0xb1f79813bc7630a52ae948bc99781397e409d0dd3521953bf7d8d7a2db6147f7 bytes32 public constant PKP_NFT_CONTRACT = keccak256("PKP_NFT"); // 0xb7b4fde9944d3c13e9a78835431c33a5084d90a7f0c73def76d7886315fe87b0 bytes32 public constant RATE_LIMIT_NFT_CONTRACT = keccak256("RATE_LIMIT_NFT"); // 0xb931b2719aeb2a65a5035fa0a190bfdc4c8622ce8cbff7a3d1ab42531fb1a918 bytes32 public constant PKP_HELPER_CONTRACT = keccak256("PKP_HELPER"); // 0x27d764ea2a4a3865434bbf4a391110149644be31448f3479fd15b44388755765 bytes32 public constant PKP_PERMISSIONS_CONTRACT = keccak256("PKP_PERMISSIONS"); // 0x54953c23068b8fc4c0736301b50f10027d6b469327de1fd42841a5072b1bcebe bytes32 public constant PKP_NFT_METADATA_CONTRACT = keccak256("PKP_NFT_METADATA"); // 0xf14f431dadc82e7dbc5e379f71234e5735c9187e4327a7c6ac014d55d1b7727a bytes32 public constant ALLOWLIST_CONTRACT = keccak256("ALLOWLIST"); // 0x74845de37cfabd357633214b47fa91ccd19b05b7c5a08ac22c187f811fb62bca bytes32 public constant DOMAIN_WALLET_ORACLE = keccak256("DOMAIN_WALLET_ORACLE"); bytes32 public constant DOMAIN_WALLET_REGISTRY = keccak256("DOMAIN_WALLET_REGISTRY"); bytes32 public constant HD_KEY_DERIVER_CONTRACT = keccak256("HD_KEY_DERIVER"); bytes32 public constant BACKUP_RECOVERY_CONTRACT = keccak256("BACKUP_RECOVERY"); enum Env { Dev, Staging, Prod } /* ========== ERRORS ========== */ /// The ADMIN role is required to use this function error AdminRoleRequired(); /* ========== EVENTS ========== */ event AllowedEnvAdded(Env env); event AllowedEnvRemoved(Env env); event SetContract(bytes32 typ, Env env, address addr); /* ========== STATE VARIABLES ========== */ mapping(Env => bool) allowedEnvs; mapping(bytes32 => mapping(Env => address)) public typeAddresses; /* ========== CONSTRUCTOR ========== */ constructor(Env env) { _setupRole(ADMIN_ROLE, msg.sender); _setRoleAdmin(ADMIN_ROLE, ADMIN_ROLE); allowedEnvs[env] = true; emit AllowedEnvAdded(env); } /* ========== MUTATIVE FUNCTIONS ========== */ /// add an allowed env function addAllowedEnv(Env env) public { // Check roles if (!hasRole(ADMIN_ROLE, msg.sender)) { revert AdminRoleRequired(); } allowedEnvs[env] = true; emit AllowedEnvAdded(env); } /// remove an allowed env function removeAllowedEnv(Env env) public { // Check roles if (!hasRole(ADMIN_ROLE, msg.sender)) { revert AdminRoleRequired(); } delete allowedEnvs[env]; emit AllowedEnvRemoved(env); } /// set the active address for a deployed contract function setContract(bytes32 typ, Env env, address addr) public { // Check roles if (!hasRole(ADMIN_ROLE, msg.sender)) { revert AdminRoleRequired(); } // Ensure the env is available require( allowedEnvs[env] == true, "The provided Env is not valid for this contract" ); // Set the contract address typeAddresses[typ][env] = addr; // Emit events emit SetContract(typ, env, addr); } function addAdmin(address newAdmin) public onlyRole(ADMIN_ROLE) { _grantRole(ADMIN_ROLE, newAdmin); } function removeAdmin( address adminBeingRemoved ) public onlyRole(ADMIN_ROLE) { require( adminBeingRemoved != msg.sender, "Cannot remove self as admin. Have the new admin do it." ); _revokeRole(ADMIN_ROLE, adminBeingRemoved); } /* ========== VIEWS ========== */ /// Returns the matching contract address for a given type and env function getContract(bytes32 typ, Env env) public view returns (address) { return (typeAddresses[typ][env]); } }
contracts/lit-node/Staking.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /******************************************************************************\ * Author: Nick Mudge <nick@perfectabstractions.com> (https://twitter.com/mudgen) * EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535 * * Implementation of a diamond. /******************************************************************************/ import { LibDiamond } from "../libraries/LibDiamond.sol"; import { IDiamondCut } from "../interfaces/IDiamondCut.sol"; import { IDiamondLoupe } from "../interfaces/IDiamondLoupe.sol"; import { IERC173 } from "../interfaces/IERC173.sol"; import { IERC165 } from "../interfaces/IERC165.sol"; import { IERC20Metadata } from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol"; import { ContractResolver } from "../lit-core/ContractResolver.sol"; import { LibStakingStorage } from "./Staking/LibStakingStorage.sol"; // When no function exists for function called error FunctionNotFound(bytes4 _functionSelector); // This is used in diamond constructor // more arguments are added to this struct // this avoids stack too deep errors struct StakingArgs { address owner; address init; bytes initCalldata; address contractResolver; ContractResolver.Env env; } contract Staking { constructor( IDiamondCut.FacetCut[] memory _diamondCut, StakingArgs memory _args ) payable { LibDiamond.setContractOwner(_args.owner); LibDiamond.diamondCut(_diamondCut, _args.init, _args.initCalldata); // Code can be added here to perform actions and set state variables. LibStakingStorage.getStorage().contractResolver = ContractResolver( _args.contractResolver ); LibStakingStorage.getStorage().env = _args.env; // 0.05 tokens per token staked meaning a 5% per epoch inflation rate uint256[] memory keyTypesTemp = new uint256[](2); keyTypesTemp[0] = 1; keyTypesTemp[1] = 2; LibStakingStorage.getStorage().configs[0] = LibStakingStorage.Config({ tokenRewardPerTokenPerEpoch: (10 ** 18) / 20, // 18 decimal places in token complaintTolerance: 10, complaintIntervalSecs: 900, keyTypes: keyTypesTemp, minimumValidatorCount: 2, maxConcurrentRequests: 1000, maxTripleCount: 25, minTripleCount: 10, peerCheckingIntervalSecs: 5000, maxTripleConcurrency: 2 }); uint256 epochLengthSeconds = 1; LibStakingStorage.getStorage().epochs[0] = LibStakingStorage.Epoch({ epochLength: epochLengthSeconds, number: 1, endTime: block.timestamp + epochLengthSeconds, retries: 0, timeout: 60 }); // set default kick penalty to 1% for reason "1" LibStakingStorage.getStorage().kickPenaltyPercentByReason[1] = 1; LibStakingStorage.getStorage().state = LibStakingStorage.States.Paused; // set sane defaults for min and max version LibStakingStorage.getStorage().versionRequirements[ 0 ] = LibStakingStorage.Version({ major: 0, minor: 0, patch: 0 }); LibStakingStorage.getStorage().versionRequirements[ 1 ] = LibStakingStorage.Version({ major: 10000, minor: 0, patch: 0 }); } // Find facet for function that is called and execute the // function if a facet is found and return any value. fallback() external { LibDiamond.DiamondStorage storage ds; bytes32 position = LibDiamond.DIAMOND_STORAGE_POSITION; // get diamond storage assembly { ds.slot := position } // get facet from function selector address facet = ds .facetAddressAndSelectorPosition[msg.sig] .facetAddress; if (facet == address(0)) { revert FunctionNotFound(msg.sig); } // Execute external function from facet using delegatecall and return any value. assembly { // copy function selector and any arguments calldatacopy(0, 0, calldatasize()) // execute function call using the facet let result := delegatecall(gas(), facet, 0, calldatasize(), 0, 0) // get any return value returndatacopy(0, 0, returndatasize()) // return any return value or error back to the caller switch result case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) } } } }
contracts/lit-node/Staking/LibStakingStorage.sol
//SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.17; import { EnumerableSet } from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; import { BitMaps } from "@openzeppelin/contracts/utils/structs/BitMaps.sol"; import "solidity-bytes-utils/contracts/BytesLib.sol"; import { ContractResolver } from "../../lit-core/ContractResolver.sol"; interface IPubkeyRouter { struct RootKey { bytes pubkey; uint256 keyType; // 1 = BLS, 2 = ECDSA. Not doing this in an enum so we can add more keytypes in the future without redeploying. } struct Signature { bytes32 r; bytes32 s; uint8 v; } } library LibStakingStorage { using EnumerableSet for EnumerableSet.AddressSet; bytes32 constant STAKING_POSITION = keccak256("staking.storage"); enum States { Active, NextValidatorSetLocked, ReadyForNextEpoch, Unlocked, Paused, Restore } struct Validator { uint32 ip; uint128 ipv6; uint32 port; address nodeAddress; uint256 reward; uint256 senderPubKey; uint256 receiverPubKey; } struct AddressMapping { address nodeAddress; address stakerAddress; } struct VoteToKickValidatorInNextEpoch { uint256 votes; mapping(address => bool) voted; } struct Epoch { uint256 epochLength; // in seconds uint256 number; // the current epoch number uint256 endTime; // the end timestamp where the next epoch can be kicked off uint256 retries; // incremented upon failure to advance and subsequent unlock uint256 timeout; // timeout in seconds, where the nodes can be unlocked. } struct Config { uint256 tokenRewardPerTokenPerEpoch; uint256 complaintTolerance; // cycles after which to escalate peer complaints to chain uint256 complaintIntervalSecs; // the key type of the node. // 1 = BLS, 2 = ECDSA. Not doing this in an enum so we can add more keytypes in the future without redeploying. uint256[] keyTypes; // don't start the DKG or let nodes leave the validator set // if there are less than this many nodes uint256 minimumValidatorCount; uint256 maxConcurrentRequests; uint256 maxTripleCount; uint256 minTripleCount; uint256 peerCheckingIntervalSecs; uint256 maxTripleConcurrency; } struct Version { uint256 major; uint256 minor; uint256 patch; } struct StakingStorage { ContractResolver contractResolver; ContractResolver.Env env; States state; EnumerableSet.AddressSet validatorsInCurrentEpoch; EnumerableSet.AddressSet validatorsInNextEpoch; EnumerableSet.AddressSet validatorsKickedFromNextEpoch; uint256 totalStaked; // versionRequirements[0] is the min version // versionRequirements[1] is the max version mapping(uint256 => Version) versionRequirements; // storing this in a mapping so that it can be changed in the future // always use epochs[0] mapping(uint256 => Epoch) epochs; // storing this in a mapping so that it can be changed in the future. // always use configs[0] mapping(uint256 => Config) configs; // list of all validators, even ones that are not in the current or next epoch // maps STAKER address to Validator struct mapping(address => Validator) validators; // stakers join by staking, but nodes need to be able to vote to kick. // to avoid node operators having to run a hotwallet with their staking private key, // the node gets it's own private key that it can use to vote to kick, // or signal that the next epoch is ready. // this mapping lets you go from the nodeAddressto the stakingAddress. mapping(address => address) nodeAddressToStakerAddress; // after the validator set is locked, nodes vote that they have successfully completed the PSS // operation. Once a threshold of nodes have voted that they are ready, then the epoch can advance mapping(address => bool) readyForNextEpoch; // nodes can vote to kick another node. If a threshold of nodes vote to kick someone, they // are removed from the next validator set mapping(uint256 => mapping(address => VoteToKickValidatorInNextEpoch)) votesToKickValidatorsInNextEpoch; // maps kick reason to amount to slash mapping(uint256 => uint256) kickPenaltyPercentByReason; // maps hash(comms_sender_pubkey,comms_receiver_pubkey) to a boolean to show if // the set of comms keys has been used or not mapping(bytes32 => bool) usedCommsKeys; // This is the set of validators that are in the current validator set that are also kicked // from the next validator set. EnumerableSet.AddressSet currentValidatorsKickedFromNextEpoch; } // Return ERC721 storage struct for reading and writing function getStorage() internal pure returns (StakingStorage storage storageStruct) { bytes32 position = STAKING_POSITION; assembly { storageStruct.slot := position } } }
contracts/lit-node/Staking/StakingFacet.sol
//SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.17; import { IERC20Metadata } from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol"; import { EnumerableSet } from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; import { ContractResolver } from "../../lit-core/ContractResolver.sol"; import { LibDiamond } from "../../libraries/LibDiamond.sol"; import { StakingViewsFacet } from "./StakingViewsFacet.sol"; import { StakingBalancesFacet } from "../StakingBalances/StakingBalancesFacet.sol"; import { LibStakingStorage } from "./LibStakingStorage.sol"; // import "hardhat/console.sol"; contract StakingFacet { using EnumerableSet for EnumerableSet.AddressSet; // errors error MustBeInActiveOrUnlockedState(LibStakingStorage.States state); error MustBeInNextValidatorSetLockedOrReadyForNextEpochOrRestoreState( LibStakingStorage.States state ); error MustBeInNextValidatorSetLockedState(LibStakingStorage.States state); error MustBeInReadyForNextEpochState(LibStakingStorage.States state); error MustBeInActiveOrUnlockedOrPausedState(LibStakingStorage.States state); error MustBeInNextValidatorSetLockedOrReadyForNextEpochState( LibStakingStorage.States state ); error NotEnoughValidatorsInNextEpoch( uint256 validatorCount, uint256 minimumValidatorCount ); error ValidatorIsNotInNextEpoch( address validator, address[] validatorsInNextEpoch ); error NotEnoughValidatorsReadyForNextEpoch( uint256 currentReadyValidatorCount, uint256 nextReadyValidatorCount, uint256 minimumValidatorCountToBeReady ); error CannotKickBelowCurrentValidatorThreshold(); error CannotStakeZero(); error CannotRejoinUntilNextEpochBecauseKicked(address stakingAddress); error ActiveValidatorsCannotLeave(); error TryingToWithdrawMoreThanStaked( uint256 yourBalance, uint256 requestedWithdrawlAmount ); error CouldNotMapNodeAddressToStakerAddress(address nodeAddress); error MustBeValidatorInNextEpochToKick(address stakerAddress); error CannotVoteTwice(address stakerAddress); error NotEnoughTimeElapsedSinceLastEpoch( uint256 currentTimestamp, uint256 epochEndTime ); error NotEnoughTimeElapsedForTimeoutSinceLastEpoch( uint256 currentTimestamp, uint256 epochEndTime, uint256 timeout ); error CannotWithdrawZero(); error CannotReuseCommsKeys(uint256 senderPubKey, uint256 receiverPubKey); error StakerNotPermitted(address stakerAddress); error SignaledReadyForWrongEpochNumber( uint256 currentEpochNumber, uint256 receivedEpochNumber ); error CallerNotOwner(); /* ========== Modifiers ========== */ modifier onlyOwner() { if (msg.sender != LibDiamond.contractOwner()) revert CallerNotOwner(); _; } /* ========== VIEWS ========== */ function s() internal pure returns (LibStakingStorage.StakingStorage storage) { return LibStakingStorage.getStorage(); } function views() internal view returns (StakingViewsFacet) { return StakingViewsFacet(address(this)); } function mutableEpoch() internal view returns (LibStakingStorage.Epoch storage) { return s().epochs[0]; } function mutableConfig() internal view returns (LibStakingStorage.Config storage) { return s().configs[0]; } /* ========== MUTATIVE FUNCTIONS ========== */ /// Lock in the validators for the next epoch function lockValidatorsForNextEpoch() external { if (block.timestamp < mutableEpoch().endTime) { revert NotEnoughTimeElapsedSinceLastEpoch( block.timestamp, mutableEpoch().endTime ); } if ( !(s().state == LibStakingStorage.States.Active || s().state == LibStakingStorage.States.Unlocked) ) { revert MustBeInActiveOrUnlockedState(s().state); } if ( s().validatorsInNextEpoch.length() < mutableConfig().minimumValidatorCount ) { revert NotEnoughValidatorsInNextEpoch( s().validatorsInNextEpoch.length(), mutableConfig().minimumValidatorCount ); } s().state = LibStakingStorage.States.NextValidatorSetLocked; emit StateChanged(s().state); } /// After proactive secret sharing is complete, the nodes may signal that they are ready for the next epoch. Note that this function is called by the node itself, and so msg.sender is the nodeAddress and not the stakerAddress. function signalReadyForNextEpoch(uint256 epochNumber) external { if (mutableEpoch().number != epochNumber) { revert SignaledReadyForWrongEpochNumber( mutableEpoch().number, epochNumber ); } address stakerAddress = s().nodeAddressToStakerAddress[msg.sender]; if ( !(s().state == LibStakingStorage.States.NextValidatorSetLocked || s().state == LibStakingStorage.States.ReadyForNextEpoch || s().state == LibStakingStorage.States.Restore) ) { revert MustBeInNextValidatorSetLockedOrReadyForNextEpochOrRestoreState( s().state ); } // at the first epoch, validatorsInCurrentEpoch is empty if (mutableEpoch().number != 1) { if (!s().validatorsInNextEpoch.contains(stakerAddress)) { revert ValidatorIsNotInNextEpoch( stakerAddress, views().getValidatorsInNextEpoch() ); } } s().readyForNextEpoch[stakerAddress] = true; emit ReadyForNextEpoch(stakerAddress, mutableEpoch().number); if (views().isReadyForNextEpoch()) { s().state = LibStakingStorage.States.ReadyForNextEpoch; emit StateChanged(s().state); } } /// Advance to the next Epoch. Rewards validators, adds the joiners, and removes the leavers function advanceEpoch() external { if (block.timestamp < mutableEpoch().endTime) { revert NotEnoughTimeElapsedSinceLastEpoch( block.timestamp, mutableEpoch().endTime ); } if (s().state != LibStakingStorage.States.ReadyForNextEpoch) { revert MustBeInReadyForNextEpochState(s().state); } if (!views().isReadyForNextEpoch()) { revert NotEnoughValidatorsReadyForNextEpoch( views().countOfCurrentValidatorsReadyForNextEpoch(), views().countOfNextValidatorsReadyForNextEpoch(), views().currentValidatorCountForConsensus() ); } // reward the validators uint256 validatorLength = s().validatorsInCurrentEpoch.length(); for (uint256 i = 0; i < validatorLength; i++) { address validatorAddress = s().validatorsInCurrentEpoch.at(i); IERC20Metadata stakingToken = IERC20Metadata( views().getTokenAddress() ); StakingBalancesFacet stakingBalances = StakingBalancesFacet( views().getStakingBalancesAddress() ); uint256 reward = (mutableConfig().tokenRewardPerTokenPerEpoch * stakingBalances.balanceOf(validatorAddress)) / 10 ** stakingToken.decimals(); stakingBalances.rewardValidator(reward, validatorAddress); } // set the validators to the new validator set // ideally we could just do this: // validatorsInCurrentEpoch = validatorsInNextEpoch; // but solidity doesn't allow that, so we have to do it manually // clear out validators in current epoch clearEnumerableAddressSet(s().validatorsInCurrentEpoch); // copy validators from next epoch to current epoch validatorLength = s().validatorsInNextEpoch.length(); for (uint256 i = 0; i < validatorLength; i++) { s().validatorsInCurrentEpoch.add(s().validatorsInNextEpoch.at(i)); // clear out readyForNextEpoch s().readyForNextEpoch[s().validatorsInNextEpoch.at(i)] = false; } // clear out the validators kicked from next epoch clearEnumerableAddressSet(s().validatorsKickedFromNextEpoch); // clear out the current validators kicked from next epoch clearEnumerableAddressSet(s().currentValidatorsKickedFromNextEpoch); mutableEpoch().number++; mutableEpoch().endTime = block.timestamp + mutableEpoch().epochLength; s().state = LibStakingStorage.States.Active; emit StateChanged(s().state); } /// Stake and request to join the validator set /// @param amount The amount of tokens to stake /// @param ip The IP address of the node /// @param port The port of the node function stakeAndJoin( uint256 amount, uint32 ip, uint128 ipv6, uint32 port, address nodeAddress, uint256 senderPubKey, uint256 receiverPubKey ) external { stake(amount); requestToJoin( ip, ipv6, port, nodeAddress, senderPubKey, receiverPubKey ); } function stake(uint256 amount) public { StakingBalancesFacet stakingBalances = StakingBalancesFacet( views().getStakingBalancesAddress() ); stakingBalances.stake(amount, msg.sender); } function requestToJoin( uint32 ip, uint128 ipv6, uint32 port, address nodeAddress, uint256 senderPubKey, uint256 receiverPubKey ) public { StakingBalancesFacet stakingBalances = StakingBalancesFacet( views().getStakingBalancesAddress() ); stakingBalances.checkStakingAmounts(msg.sender); if ( !(s().state == LibStakingStorage.States.Active || s().state == LibStakingStorage.States.Unlocked || s().state == LibStakingStorage.States.Paused) ) { revert MustBeInActiveOrUnlockedOrPausedState(s().state); } // make sure they haven't been kicked if (s().validatorsKickedFromNextEpoch.contains(msg.sender)) { revert CannotRejoinUntilNextEpochBecauseKicked(msg.sender); } bytes32 commsKeysHash = keccak256( abi.encodePacked(senderPubKey, receiverPubKey) ); if (s().usedCommsKeys[commsKeysHash]) { revert CannotReuseCommsKeys(senderPubKey, receiverPubKey); } s().usedCommsKeys[commsKeysHash] = true; if (stakingBalances.permittedStakersOn()) { if (!stakingBalances.isPermittedStaker(msg.sender)) { revert StakerNotPermitted(msg.sender); } } s().validators[msg.sender].ip = ip; s().validators[msg.sender].ipv6 = ipv6; s().validators[msg.sender].port = port; s().validators[msg.sender].nodeAddress = nodeAddress; s().validators[msg.sender].senderPubKey = senderPubKey; s().validators[msg.sender].receiverPubKey = receiverPubKey; s().nodeAddressToStakerAddress[nodeAddress] = msg.sender; s().validatorsInNextEpoch.add(msg.sender); emit RequestToJoin(msg.sender); } /// Withdraw staked tokens. This can only be done by users who are not active in the validator set. /// @param amount The amount of tokens to withdraw function withdraw(uint256 amount) external { StakingBalancesFacet stakingBalances = StakingBalancesFacet( views().getStakingBalancesAddress() ); stakingBalances.withdraw(amount, msg.sender); } /// Request to leave in the next Epoch function requestToLeave() external { stakerRequestToLeave(msg.sender); } function requestToLeaveAsNode() external { address stakerAddress = s().nodeAddressToStakerAddress[msg.sender]; if (stakerAddress == address(0)) { revert CouldNotMapNodeAddressToStakerAddress(msg.sender); } stakerRequestToLeave(stakerAddress); } function stakerRequestToLeave(address staker) internal { if ( !(s().state == LibStakingStorage.States.Active || s().state == LibStakingStorage.States.Unlocked || s().state == LibStakingStorage.States.Paused) ) { revert MustBeInActiveOrUnlockedOrPausedState(s().state); } if ( s().validatorsInNextEpoch.length() - 1 < mutableConfig().minimumValidatorCount ) { revert NotEnoughValidatorsInNextEpoch( s().validatorsInNextEpoch.length(), mutableConfig().minimumValidatorCount ); } removeValidatorFromNextEpoch(staker); emit RequestToLeave(staker); } /// Transfer any outstanding reward tokens function getReward() external { StakingBalancesFacet stakingBalances = StakingBalancesFacet( views().getStakingBalancesAddress() ); stakingBalances.getReward(msg.sender); } /// Exit staking and get any outstanding rewards function exit() external { StakingBalancesFacet stakingBalances = StakingBalancesFacet( views().getStakingBalancesAddress() ); stakingBalances.withdraw( stakingBalances.balanceOf(msg.sender), msg.sender ); stakingBalances.getReward(msg.sender); } /// If more than the threshold of validators vote to kick someone, kick them. /// It's expected that this will be called by the node directly, so msg.sender will be the nodeAddress function kickValidatorInNextEpoch( address validatorStakerAddress, uint256 reason, bytes calldata data ) external { address stakerAddressOfSender = s().nodeAddressToStakerAddress[ msg.sender ]; if (stakerAddressOfSender == address(0)) { revert CouldNotMapNodeAddressToStakerAddress(msg.sender); } if (!s().validatorsInNextEpoch.contains(stakerAddressOfSender)) { revert MustBeValidatorInNextEpochToKick(stakerAddressOfSender); } if ( s() .votesToKickValidatorsInNextEpoch[mutableEpoch().number][ validatorStakerAddress ].voted[stakerAddressOfSender] ) { revert CannotVoteTwice(stakerAddressOfSender); } // A threshold number of validators from the current validator set MUST NOT // be kicked in order for DKG resharing to be successful. // This is only valid for epoch 2+ since epoch 1 has no current validator set, // and if we enforce this in epoch 1, we are effectively prohibiting any votes // to kick. bool isValidatorInCurrentSet = s().validatorsInCurrentEpoch.contains( validatorStakerAddress ); if ( views().epoch().number > 1 && s().currentValidatorsKickedFromNextEpoch.length() >= (views().getValidatorsInCurrentEpoch().length - views().currentValidatorCountForConsensus()) ) { revert CannotKickBelowCurrentValidatorThreshold(); } // Vote to kick s() .votesToKickValidatorsInNextEpoch[mutableEpoch().number][ validatorStakerAddress ].votes++; s() .votesToKickValidatorsInNextEpoch[mutableEpoch().number][ validatorStakerAddress ].voted[stakerAddressOfSender] = true; if ( s().validatorsInNextEpoch.contains(validatorStakerAddress) && views().shouldKickValidator(validatorStakerAddress) ) { // remove them from the validator set removeValidatorFromNextEpoch(validatorStakerAddress); // block them from rejoining the next epoch s().validatorsKickedFromNextEpoch.add(validatorStakerAddress); // mark them if they are in the current validator set if (isValidatorInCurrentSet) { s().currentValidatorsKickedFromNextEpoch.add( validatorStakerAddress ); } // slash the stake uint256 kickPenaltyPercent = s().kickPenaltyPercentByReason[reason]; StakingBalancesFacet stakingBalances = StakingBalancesFacet( views().getStakingBalancesAddress() ); uint256 amountToPenalize = (stakingBalances.balanceOf( validatorStakerAddress ) * kickPenaltyPercent) / 100; stakingBalances.penalizeTokens( amountToPenalize, validatorStakerAddress ); // shame them with an event emit ValidatorKickedFromNextEpoch( validatorStakerAddress, amountToPenalize ); // if we're in the locked state, then we need to unlock, because we kicked a node if ( s().state == LibStakingStorage.States.NextValidatorSetLocked || s().state == LibStakingStorage.States.ReadyForNextEpoch ) { unlockEpoch(); } } emit VotedToKickValidatorInNextEpoch( stakerAddressOfSender, validatorStakerAddress, reason, data ); } function clearEnumerableAddressSet( EnumerableSet.AddressSet storage set ) internal { while (set.length() > 0) { set.remove(set.at(0)); } } /// Set the IP and port of your node /// @param ip The ip address of your node /// @param port The port of your node function setIpPortNodeAddressAndCommunicationPubKeys( uint32 ip, uint128 ipv6, uint32 port, address nodeAddress, uint256 senderPubKey, uint256 receiverPubKey ) external { s().validators[msg.sender].ip = ip; s().validators[msg.sender].ipv6 = ipv6; s().validators[msg.sender].port = port; s().validators[msg.sender].nodeAddress = nodeAddress; s().validators[msg.sender].senderPubKey = senderPubKey; s().validators[msg.sender].receiverPubKey = receiverPubKey; // don't let them overwrite an existing mapping // becuase it could belong to someone else, // but let them create a new mapping if (s().nodeAddressToStakerAddress[nodeAddress] == address(0)) { s().nodeAddressToStakerAddress[nodeAddress] = msg.sender; } } function setEpochLength(uint256 newEpochLength) external onlyOwner { mutableEpoch().epochLength = newEpochLength; emit EpochLengthSet(newEpochLength); } function setEpochTimeout(uint256 newEpochTimeout) external onlyOwner { mutableEpoch().timeout = newEpochTimeout; emit EpochTimeoutSet(newEpochTimeout); } function setEpochEndTime(uint256 newEpochEndTime) external onlyOwner { mutableEpoch().endTime = newEpochEndTime; emit EpochEndTimeSet(newEpochEndTime); } function setContractResolver( address newResolverAddress ) external onlyOwner { s().contractResolver = ContractResolver(newResolverAddress); emit ResolverContractAddressSet(newResolverAddress); } function setKickPenaltyPercent( uint256 reason, uint256 newKickPenaltyPercent ) external onlyOwner { s().kickPenaltyPercentByReason[reason] = newKickPenaltyPercent; emit KickPenaltyPercentSet(reason, newKickPenaltyPercent); } function setEpochState( LibStakingStorage.States newState ) external onlyOwner { s().state = newState; emit StateChanged(newState); } function adminKickValidatorInNextEpoch( address validatorStakerAddress ) external onlyOwner { // block them from rejoining the next epoch s().validatorsKickedFromNextEpoch.add(validatorStakerAddress); // remove from the validator set removeValidatorFromNextEpoch(validatorStakerAddress); // if they're in the current set, we need to mark them as kicked from the current set too bool isValidatorInCurrentSet = s().validatorsInCurrentEpoch.contains( validatorStakerAddress ); if (isValidatorInCurrentSet) { s().currentValidatorsKickedFromNextEpoch.add( validatorStakerAddress ); } emit ValidatorKickedFromNextEpoch(validatorStakerAddress, 0); // // if we're in the locked state, then we need to unlock, because we kicked a node if ( s().state == LibStakingStorage.States.NextValidatorSetLocked || s().state == LibStakingStorage.States.ReadyForNextEpoch ) { unlockEpoch(); } } function adminSlashValidator( address validatorStakerAddress, uint256 amountToPenalize ) external onlyOwner { StakingBalancesFacet stakingBalances = StakingBalancesFacet( views().getStakingBalancesAddress() ); stakingBalances.penalizeTokens( amountToPenalize, validatorStakerAddress ); } function removeValidatorFromNextEpoch(address staker) internal { if (s().validatorsInNextEpoch.contains(staker)) { // remove them s().validatorsInNextEpoch.remove(staker); } LibStakingStorage.Validator memory validator = s().validators[staker]; bytes32 commsKeysHash = keccak256( abi.encodePacked(validator.senderPubKey, validator.receiverPubKey) ); s().usedCommsKeys[commsKeysHash] = false; } function adminRejoinValidator(address staker) external onlyOwner { if ( !(s().state == LibStakingStorage.States.Active || s().state == LibStakingStorage.States.Unlocked || s().state == LibStakingStorage.States.Paused) ) { revert MustBeInActiveOrUnlockedOrPausedState(s().state); } // remove from next validator kicked list s().validatorsKickedFromNextEpoch.remove(staker); // remove from current validator kicked list s().currentValidatorsKickedFromNextEpoch.remove(staker); // add to next validator set s().validatorsInNextEpoch.add(staker); emit ValidatorRejoinedNextEpoch(staker); } function setConfig( uint256 newTokenRewardPerTokenPerEpoch, uint256 newComplaintTolerance, uint256 newComplaintIntervalSecs, uint256[] memory newKeyTypes, uint256 newMinimumValidatorCount, uint256 newMaxConcurrentRequests, uint256 newMaxTripleCount, uint256 newMinTripleCount, uint256 newPeerCheckingIntervalSecs, uint256 newMaxTripleConcurrency ) external onlyOwner { require( newMinTripleCount <= newMaxTripleCount, "min triple count must be less than or equal to max triple count" ); mutableConfig() .tokenRewardPerTokenPerEpoch = newTokenRewardPerTokenPerEpoch; mutableConfig().complaintTolerance = newComplaintTolerance; mutableConfig().complaintIntervalSecs = newComplaintIntervalSecs; mutableConfig().keyTypes = newKeyTypes; mutableConfig().minimumValidatorCount = newMinimumValidatorCount; mutableConfig().maxConcurrentRequests = newMaxConcurrentRequests; mutableConfig().maxTripleCount = newMaxTripleCount; mutableConfig().minTripleCount = newMinTripleCount; mutableConfig().peerCheckingIntervalSecs = newPeerCheckingIntervalSecs; mutableConfig().maxTripleConcurrency = newMaxTripleConcurrency; emit ConfigSet( newTokenRewardPerTokenPerEpoch, newComplaintTolerance, newComplaintIntervalSecs, newKeyTypes, newMinimumValidatorCount, newMaxConcurrentRequests, newMaxTripleCount, newMinTripleCount, newPeerCheckingIntervalSecs, newMaxTripleConcurrency ); } function adminResetEpoch() external onlyOwner { require(s().env == ContractResolver.Env.Dev, "only for dev env"); // clear out validators in current epoch clearEnumerableAddressSet(s().validatorsInCurrentEpoch); // clear out validators in next epoch clearEnumerableAddressSet(s().validatorsInNextEpoch); // clear out the validators kicked from next epoch clearEnumerableAddressSet(s().validatorsKickedFromNextEpoch); // clear out the current validators kicked from next epoch clearEnumerableAddressSet(s().currentValidatorsKickedFromNextEpoch); // reset the epoch mutableEpoch().number = 1; mutableEpoch().endTime = block.timestamp + mutableEpoch().epochLength; mutableEpoch().retries = 0; // reset the state s().state = LibStakingStorage.States.Paused; emit StateChanged(s().state); } function unlockEpoch() internal { // this should only be callable from the ReadyForNextEpoch state or the NextValidatorSetLocked state if ( !(s().state == LibStakingStorage.States.ReadyForNextEpoch || s().state == LibStakingStorage.States.NextValidatorSetLocked) ) { revert MustBeInNextValidatorSetLockedOrReadyForNextEpochState( s().state ); } // clear out readyForNextEpoch for current nodes uint256 validatorLength = s().validatorsInCurrentEpoch.length(); for (uint256 i = 0; i < validatorLength; i++) { s().readyForNextEpoch[s().validatorsInCurrentEpoch.at(i)] = false; } // clear out readyForNextEpoch for next nodes validatorLength = s().validatorsInNextEpoch.length(); for (uint256 i = 0; i < validatorLength; i++) { s().readyForNextEpoch[s().validatorsInNextEpoch.at(i)] = false; } s().state = LibStakingStorage.States.Unlocked; s().epochs[0].retries++; emit StateChanged(s().state); } /* ========== EVENTS ========== */ event RewardsDurationUpdated(uint256 newDuration); event RequestToJoin(address indexed staker); event RequestToLeave(address indexed staker); event Recovered(address token, uint256 amount); event ReadyForNextEpoch(address indexed staker, uint256 epochNumber); event StateChanged(LibStakingStorage.States newState); event VotedToKickValidatorInNextEpoch( address indexed reporter, address indexed validatorStakerAddress, uint256 indexed reason, bytes data ); event ValidatorKickedFromNextEpoch( address indexed staker, uint256 amountBurned ); // onlyOwner events event EpochLengthSet(uint256 newEpochLength); event EpochTimeoutSet(uint256 newEpochTimeout); event EpochEndTimeSet(uint256 newEpochEndTime); event StakingTokenSet(address newStakingTokenAddress); event KickPenaltyPercentSet(uint256 reason, uint256 newKickPenaltyPercent); event ResolverContractAddressSet(address newResolverContractAddress); event ConfigSet( uint256 newTokenRewardPerTokenPerEpoch, uint256 newComplaintTolerance, uint256 newComplaintIntervalSecs, uint256[] newKeyTypes, uint256 newMinimumValidatorCount, uint256 newMaxConcurrentRequests, uint256 newMaxTripleCount, uint256 newMinTripleCount, uint256 newPeerCheckingIntervalSecs, uint256 newMaxTripleConcurrency ); event ValidatorRejoinedNextEpoch(address staker); }
contracts/lit-node/Staking/StakingViewsFacet.sol
//SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.17; import { IERC20Metadata } from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol"; import { EnumerableSet } from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; import { StakingBalancesFacet } from "../StakingBalances/StakingBalancesFacet.sol"; import { ContractResolver } from "../../lit-core/ContractResolver.sol"; import { LibDiamond } from "../../libraries/LibDiamond.sol"; import { LibStakingStorage } from "./LibStakingStorage.sol"; // import "hardhat/console.sol"; contract StakingViewsFacet { using EnumerableSet for EnumerableSet.AddressSet; /* ========== VIEWS ========== */ function stakingStorage() internal pure returns (LibStakingStorage.StakingStorage storage) { return LibStakingStorage.getStorage(); } function epoch() public view returns (LibStakingStorage.Epoch memory) { return stakingStorage().epochs[0]; } function config() public view returns (LibStakingStorage.Config memory) { return stakingStorage().configs[0]; } function getKeyTypes() external view returns (uint256[] memory) { return config().keyTypes; } function contractResolver() external view returns (address) { return address(stakingStorage().contractResolver); } function kickPenaltyPercentByReason( uint256 reason ) external view returns (uint256) { return stakingStorage().kickPenaltyPercentByReason[reason]; } function nodeAddressToStakerAddress( address nodeAddress ) external view returns (address) { return stakingStorage().nodeAddressToStakerAddress[nodeAddress]; } function readyForNextEpoch( address stakerAddress ) external view returns (bool) { return stakingStorage().readyForNextEpoch[stakerAddress]; } function state() external view returns (LibStakingStorage.States) { return stakingStorage().state; } /// get the token address from the resolver function getTokenAddress() public view returns (address) { return stakingStorage().contractResolver.getContract( stakingStorage().contractResolver.LIT_TOKEN_CONTRACT(), stakingStorage().env ); } // get the staking balances address from the resolver function getStakingBalancesAddress() public view returns (address) { return stakingStorage().contractResolver.getContract( stakingStorage().contractResolver.STAKING_BALANCES_CONTRACT(), stakingStorage().env ); } function validators( address stakerAddress ) public view returns (LibStakingStorage.Validator memory) { return stakingStorage().validators[stakerAddress]; } function isActiveValidator(address account) external view returns (bool) { return stakingStorage().validatorsInCurrentEpoch.contains(account); } function isActiveValidatorByNodeAddress( address account ) external view returns (bool) { return stakingStorage().validatorsInCurrentEpoch.contains( stakingStorage().nodeAddressToStakerAddress[account] ); } function getVotingStatusToKickValidator( uint256 epochNumber, address validatorStakerAddress, address voterStakerAddress ) external view returns (uint256, bool) { LibStakingStorage.VoteToKickValidatorInNextEpoch storage votingStatus = stakingStorage() .votesToKickValidatorsInNextEpoch[epochNumber][ validatorStakerAddress ]; return (votingStatus.votes, votingStatus.voted[voterStakerAddress]); } function getValidatorsInCurrentEpoch() public view returns (address[] memory) { address[] memory values = new address[]( stakingStorage().validatorsInCurrentEpoch.length() ); uint256 validatorLength = stakingStorage() .validatorsInCurrentEpoch .length(); for (uint256 i = 0; i < validatorLength; i++) { values[i] = stakingStorage().validatorsInCurrentEpoch.at(i); } return values; } function getValidatorsInCurrentEpochLength() external view returns (uint256) { return stakingStorage().validatorsInCurrentEpoch.length(); } function getValidatorsInNextEpoch() public view returns (address[] memory) { address[] memory values = new address[]( stakingStorage().validatorsInNextEpoch.length() ); uint256 validatorLength = stakingStorage() .validatorsInNextEpoch .length(); for (uint256 i = 0; i < validatorLength; i++) { values[i] = stakingStorage().validatorsInNextEpoch.at(i); } return values; } function getValidatorsStructs( address[] memory addresses ) public view returns (LibStakingStorage.Validator[] memory) { LibStakingStorage.Validator[] memory values = new LibStakingStorage.Validator[](addresses.length); for (uint256 i = 0; i < addresses.length; i++) { values[i] = stakingStorage().validators[addresses[i]]; } return values; } function getValidatorsStructsInCurrentEpoch() external view returns (LibStakingStorage.Validator[] memory) { address[] memory addresses = getValidatorsInCurrentEpoch(); return getValidatorsStructs(addresses); } function getValidatorsStructsInNextEpoch() external view returns (LibStakingStorage.Validator[] memory) { address[] memory addresses = getValidatorsInNextEpoch(); return getValidatorsStructs(addresses); } function getNodeStakerAddressMappings( address[] memory addresses ) public view returns (LibStakingStorage.AddressMapping[] memory) { LibStakingStorage.AddressMapping[] memory values = new LibStakingStorage.AddressMapping[]( addresses.length ); for (uint256 i = 0; i < addresses.length; i++) { values[i].nodeAddress = addresses[i]; values[i].stakerAddress = stakingStorage() .nodeAddressToStakerAddress[addresses[i]]; } return values; } function countOfCurrentValidatorsReadyForNextEpoch() public view returns (uint256) { uint256 total = 0; uint256 validatorLength = stakingStorage() .validatorsInCurrentEpoch .length(); for (uint256 i = 0; i < validatorLength; i++) { if ( stakingStorage().readyForNextEpoch[ stakingStorage().validatorsInCurrentEpoch.at(i) ] ) { total++; } } return total; } function countOfNextValidatorsReadyForNextEpoch() public view returns (uint256) { uint256 total = 0; uint256 validatorLength = stakingStorage() .validatorsInNextEpoch .length(); for (uint256 i = 0; i < validatorLength; i++) { if ( stakingStorage().readyForNextEpoch[ stakingStorage().validatorsInNextEpoch.at(i) ] ) { total++; } } return total; } function isReadyForNextEpoch() public view returns (bool) { // confirm that current validator set is ready if ( countOfCurrentValidatorsReadyForNextEpoch() < currentValidatorCountForConsensus() ) { return false; } // confirm that next validator set is ready if ( countOfNextValidatorsReadyForNextEpoch() < nextValidatorCountForConsensus() ) { return false; } return true; } function shouldKickValidator( address stakerAddress ) public view returns (bool) { if ( stakingStorage() .votesToKickValidatorsInNextEpoch[epoch().number][stakerAddress] .votes >= currentValidatorCountForConsensus() ) { // 2/3 of validators must vote return true; } return false; } // currently set to 2/3. this could be changed to be configurable. function currentValidatorCountForConsensus() public view returns (uint256) { if (stakingStorage().validatorsInCurrentEpoch.length() == 2) { return 1; } return (stakingStorage().validatorsInCurrentEpoch.length() * 2) / 3; } /// require all nodes in the next validator set to vote that they're ready /// any offline nodes will be kicked from the next validator set so that's why this is safe function nextValidatorCountForConsensus() public view returns (uint256) { return stakingStorage().validatorsInNextEpoch.length(); } function getKickedValidators() public view returns (address[] memory) { address[] memory values = new address[]( stakingStorage().validatorsKickedFromNextEpoch.length() ); uint256 validatorLength = stakingStorage() .validatorsKickedFromNextEpoch .length(); for (uint256 i = 0; i < validatorLength; i++) { values[i] = stakingStorage().validatorsKickedFromNextEpoch.at(i); } return values; } }
contracts/lit-node/StakingBalances/LibStakingBalancesStorage.sol
//SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.17; import { EnumerableSet } from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; import { BitMaps } from "@openzeppelin/contracts/utils/structs/BitMaps.sol"; import "solidity-bytes-utils/contracts/BytesLib.sol"; import { ContractResolver } from "../../lit-core/ContractResolver.sol"; library LibStakingBalancesStorage { using EnumerableSet for EnumerableSet.AddressSet; struct VoteToKickValidatorInNextEpoch { uint256 votes; mapping(address => bool) voted; } bytes32 constant STAKING_BALANCES_POSITION = keccak256("stakingbalances.storage"); struct StakingBalancesStorage { ContractResolver contractResolver; ContractResolver.Env env; mapping(address => uint256) balances; mapping(address => uint256) rewards; // allowed stakers mapping(address => bool) permittedStakers; // maps alias address to real staker address mapping(address => address) aliases; // maps staker address to alias count mapping(address => uint256) aliasCounts; uint256 minimumStake; uint256 maximumStake; uint256 totalStaked; bool permittedStakersOn; uint256 maxAliasCount; uint256 penaltyBalance; } // Return ERC721 storage struct for reading and writing function getStorage() internal pure returns (StakingBalancesStorage storage storageStruct) { bytes32 position = STAKING_BALANCES_POSITION; assembly { storageStruct.slot := position } } }
hardhat/console.sol
// SPDX-License-Identifier: MIT pragma solidity >=0.4.22 <0.9.0; library console { address constant CONSOLE_ADDRESS = 0x000000000000000000636F6e736F6c652e6c6f67; function _sendLogPayloadImplementation(bytes memory payload) internal view { address consoleAddress = CONSOLE_ADDRESS; /// @solidity memory-safe-assembly assembly { pop( staticcall( gas(), consoleAddress, add(payload, 32), mload(payload), 0, 0 ) ) } } function _castToPure( function(bytes memory) internal view fnIn ) internal pure returns (function(bytes memory) pure fnOut) { assembly { fnOut := fnIn } } function _sendLogPayload(bytes memory payload) internal pure { _castToPure(_sendLogPayloadImplementation)(payload); } function log() internal pure { _sendLogPayload(abi.encodeWithSignature("log()")); } function logInt(int256 p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(int256)", p0)); } function logUint(uint256 p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256)", p0)); } function logString(string memory p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string)", p0)); } function logBool(bool p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool)", p0)); } function logAddress(address p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address)", p0)); } function logBytes(bytes memory p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bytes)", p0)); } function logBytes1(bytes1 p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bytes1)", p0)); } function logBytes2(bytes2 p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bytes2)", p0)); } function logBytes3(bytes3 p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bytes3)", p0)); } function logBytes4(bytes4 p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bytes4)", p0)); } function logBytes5(bytes5 p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bytes5)", p0)); } function logBytes6(bytes6 p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bytes6)", p0)); } function logBytes7(bytes7 p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bytes7)", p0)); } function logBytes8(bytes8 p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bytes8)", p0)); } function logBytes9(bytes9 p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bytes9)", p0)); } function logBytes10(bytes10 p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bytes10)", p0)); } function logBytes11(bytes11 p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bytes11)", p0)); } function logBytes12(bytes12 p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bytes12)", p0)); } function logBytes13(bytes13 p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bytes13)", p0)); } function logBytes14(bytes14 p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bytes14)", p0)); } function logBytes15(bytes15 p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bytes15)", p0)); } function logBytes16(bytes16 p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bytes16)", p0)); } function logBytes17(bytes17 p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bytes17)", p0)); } function logBytes18(bytes18 p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bytes18)", p0)); } function logBytes19(bytes19 p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bytes19)", p0)); } function logBytes20(bytes20 p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bytes20)", p0)); } function logBytes21(bytes21 p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bytes21)", p0)); } function logBytes22(bytes22 p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bytes22)", p0)); } function logBytes23(bytes23 p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bytes23)", p0)); } function logBytes24(bytes24 p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bytes24)", p0)); } function logBytes25(bytes25 p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bytes25)", p0)); } function logBytes26(bytes26 p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bytes26)", p0)); } function logBytes27(bytes27 p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bytes27)", p0)); } function logBytes28(bytes28 p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bytes28)", p0)); } function logBytes29(bytes29 p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bytes29)", p0)); } function logBytes30(bytes30 p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bytes30)", p0)); } function logBytes31(bytes31 p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bytes31)", p0)); } function logBytes32(bytes32 p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bytes32)", p0)); } function log(uint256 p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256)", p0)); } function log(string memory p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string)", p0)); } function log(bool p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool)", p0)); } function log(address p0) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address)", p0)); } function log(uint256 p0, uint256 p1) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,uint256)", p0, p1)); } function log(uint256 p0, string memory p1) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,string)", p0, p1)); } function log(uint256 p0, bool p1) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,bool)", p0, p1)); } function log(uint256 p0, address p1) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,address)", p0, p1)); } function log(string memory p0, uint256 p1) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,uint256)", p0, p1)); } function log(string memory p0, string memory p1) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,string)", p0, p1)); } function log(string memory p0, bool p1) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,bool)", p0, p1)); } function log(string memory p0, address p1) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,address)", p0, p1)); } function log(bool p0, uint256 p1) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,uint256)", p0, p1)); } function log(bool p0, string memory p1) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,string)", p0, p1)); } function log(bool p0, bool p1) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,bool)", p0, p1)); } function log(bool p0, address p1) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,address)", p0, p1)); } function log(address p0, uint256 p1) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,uint256)", p0, p1)); } function log(address p0, string memory p1) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,string)", p0, p1)); } function log(address p0, bool p1) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,bool)", p0, p1)); } function log(address p0, address p1) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,address)", p0, p1)); } function log(uint256 p0, uint256 p1, uint256 p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,uint256)", p0, p1, p2)); } function log(uint256 p0, uint256 p1, string memory p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,string)", p0, p1, p2)); } function log(uint256 p0, uint256 p1, bool p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,bool)", p0, p1, p2)); } function log(uint256 p0, uint256 p1, address p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,address)", p0, p1, p2)); } function log(uint256 p0, string memory p1, uint256 p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,string,uint256)", p0, p1, p2)); } function log(uint256 p0, string memory p1, string memory p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,string,string)", p0, p1, p2)); } function log(uint256 p0, string memory p1, bool p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,string,bool)", p0, p1, p2)); } function log(uint256 p0, string memory p1, address p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,string,address)", p0, p1, p2)); } function log(uint256 p0, bool p1, uint256 p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,bool,uint256)", p0, p1, p2)); } function log(uint256 p0, bool p1, string memory p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,bool,string)", p0, p1, p2)); } function log(uint256 p0, bool p1, bool p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,bool,bool)", p0, p1, p2)); } function log(uint256 p0, bool p1, address p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,bool,address)", p0, p1, p2)); } function log(uint256 p0, address p1, uint256 p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,address,uint256)", p0, p1, p2)); } function log(uint256 p0, address p1, string memory p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,address,string)", p0, p1, p2)); } function log(uint256 p0, address p1, bool p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,address,bool)", p0, p1, p2)); } function log(uint256 p0, address p1, address p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,address,address)", p0, p1, p2)); } function log(string memory p0, uint256 p1, uint256 p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,uint256,uint256)", p0, p1, p2)); } function log(string memory p0, uint256 p1, string memory p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,uint256,string)", p0, p1, p2)); } function log(string memory p0, uint256 p1, bool p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,uint256,bool)", p0, p1, p2)); } function log(string memory p0, uint256 p1, address p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,uint256,address)", p0, p1, p2)); } function log(string memory p0, string memory p1, uint256 p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,string,uint256)", p0, p1, p2)); } function log(string memory p0, string memory p1, string memory p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,string,string)", p0, p1, p2)); } function log(string memory p0, string memory p1, bool p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,string,bool)", p0, p1, p2)); } function log(string memory p0, string memory p1, address p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,string,address)", p0, p1, p2)); } function log(string memory p0, bool p1, uint256 p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,bool,uint256)", p0, p1, p2)); } function log(string memory p0, bool p1, string memory p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,bool,string)", p0, p1, p2)); } function log(string memory p0, bool p1, bool p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,bool,bool)", p0, p1, p2)); } function log(string memory p0, bool p1, address p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,bool,address)", p0, p1, p2)); } function log(string memory p0, address p1, uint256 p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,address,uint256)", p0, p1, p2)); } function log(string memory p0, address p1, string memory p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,address,string)", p0, p1, p2)); } function log(string memory p0, address p1, bool p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,address,bool)", p0, p1, p2)); } function log(string memory p0, address p1, address p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,address,address)", p0, p1, p2)); } function log(bool p0, uint256 p1, uint256 p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,uint256,uint256)", p0, p1, p2)); } function log(bool p0, uint256 p1, string memory p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,uint256,string)", p0, p1, p2)); } function log(bool p0, uint256 p1, bool p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,uint256,bool)", p0, p1, p2)); } function log(bool p0, uint256 p1, address p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,uint256,address)", p0, p1, p2)); } function log(bool p0, string memory p1, uint256 p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,string,uint256)", p0, p1, p2)); } function log(bool p0, string memory p1, string memory p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,string,string)", p0, p1, p2)); } function log(bool p0, string memory p1, bool p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,string,bool)", p0, p1, p2)); } function log(bool p0, string memory p1, address p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,string,address)", p0, p1, p2)); } function log(bool p0, bool p1, uint256 p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint256)", p0, p1, p2)); } function log(bool p0, bool p1, string memory p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,string)", p0, p1, p2)); } function log(bool p0, bool p1, bool p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool)", p0, p1, p2)); } function log(bool p0, bool p1, address p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,address)", p0, p1, p2)); } function log(bool p0, address p1, uint256 p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,address,uint256)", p0, p1, p2)); } function log(bool p0, address p1, string memory p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,address,string)", p0, p1, p2)); } function log(bool p0, address p1, bool p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,address,bool)", p0, p1, p2)); } function log(bool p0, address p1, address p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,address,address)", p0, p1, p2)); } function log(address p0, uint256 p1, uint256 p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,uint256,uint256)", p0, p1, p2)); } function log(address p0, uint256 p1, string memory p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,uint256,string)", p0, p1, p2)); } function log(address p0, uint256 p1, bool p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,uint256,bool)", p0, p1, p2)); } function log(address p0, uint256 p1, address p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,uint256,address)", p0, p1, p2)); } function log(address p0, string memory p1, uint256 p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,string,uint256)", p0, p1, p2)); } function log(address p0, string memory p1, string memory p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,string,string)", p0, p1, p2)); } function log(address p0, string memory p1, bool p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,string,bool)", p0, p1, p2)); } function log(address p0, string memory p1, address p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,string,address)", p0, p1, p2)); } function log(address p0, bool p1, uint256 p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,bool,uint256)", p0, p1, p2)); } function log(address p0, bool p1, string memory p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,bool,string)", p0, p1, p2)); } function log(address p0, bool p1, bool p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,bool,bool)", p0, p1, p2)); } function log(address p0, bool p1, address p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,bool,address)", p0, p1, p2)); } function log(address p0, address p1, uint256 p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,address,uint256)", p0, p1, p2)); } function log(address p0, address p1, string memory p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,address,string)", p0, p1, p2)); } function log(address p0, address p1, bool p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,address,bool)", p0, p1, p2)); } function log(address p0, address p1, address p2) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,address,address)", p0, p1, p2)); } function log(uint256 p0, uint256 p1, uint256 p2, uint256 p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,uint256,uint256)", p0, p1, p2, p3)); } function log(uint256 p0, uint256 p1, uint256 p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,uint256,string)", p0, p1, p2, p3)); } function log(uint256 p0, uint256 p1, uint256 p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,uint256,bool)", p0, p1, p2, p3)); } function log(uint256 p0, uint256 p1, uint256 p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,uint256,address)", p0, p1, p2, p3)); } function log(uint256 p0, uint256 p1, string memory p2, uint256 p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,string,uint256)", p0, p1, p2, p3)); } function log(uint256 p0, uint256 p1, string memory p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,string,string)", p0, p1, p2, p3)); } function log(uint256 p0, uint256 p1, string memory p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,string,bool)", p0, p1, p2, p3)); } function log(uint256 p0, uint256 p1, string memory p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,string,address)", p0, p1, p2, p3)); } function log(uint256 p0, uint256 p1, bool p2, uint256 p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,bool,uint256)", p0, p1, p2, p3)); } function log(uint256 p0, uint256 p1, bool p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,bool,string)", p0, p1, p2, p3)); } function log(uint256 p0, uint256 p1, bool p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,bool,bool)", p0, p1, p2, p3)); } function log(uint256 p0, uint256 p1, bool p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,bool,address)", p0, p1, p2, p3)); } function log(uint256 p0, uint256 p1, address p2, uint256 p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,address,uint256)", p0, p1, p2, p3)); } function log(uint256 p0, uint256 p1, address p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,address,string)", p0, p1, p2, p3)); } function log(uint256 p0, uint256 p1, address p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,address,bool)", p0, p1, p2, p3)); } function log(uint256 p0, uint256 p1, address p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,address,address)", p0, p1, p2, p3)); } function log(uint256 p0, string memory p1, uint256 p2, uint256 p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,string,uint256,uint256)", p0, p1, p2, p3)); } function log(uint256 p0, string memory p1, uint256 p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,string,uint256,string)", p0, p1, p2, p3)); } function log(uint256 p0, string memory p1, uint256 p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,string,uint256,bool)", p0, p1, p2, p3)); } function log(uint256 p0, string memory p1, uint256 p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,string,uint256,address)", p0, p1, p2, p3)); } function log(uint256 p0, string memory p1, string memory p2, uint256 p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,string,string,uint256)", p0, p1, p2, p3)); } function log(uint256 p0, string memory p1, string memory p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,string,string,string)", p0, p1, p2, p3)); } function log(uint256 p0, string memory p1, string memory p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,string,string,bool)", p0, p1, p2, p3)); } function log(uint256 p0, string memory p1, string memory p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,string,string,address)", p0, p1, p2, p3)); } function log(uint256 p0, string memory p1, bool p2, uint256 p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,string,bool,uint256)", p0, p1, p2, p3)); } function log(uint256 p0, string memory p1, bool p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,string,bool,string)", p0, p1, p2, p3)); } function log(uint256 p0, string memory p1, bool p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,string,bool,bool)", p0, p1, p2, p3)); } function log(uint256 p0, string memory p1, bool p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,string,bool,address)", p0, p1, p2, p3)); } function log(uint256 p0, string memory p1, address p2, uint256 p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,string,address,uint256)", p0, p1, p2, p3)); } function log(uint256 p0, string memory p1, address p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,string,address,string)", p0, p1, p2, p3)); } function log(uint256 p0, string memory p1, address p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,string,address,bool)", p0, p1, p2, p3)); } function log(uint256 p0, string memory p1, address p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,string,address,address)", p0, p1, p2, p3)); } function log(uint256 p0, bool p1, uint256 p2, uint256 p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,bool,uint256,uint256)", p0, p1, p2, p3)); } function log(uint256 p0, bool p1, uint256 p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,bool,uint256,string)", p0, p1, p2, p3)); } function log(uint256 p0, bool p1, uint256 p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,bool,uint256,bool)", p0, p1, p2, p3)); } function log(uint256 p0, bool p1, uint256 p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,bool,uint256,address)", p0, p1, p2, p3)); } function log(uint256 p0, bool p1, string memory p2, uint256 p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,bool,string,uint256)", p0, p1, p2, p3)); } function log(uint256 p0, bool p1, string memory p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,bool,string,string)", p0, p1, p2, p3)); } function log(uint256 p0, bool p1, string memory p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,bool,string,bool)", p0, p1, p2, p3)); } function log(uint256 p0, bool p1, string memory p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,bool,string,address)", p0, p1, p2, p3)); } function log(uint256 p0, bool p1, bool p2, uint256 p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,bool,bool,uint256)", p0, p1, p2, p3)); } function log(uint256 p0, bool p1, bool p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,bool,bool,string)", p0, p1, p2, p3)); } function log(uint256 p0, bool p1, bool p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,bool,bool,bool)", p0, p1, p2, p3)); } function log(uint256 p0, bool p1, bool p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,bool,bool,address)", p0, p1, p2, p3)); } function log(uint256 p0, bool p1, address p2, uint256 p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,bool,address,uint256)", p0, p1, p2, p3)); } function log(uint256 p0, bool p1, address p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,bool,address,string)", p0, p1, p2, p3)); } function log(uint256 p0, bool p1, address p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,bool,address,bool)", p0, p1, p2, p3)); } function log(uint256 p0, bool p1, address p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,bool,address,address)", p0, p1, p2, p3)); } function log(uint256 p0, address p1, uint256 p2, uint256 p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,address,uint256,uint256)", p0, p1, p2, p3)); } function log(uint256 p0, address p1, uint256 p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,address,uint256,string)", p0, p1, p2, p3)); } function log(uint256 p0, address p1, uint256 p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,address,uint256,bool)", p0, p1, p2, p3)); } function log(uint256 p0, address p1, uint256 p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,address,uint256,address)", p0, p1, p2, p3)); } function log(uint256 p0, address p1, string memory p2, uint256 p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,address,string,uint256)", p0, p1, p2, p3)); } function log(uint256 p0, address p1, string memory p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,address,string,string)", p0, p1, p2, p3)); } function log(uint256 p0, address p1, string memory p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,address,string,bool)", p0, p1, p2, p3)); } function log(uint256 p0, address p1, string memory p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,address,string,address)", p0, p1, p2, p3)); } function log(uint256 p0, address p1, bool p2, uint256 p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,address,bool,uint256)", p0, p1, p2, p3)); } function log(uint256 p0, address p1, bool p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,address,bool,string)", p0, p1, p2, p3)); } function log(uint256 p0, address p1, bool p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,address,bool,bool)", p0, p1, p2, p3)); } function log(uint256 p0, address p1, bool p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,address,bool,address)", p0, p1, p2, p3)); } function log(uint256 p0, address p1, address p2, uint256 p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,address,address,uint256)", p0, p1, p2, p3)); } function log(uint256 p0, address p1, address p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,address,address,string)", p0, p1, p2, p3)); } function log(uint256 p0, address p1, address p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,address,address,bool)", p0, p1, p2, p3)); } function log(uint256 p0, address p1, address p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(uint256,address,address,address)", p0, p1, p2, p3)); } function log(string memory p0, uint256 p1, uint256 p2, uint256 p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,uint256,uint256,uint256)", p0, p1, p2, p3)); } function log(string memory p0, uint256 p1, uint256 p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,uint256,uint256,string)", p0, p1, p2, p3)); } function log(string memory p0, uint256 p1, uint256 p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,uint256,uint256,bool)", p0, p1, p2, p3)); } function log(string memory p0, uint256 p1, uint256 p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,uint256,uint256,address)", p0, p1, p2, p3)); } function log(string memory p0, uint256 p1, string memory p2, uint256 p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,uint256,string,uint256)", p0, p1, p2, p3)); } function log(string memory p0, uint256 p1, string memory p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,uint256,string,string)", p0, p1, p2, p3)); } function log(string memory p0, uint256 p1, string memory p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,uint256,string,bool)", p0, p1, p2, p3)); } function log(string memory p0, uint256 p1, string memory p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,uint256,string,address)", p0, p1, p2, p3)); } function log(string memory p0, uint256 p1, bool p2, uint256 p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,uint256,bool,uint256)", p0, p1, p2, p3)); } function log(string memory p0, uint256 p1, bool p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,uint256,bool,string)", p0, p1, p2, p3)); } function log(string memory p0, uint256 p1, bool p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,uint256,bool,bool)", p0, p1, p2, p3)); } function log(string memory p0, uint256 p1, bool p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,uint256,bool,address)", p0, p1, p2, p3)); } function log(string memory p0, uint256 p1, address p2, uint256 p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,uint256,address,uint256)", p0, p1, p2, p3)); } function log(string memory p0, uint256 p1, address p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,uint256,address,string)", p0, p1, p2, p3)); } function log(string memory p0, uint256 p1, address p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,uint256,address,bool)", p0, p1, p2, p3)); } function log(string memory p0, uint256 p1, address p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,uint256,address,address)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, uint256 p2, uint256 p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,string,uint256,uint256)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, uint256 p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,string,uint256,string)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, uint256 p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,string,uint256,bool)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, uint256 p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,string,uint256,address)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, string memory p2, uint256 p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,string,string,uint256)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, string memory p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,string,string,string)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, string memory p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,string,string,bool)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, string memory p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,string,string,address)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, bool p2, uint256 p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,string,bool,uint256)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, bool p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,string,bool,string)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, bool p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,string,bool,bool)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, bool p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,string,bool,address)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, address p2, uint256 p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,string,address,uint256)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, address p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,string,address,string)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, address p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,string,address,bool)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, address p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,string,address,address)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, uint256 p2, uint256 p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,bool,uint256,uint256)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, uint256 p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,bool,uint256,string)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, uint256 p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,bool,uint256,bool)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, uint256 p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,bool,uint256,address)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, string memory p2, uint256 p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,bool,string,uint256)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, string memory p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,bool,string,string)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, string memory p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,bool,string,bool)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, string memory p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,bool,string,address)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, bool p2, uint256 p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,bool,bool,uint256)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, bool p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,bool,bool,string)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, bool p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,bool,bool,bool)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, bool p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,bool,bool,address)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, address p2, uint256 p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,bool,address,uint256)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, address p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,bool,address,string)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, address p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,bool,address,bool)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, address p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,bool,address,address)", p0, p1, p2, p3)); } function log(string memory p0, address p1, uint256 p2, uint256 p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,address,uint256,uint256)", p0, p1, p2, p3)); } function log(string memory p0, address p1, uint256 p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,address,uint256,string)", p0, p1, p2, p3)); } function log(string memory p0, address p1, uint256 p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,address,uint256,bool)", p0, p1, p2, p3)); } function log(string memory p0, address p1, uint256 p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,address,uint256,address)", p0, p1, p2, p3)); } function log(string memory p0, address p1, string memory p2, uint256 p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,address,string,uint256)", p0, p1, p2, p3)); } function log(string memory p0, address p1, string memory p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,address,string,string)", p0, p1, p2, p3)); } function log(string memory p0, address p1, string memory p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,address,string,bool)", p0, p1, p2, p3)); } function log(string memory p0, address p1, string memory p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,address,string,address)", p0, p1, p2, p3)); } function log(string memory p0, address p1, bool p2, uint256 p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,address,bool,uint256)", p0, p1, p2, p3)); } function log(string memory p0, address p1, bool p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,address,bool,string)", p0, p1, p2, p3)); } function log(string memory p0, address p1, bool p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,address,bool,bool)", p0, p1, p2, p3)); } function log(string memory p0, address p1, bool p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,address,bool,address)", p0, p1, p2, p3)); } function log(string memory p0, address p1, address p2, uint256 p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,address,address,uint256)", p0, p1, p2, p3)); } function log(string memory p0, address p1, address p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,address,address,string)", p0, p1, p2, p3)); } function log(string memory p0, address p1, address p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,address,address,bool)", p0, p1, p2, p3)); } function log(string memory p0, address p1, address p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(string,address,address,address)", p0, p1, p2, p3)); } function log(bool p0, uint256 p1, uint256 p2, uint256 p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,uint256,uint256,uint256)", p0, p1, p2, p3)); } function log(bool p0, uint256 p1, uint256 p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,uint256,uint256,string)", p0, p1, p2, p3)); } function log(bool p0, uint256 p1, uint256 p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,uint256,uint256,bool)", p0, p1, p2, p3)); } function log(bool p0, uint256 p1, uint256 p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,uint256,uint256,address)", p0, p1, p2, p3)); } function log(bool p0, uint256 p1, string memory p2, uint256 p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,uint256,string,uint256)", p0, p1, p2, p3)); } function log(bool p0, uint256 p1, string memory p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,uint256,string,string)", p0, p1, p2, p3)); } function log(bool p0, uint256 p1, string memory p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,uint256,string,bool)", p0, p1, p2, p3)); } function log(bool p0, uint256 p1, string memory p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,uint256,string,address)", p0, p1, p2, p3)); } function log(bool p0, uint256 p1, bool p2, uint256 p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,uint256,bool,uint256)", p0, p1, p2, p3)); } function log(bool p0, uint256 p1, bool p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,uint256,bool,string)", p0, p1, p2, p3)); } function log(bool p0, uint256 p1, bool p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,uint256,bool,bool)", p0, p1, p2, p3)); } function log(bool p0, uint256 p1, bool p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,uint256,bool,address)", p0, p1, p2, p3)); } function log(bool p0, uint256 p1, address p2, uint256 p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,uint256,address,uint256)", p0, p1, p2, p3)); } function log(bool p0, uint256 p1, address p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,uint256,address,string)", p0, p1, p2, p3)); } function log(bool p0, uint256 p1, address p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,uint256,address,bool)", p0, p1, p2, p3)); } function log(bool p0, uint256 p1, address p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,uint256,address,address)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, uint256 p2, uint256 p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,string,uint256,uint256)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, uint256 p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,string,uint256,string)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, uint256 p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,string,uint256,bool)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, uint256 p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,string,uint256,address)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, string memory p2, uint256 p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,string,string,uint256)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, string memory p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,string,string,string)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, string memory p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,string,string,bool)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, string memory p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,string,string,address)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, bool p2, uint256 p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,string,bool,uint256)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, bool p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,string,bool,string)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, bool p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,string,bool,bool)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, bool p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,string,bool,address)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, address p2, uint256 p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,string,address,uint256)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, address p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,string,address,string)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, address p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,string,address,bool)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, address p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,string,address,address)", p0, p1, p2, p3)); } function log(bool p0, bool p1, uint256 p2, uint256 p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint256,uint256)", p0, p1, p2, p3)); } function log(bool p0, bool p1, uint256 p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint256,string)", p0, p1, p2, p3)); } function log(bool p0, bool p1, uint256 p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint256,bool)", p0, p1, p2, p3)); } function log(bool p0, bool p1, uint256 p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint256,address)", p0, p1, p2, p3)); } function log(bool p0, bool p1, string memory p2, uint256 p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,string,uint256)", p0, p1, p2, p3)); } function log(bool p0, bool p1, string memory p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,string,string)", p0, p1, p2, p3)); } function log(bool p0, bool p1, string memory p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,string,bool)", p0, p1, p2, p3)); } function log(bool p0, bool p1, string memory p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,string,address)", p0, p1, p2, p3)); } function log(bool p0, bool p1, bool p2, uint256 p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool,uint256)", p0, p1, p2, p3)); } function log(bool p0, bool p1, bool p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool,string)", p0, p1, p2, p3)); } function log(bool p0, bool p1, bool p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool,bool)", p0, p1, p2, p3)); } function log(bool p0, bool p1, bool p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool,address)", p0, p1, p2, p3)); } function log(bool p0, bool p1, address p2, uint256 p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,address,uint256)", p0, p1, p2, p3)); } function log(bool p0, bool p1, address p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,address,string)", p0, p1, p2, p3)); } function log(bool p0, bool p1, address p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,address,bool)", p0, p1, p2, p3)); } function log(bool p0, bool p1, address p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,address,address)", p0, p1, p2, p3)); } function log(bool p0, address p1, uint256 p2, uint256 p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,address,uint256,uint256)", p0, p1, p2, p3)); } function log(bool p0, address p1, uint256 p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,address,uint256,string)", p0, p1, p2, p3)); } function log(bool p0, address p1, uint256 p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,address,uint256,bool)", p0, p1, p2, p3)); } function log(bool p0, address p1, uint256 p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,address,uint256,address)", p0, p1, p2, p3)); } function log(bool p0, address p1, string memory p2, uint256 p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,address,string,uint256)", p0, p1, p2, p3)); } function log(bool p0, address p1, string memory p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,address,string,string)", p0, p1, p2, p3)); } function log(bool p0, address p1, string memory p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,address,string,bool)", p0, p1, p2, p3)); } function log(bool p0, address p1, string memory p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,address,string,address)", p0, p1, p2, p3)); } function log(bool p0, address p1, bool p2, uint256 p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,address,bool,uint256)", p0, p1, p2, p3)); } function log(bool p0, address p1, bool p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,address,bool,string)", p0, p1, p2, p3)); } function log(bool p0, address p1, bool p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,address,bool,bool)", p0, p1, p2, p3)); } function log(bool p0, address p1, bool p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,address,bool,address)", p0, p1, p2, p3)); } function log(bool p0, address p1, address p2, uint256 p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,address,address,uint256)", p0, p1, p2, p3)); } function log(bool p0, address p1, address p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,address,address,string)", p0, p1, p2, p3)); } function log(bool p0, address p1, address p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,address,address,bool)", p0, p1, p2, p3)); } function log(bool p0, address p1, address p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(bool,address,address,address)", p0, p1, p2, p3)); } function log(address p0, uint256 p1, uint256 p2, uint256 p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,uint256,uint256,uint256)", p0, p1, p2, p3)); } function log(address p0, uint256 p1, uint256 p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,uint256,uint256,string)", p0, p1, p2, p3)); } function log(address p0, uint256 p1, uint256 p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,uint256,uint256,bool)", p0, p1, p2, p3)); } function log(address p0, uint256 p1, uint256 p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,uint256,uint256,address)", p0, p1, p2, p3)); } function log(address p0, uint256 p1, string memory p2, uint256 p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,uint256,string,uint256)", p0, p1, p2, p3)); } function log(address p0, uint256 p1, string memory p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,uint256,string,string)", p0, p1, p2, p3)); } function log(address p0, uint256 p1, string memory p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,uint256,string,bool)", p0, p1, p2, p3)); } function log(address p0, uint256 p1, string memory p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,uint256,string,address)", p0, p1, p2, p3)); } function log(address p0, uint256 p1, bool p2, uint256 p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,uint256,bool,uint256)", p0, p1, p2, p3)); } function log(address p0, uint256 p1, bool p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,uint256,bool,string)", p0, p1, p2, p3)); } function log(address p0, uint256 p1, bool p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,uint256,bool,bool)", p0, p1, p2, p3)); } function log(address p0, uint256 p1, bool p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,uint256,bool,address)", p0, p1, p2, p3)); } function log(address p0, uint256 p1, address p2, uint256 p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,uint256,address,uint256)", p0, p1, p2, p3)); } function log(address p0, uint256 p1, address p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,uint256,address,string)", p0, p1, p2, p3)); } function log(address p0, uint256 p1, address p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,uint256,address,bool)", p0, p1, p2, p3)); } function log(address p0, uint256 p1, address p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,uint256,address,address)", p0, p1, p2, p3)); } function log(address p0, string memory p1, uint256 p2, uint256 p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,string,uint256,uint256)", p0, p1, p2, p3)); } function log(address p0, string memory p1, uint256 p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,string,uint256,string)", p0, p1, p2, p3)); } function log(address p0, string memory p1, uint256 p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,string,uint256,bool)", p0, p1, p2, p3)); } function log(address p0, string memory p1, uint256 p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,string,uint256,address)", p0, p1, p2, p3)); } function log(address p0, string memory p1, string memory p2, uint256 p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,string,string,uint256)", p0, p1, p2, p3)); } function log(address p0, string memory p1, string memory p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,string,string,string)", p0, p1, p2, p3)); } function log(address p0, string memory p1, string memory p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,string,string,bool)", p0, p1, p2, p3)); } function log(address p0, string memory p1, string memory p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,string,string,address)", p0, p1, p2, p3)); } function log(address p0, string memory p1, bool p2, uint256 p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,string,bool,uint256)", p0, p1, p2, p3)); } function log(address p0, string memory p1, bool p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,string,bool,string)", p0, p1, p2, p3)); } function log(address p0, string memory p1, bool p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,string,bool,bool)", p0, p1, p2, p3)); } function log(address p0, string memory p1, bool p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,string,bool,address)", p0, p1, p2, p3)); } function log(address p0, string memory p1, address p2, uint256 p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,string,address,uint256)", p0, p1, p2, p3)); } function log(address p0, string memory p1, address p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,string,address,string)", p0, p1, p2, p3)); } function log(address p0, string memory p1, address p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,string,address,bool)", p0, p1, p2, p3)); } function log(address p0, string memory p1, address p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,string,address,address)", p0, p1, p2, p3)); } function log(address p0, bool p1, uint256 p2, uint256 p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,bool,uint256,uint256)", p0, p1, p2, p3)); } function log(address p0, bool p1, uint256 p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,bool,uint256,string)", p0, p1, p2, p3)); } function log(address p0, bool p1, uint256 p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,bool,uint256,bool)", p0, p1, p2, p3)); } function log(address p0, bool p1, uint256 p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,bool,uint256,address)", p0, p1, p2, p3)); } function log(address p0, bool p1, string memory p2, uint256 p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,bool,string,uint256)", p0, p1, p2, p3)); } function log(address p0, bool p1, string memory p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,bool,string,string)", p0, p1, p2, p3)); } function log(address p0, bool p1, string memory p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,bool,string,bool)", p0, p1, p2, p3)); } function log(address p0, bool p1, string memory p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,bool,string,address)", p0, p1, p2, p3)); } function log(address p0, bool p1, bool p2, uint256 p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,bool,bool,uint256)", p0, p1, p2, p3)); } function log(address p0, bool p1, bool p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,bool,bool,string)", p0, p1, p2, p3)); } function log(address p0, bool p1, bool p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,bool,bool,bool)", p0, p1, p2, p3)); } function log(address p0, bool p1, bool p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,bool,bool,address)", p0, p1, p2, p3)); } function log(address p0, bool p1, address p2, uint256 p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,bool,address,uint256)", p0, p1, p2, p3)); } function log(address p0, bool p1, address p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,bool,address,string)", p0, p1, p2, p3)); } function log(address p0, bool p1, address p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,bool,address,bool)", p0, p1, p2, p3)); } function log(address p0, bool p1, address p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,bool,address,address)", p0, p1, p2, p3)); } function log(address p0, address p1, uint256 p2, uint256 p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,address,uint256,uint256)", p0, p1, p2, p3)); } function log(address p0, address p1, uint256 p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,address,uint256,string)", p0, p1, p2, p3)); } function log(address p0, address p1, uint256 p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,address,uint256,bool)", p0, p1, p2, p3)); } function log(address p0, address p1, uint256 p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,address,uint256,address)", p0, p1, p2, p3)); } function log(address p0, address p1, string memory p2, uint256 p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,address,string,uint256)", p0, p1, p2, p3)); } function log(address p0, address p1, string memory p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,address,string,string)", p0, p1, p2, p3)); } function log(address p0, address p1, string memory p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,address,string,bool)", p0, p1, p2, p3)); } function log(address p0, address p1, string memory p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,address,string,address)", p0, p1, p2, p3)); } function log(address p0, address p1, bool p2, uint256 p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,address,bool,uint256)", p0, p1, p2, p3)); } function log(address p0, address p1, bool p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,address,bool,string)", p0, p1, p2, p3)); } function log(address p0, address p1, bool p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,address,bool,bool)", p0, p1, p2, p3)); } function log(address p0, address p1, bool p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,address,bool,address)", p0, p1, p2, p3)); } function log(address p0, address p1, address p2, uint256 p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,address,address,uint256)", p0, p1, p2, p3)); } function log(address p0, address p1, address p2, string memory p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,address,address,string)", p0, p1, p2, p3)); } function log(address p0, address p1, address p2, bool p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,address,address,bool)", p0, p1, p2, p3)); } function log(address p0, address p1, address p2, address p3) internal pure { _sendLogPayload(abi.encodeWithSignature("log(address,address,address,address)", p0, p1, p2, p3)); } }
solidity-bytes-utils/contracts/BytesLib.sol
// SPDX-License-Identifier: Unlicense /* * @title Solidity Bytes Arrays Utils * @author Gonçalo Sá <goncalo.sa@consensys.net> * * @dev Bytes tightly packed arrays utility library for ethereum contracts written in Solidity. * The library lets you concatenate, slice and type cast bytes arrays both in memory and storage. */ pragma solidity >=0.8.0 <0.9.0; library BytesLib { function concat( bytes memory _preBytes, bytes memory _postBytes ) internal pure returns (bytes memory) { bytes memory tempBytes; assembly { // Get a location of some free memory and store it in tempBytes as // Solidity does for memory variables. tempBytes := mload(0x40) // Store the length of the first bytes array at the beginning of // the memory for tempBytes. let length := mload(_preBytes) mstore(tempBytes, length) // Maintain a memory counter for the current write location in the // temp bytes array by adding the 32 bytes for the array length to // the starting location. let mc := add(tempBytes, 0x20) // Stop copying when the memory counter reaches the length of the // first bytes array. let end := add(mc, length) for { // Initialize a copy counter to the start of the _preBytes data, // 32 bytes into its memory. let cc := add(_preBytes, 0x20) } lt(mc, end) { // Increase both counters by 32 bytes each iteration. mc := add(mc, 0x20) cc := add(cc, 0x20) } { // Write the _preBytes data into the tempBytes memory 32 bytes // at a time. mstore(mc, mload(cc)) } // Add the length of _postBytes to the current length of tempBytes // and store it as the new length in the first 32 bytes of the // tempBytes memory. length := mload(_postBytes) mstore(tempBytes, add(length, mload(tempBytes))) // Move the memory counter back from a multiple of 0x20 to the // actual end of the _preBytes data. mc := end // Stop copying when the memory counter reaches the new combined // length of the arrays. end := add(mc, length) for { let cc := add(_postBytes, 0x20) } lt(mc, end) { mc := add(mc, 0x20) cc := add(cc, 0x20) } { mstore(mc, mload(cc)) } // Update the free-memory pointer by padding our last write location // to 32 bytes: add 31 bytes to the end of tempBytes to move to the // next 32 byte block, then round down to the nearest multiple of // 32. If the sum of the length of the two arrays is zero then add // one before rounding down to leave a blank 32 bytes (the length block with 0). mstore(0x40, and( add(add(end, iszero(add(length, mload(_preBytes)))), 31), not(31) // Round down to the nearest 32 bytes. )) } return tempBytes; } function concatStorage(bytes storage _preBytes, bytes memory _postBytes) internal { assembly { // Read the first 32 bytes of _preBytes storage, which is the length // of the array. (We don't need to use the offset into the slot // because arrays use the entire slot.) let fslot := sload(_preBytes.slot) // Arrays of 31 bytes or less have an even value in their slot, // while longer arrays have an odd value. The actual length is // the slot divided by two for odd values, and the lowest order // byte divided by two for even values. // If the slot is even, bitwise and the slot with 255 and divide by // two to get the length. If the slot is odd, bitwise and the slot // with -1 and divide by two. let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2) let mlength := mload(_postBytes) let newlength := add(slength, mlength) // slength can contain both the length and contents of the array // if length < 32 bytes so let's prepare for that // v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage switch add(lt(slength, 32), lt(newlength, 32)) case 2 { // Since the new array still fits in the slot, we just need to // update the contents of the slot. // uint256(bytes_storage) = uint256(bytes_storage) + uint256(bytes_memory) + new_length sstore( _preBytes.slot, // all the modifications to the slot are inside this // next block add( // we can just add to the slot contents because the // bytes we want to change are the LSBs fslot, add( mul( div( // load the bytes from memory mload(add(_postBytes, 0x20)), // zero all bytes to the right exp(0x100, sub(32, mlength)) ), // and now shift left the number of bytes to // leave space for the length in the slot exp(0x100, sub(32, newlength)) ), // increase length by the double of the memory // bytes length mul(mlength, 2) ) ) ) } case 1 { // The stored value fits in the slot, but the combined value // will exceed it. // get the keccak hash to get the contents of the array mstore(0x0, _preBytes.slot) let sc := add(keccak256(0x0, 0x20), div(slength, 32)) // save new length sstore(_preBytes.slot, add(mul(newlength, 2), 1)) // The contents of the _postBytes array start 32 bytes into // the structure. Our first read should obtain the `submod` // bytes that can fit into the unused space in the last word // of the stored array. To get this, we read 32 bytes starting // from `submod`, so the data we read overlaps with the array // contents by `submod` bytes. Masking the lowest-order // `submod` bytes allows us to add that value directly to the // stored value. let submod := sub(32, slength) let mc := add(_postBytes, submod) let end := add(_postBytes, mlength) let mask := sub(exp(0x100, submod), 1) sstore( sc, add( and( fslot, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00 ), and(mload(mc), mask) ) ) for { mc := add(mc, 0x20) sc := add(sc, 1) } lt(mc, end) { sc := add(sc, 1) mc := add(mc, 0x20) } { sstore(sc, mload(mc)) } mask := exp(0x100, sub(mc, end)) sstore(sc, mul(div(mload(mc), mask), mask)) } default { // get the keccak hash to get the contents of the array mstore(0x0, _preBytes.slot) // Start copying to the last used word of the stored array. let sc := add(keccak256(0x0, 0x20), div(slength, 32)) // save new length sstore(_preBytes.slot, add(mul(newlength, 2), 1)) // Copy over the first `submod` bytes of the new data as in // case 1 above. let slengthmod := mod(slength, 32) let mlengthmod := mod(mlength, 32) let submod := sub(32, slengthmod) let mc := add(_postBytes, submod) let end := add(_postBytes, mlength) let mask := sub(exp(0x100, submod), 1) sstore(sc, add(sload(sc), and(mload(mc), mask))) for { sc := add(sc, 1) mc := add(mc, 0x20) } lt(mc, end) { sc := add(sc, 1) mc := add(mc, 0x20) } { sstore(sc, mload(mc)) } mask := exp(0x100, sub(mc, end)) sstore(sc, mul(div(mload(mc), mask), mask)) } } } function slice( bytes memory _bytes, uint256 _start, uint256 _length ) internal pure returns (bytes memory) { require(_length + 31 >= _length, "slice_overflow"); require(_bytes.length >= _start + _length, "slice_outOfBounds"); bytes memory tempBytes; assembly { switch iszero(_length) case 0 { // Get a location of some free memory and store it in tempBytes as // Solidity does for memory variables. tempBytes := mload(0x40) // The first word of the slice result is potentially a partial // word read from the original array. To read it, we calculate // the length of that partial word and start copying that many // bytes into the array. The first word we copy will start with // data we don't care about, but the last `lengthmod` bytes will // land at the beginning of the contents of the new array. When // we're done copying, we overwrite the full first word with // the actual length of the slice. let lengthmod := and(_length, 31) // The multiplication in the next line is necessary // because when slicing multiples of 32 bytes (lengthmod == 0) // the following copy loop was copying the origin's length // and then ending prematurely not copying everything it should. let mc := add(add(tempBytes, lengthmod), mul(0x20, iszero(lengthmod))) let end := add(mc, _length) for { // The multiplication in the next line has the same exact purpose // as the one above. let cc := add(add(add(_bytes, lengthmod), mul(0x20, iszero(lengthmod))), _start) } lt(mc, end) { mc := add(mc, 0x20) cc := add(cc, 0x20) } { mstore(mc, mload(cc)) } mstore(tempBytes, _length) //update free-memory pointer //allocating the array padded to 32 bytes like the compiler does now mstore(0x40, and(add(mc, 31), not(31))) } //if we want a zero-length slice let's just return a zero-length array default { tempBytes := mload(0x40) //zero out the 32 bytes slice we are about to return //we need to do it because Solidity does not garbage collect mstore(tempBytes, 0) mstore(0x40, add(tempBytes, 0x20)) } } return tempBytes; } function toAddress(bytes memory _bytes, uint256 _start) internal pure returns (address) { require(_bytes.length >= _start + 20, "toAddress_outOfBounds"); address tempAddress; assembly { tempAddress := div(mload(add(add(_bytes, 0x20), _start)), 0x1000000000000000000000000) } return tempAddress; } function toUint8(bytes memory _bytes, uint256 _start) internal pure returns (uint8) { require(_bytes.length >= _start + 1 , "toUint8_outOfBounds"); uint8 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x1), _start)) } return tempUint; } function toUint16(bytes memory _bytes, uint256 _start) internal pure returns (uint16) { require(_bytes.length >= _start + 2, "toUint16_outOfBounds"); uint16 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x2), _start)) } return tempUint; } function toUint32(bytes memory _bytes, uint256 _start) internal pure returns (uint32) { require(_bytes.length >= _start + 4, "toUint32_outOfBounds"); uint32 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x4), _start)) } return tempUint; } function toUint64(bytes memory _bytes, uint256 _start) internal pure returns (uint64) { require(_bytes.length >= _start + 8, "toUint64_outOfBounds"); uint64 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x8), _start)) } return tempUint; } function toUint96(bytes memory _bytes, uint256 _start) internal pure returns (uint96) { require(_bytes.length >= _start + 12, "toUint96_outOfBounds"); uint96 tempUint; assembly { tempUint := mload(add(add(_bytes, 0xc), _start)) } return tempUint; } function toUint128(bytes memory _bytes, uint256 _start) internal pure returns (uint128) { require(_bytes.length >= _start + 16, "toUint128_outOfBounds"); uint128 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x10), _start)) } return tempUint; } function toUint256(bytes memory _bytes, uint256 _start) internal pure returns (uint256) { require(_bytes.length >= _start + 32, "toUint256_outOfBounds"); uint256 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x20), _start)) } return tempUint; } function toBytes32(bytes memory _bytes, uint256 _start) internal pure returns (bytes32) { require(_bytes.length >= _start + 32, "toBytes32_outOfBounds"); bytes32 tempBytes32; assembly { tempBytes32 := mload(add(add(_bytes, 0x20), _start)) } return tempBytes32; } function equal(bytes memory _preBytes, bytes memory _postBytes) internal pure returns (bool) { bool success = true; assembly { let length := mload(_preBytes) // if lengths don't match the arrays are not equal switch eq(length, mload(_postBytes)) case 1 { // cb is a circuit breaker in the for loop since there's // no said feature for inline assembly loops // cb = 1 - don't breaker // cb = 0 - break let cb := 1 let mc := add(_preBytes, 0x20) let end := add(mc, length) for { let cc := add(_postBytes, 0x20) // the next line is the loop condition: // while(uint256(mc < end) + cb == 2) } eq(add(lt(mc, end), cb), 2) { mc := add(mc, 0x20) cc := add(cc, 0x20) } { // if any of these checks fails then arrays are not equal if iszero(eq(mload(mc), mload(cc))) { // unsuccess: success := 0 cb := 0 } } } default { // unsuccess: success := 0 } } return success; } function equal_nonAligned(bytes memory _preBytes, bytes memory _postBytes) internal pure returns (bool) { bool success = true; assembly { let length := mload(_preBytes) // if lengths don't match the arrays are not equal switch eq(length, mload(_postBytes)) case 1 { // cb is a circuit breaker in the for loop since there's // no said feature for inline assembly loops // cb = 1 - don't breaker // cb = 0 - break let cb := 1 let endMinusWord := add(_preBytes, length) let mc := add(_preBytes, 0x20) let cc := add(_postBytes, 0x20) for { // the next line is the loop condition: // while(uint256(mc < endWord) + cb == 2) } eq(add(lt(mc, endMinusWord), cb), 2) { mc := add(mc, 0x20) cc := add(cc, 0x20) } { // if any of these checks fails then arrays are not equal if iszero(eq(mload(mc), mload(cc))) { // unsuccess: success := 0 cb := 0 } } // Only if still successful // For <1 word tail bytes if gt(success, 0) { // Get the remainder of length/32 // length % 32 = AND(length, 32 - 1) let numTailBytes := and(length, 0x1f) let mcRem := mload(mc) let ccRem := mload(cc) for { let i := 0 // the next line is the loop condition: // while(uint256(i < numTailBytes) + cb == 2) } eq(add(lt(i, numTailBytes), cb), 2) { i := add(i, 1) } { if iszero(eq(byte(i, mcRem), byte(i, ccRem))) { // unsuccess: success := 0 cb := 0 } } } } default { // unsuccess: success := 0 } } return success; } function equalStorage( bytes storage _preBytes, bytes memory _postBytes ) internal view returns (bool) { bool success = true; assembly { // we know _preBytes_offset is 0 let fslot := sload(_preBytes.slot) // Decode the length of the stored array like in concatStorage(). let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2) let mlength := mload(_postBytes) // if lengths don't match the arrays are not equal switch eq(slength, mlength) case 1 { // slength can contain both the length and contents of the array // if length < 32 bytes so let's prepare for that // v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage if iszero(iszero(slength)) { switch lt(slength, 32) case 1 { // blank the last byte which is the length fslot := mul(div(fslot, 0x100), 0x100) if iszero(eq(fslot, mload(add(_postBytes, 0x20)))) { // unsuccess: success := 0 } } default { // cb is a circuit breaker in the for loop since there's // no said feature for inline assembly loops // cb = 1 - don't breaker // cb = 0 - break let cb := 1 // get the keccak hash to get the contents of the array mstore(0x0, _preBytes.slot) let sc := keccak256(0x0, 0x20) let mc := add(_postBytes, 0x20) let end := add(mc, mlength) // the next line is the loop condition: // while(uint256(mc < end) + cb == 2) for {} eq(add(lt(mc, end), cb), 2) { sc := add(sc, 1) mc := add(mc, 0x20) } { if iszero(eq(sload(sc), mload(mc))) { // unsuccess: success := 0 cb := 0 } } } } } default { // unsuccess: success := 0 } } return success; } }
Contract ABI
[{"type":"error","name":"ActiveValidatorsCannotLeave","inputs":[]},{"type":"error","name":"AliasNotOwnedBySender","inputs":[{"type":"address","name":"aliasAccount","internalType":"address"},{"type":"address","name":"stakerAddress","internalType":"address"}]},{"type":"error","name":"CallerNotOwner","inputs":[]},{"type":"error","name":"CannotRemoveAliasOfActiveValidator","inputs":[{"type":"address","name":"aliasAccount","internalType":"address"}]},{"type":"error","name":"CannotStakeZero","inputs":[]},{"type":"error","name":"CannotWithdrawZero","inputs":[]},{"type":"error","name":"MaxAliasCountReached","inputs":[{"type":"uint256","name":"aliasCount","internalType":"uint256"}]},{"type":"error","name":"OnlyStakingContract","inputs":[{"type":"address","name":"sender","internalType":"address"}]},{"type":"error","name":"StakeMustBeGreaterThanMinimumStake","inputs":[{"type":"uint256","name":"amountStaked","internalType":"uint256"},{"type":"uint256","name":"minimumStake","internalType":"uint256"}]},{"type":"error","name":"StakeMustBeLessThanMaximumStake","inputs":[{"type":"uint256","name":"amountStaked","internalType":"uint256"},{"type":"uint256","name":"maximumStake","internalType":"uint256"}]},{"type":"error","name":"StakerNotPermitted","inputs":[{"type":"address","name":"stakerAddress","internalType":"address"}]},{"type":"error","name":"TryingToWithdrawMoreThanStaked","inputs":[{"type":"uint256","name":"yourBalance","internalType":"uint256"},{"type":"uint256","name":"requestedWithdrawlAmount","internalType":"uint256"}]},{"type":"event","name":"AliasAdded","inputs":[{"type":"address","name":"staker","internalType":"address","indexed":true},{"type":"address","name":"aliasAccount","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"AliasRemoved","inputs":[{"type":"address","name":"staker","internalType":"address","indexed":true},{"type":"address","name":"aliasAccount","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"MaxAliasCountSet","inputs":[{"type":"uint256","name":"newMaxAliasCount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"MaximumStakeSet","inputs":[{"type":"uint256","name":"newMaximumStake","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"MinimumStakeSet","inputs":[{"type":"uint256","name":"newMinimumStake","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"PermittedStakerAdded","inputs":[{"type":"address","name":"staker","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"PermittedStakerRemoved","inputs":[{"type":"address","name":"staker","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"PermittedStakersOnChanged","inputs":[{"type":"bool","name":"permittedStakersOn","internalType":"bool","indexed":false}],"anonymous":false},{"type":"event","name":"ResolverContractAddressSet","inputs":[{"type":"address","name":"newResolverAddress","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"RewardPaid","inputs":[{"type":"address","name":"staker","internalType":"address","indexed":true},{"type":"uint256","name":"reward","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"Staked","inputs":[{"type":"address","name":"staker","internalType":"address","indexed":true},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"TokenRewardPerTokenPerEpochSet","inputs":[{"type":"uint256","name":"newTokenRewardPerTokenPerEpoch","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"ValidatorNotRewardedBecauseAlias","inputs":[{"type":"address","name":"staker","internalType":"address","indexed":true},{"type":"address","name":"aliasAccount","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"ValidatorRewarded","inputs":[{"type":"address","name":"staker","internalType":"address","indexed":true},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"ValidatorTokensPenalized","inputs":[{"type":"address","name":"staker","internalType":"address","indexed":true},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"Withdrawn","inputs":[{"type":"address","name":"staker","internalType":"address","indexed":true},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"addAlias","inputs":[{"type":"address","name":"aliasAccount","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"addPermittedStaker","inputs":[{"type":"address","name":"staker","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"addPermittedStakers","inputs":[{"type":"address[]","name":"stakers","internalType":"address[]"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"balanceOf","inputs":[{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"checkStakingAmounts","inputs":[{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"contractResolver","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"getReward","inputs":[{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"getStakingAddress","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"getTokenAddress","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isPermittedStaker","inputs":[{"type":"address","name":"staker","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"maximumStake","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"minimumStake","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"penalizeTokens","inputs":[{"type":"uint256","name":"amount","internalType":"uint256"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"permittedStakersOn","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"removeAlias","inputs":[{"type":"address","name":"aliasAccount","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"removePermittedStaker","inputs":[{"type":"address","name":"staker","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"restakePenaltyTokens","inputs":[{"type":"address","name":"staker","internalType":"address"},{"type":"uint256","name":"balance","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"rewardOf","inputs":[{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"rewardValidator","inputs":[{"type":"uint256","name":"amount","internalType":"uint256"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setContractResolver","inputs":[{"type":"address","name":"newResolverAddress","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setMaxAliasCount","inputs":[{"type":"uint256","name":"newMaxAliasCount","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setMaximumStake","inputs":[{"type":"uint256","name":"newMaximumStake","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setMinimumStake","inputs":[{"type":"uint256","name":"newMinimumStake","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setPermittedStakersOn","inputs":[{"type":"bool","name":"permitted","internalType":"bool"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"stake","inputs":[{"type":"uint256","name":"amount","internalType":"uint256"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"totalStaked","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferPenaltyTokens","inputs":[{"type":"uint256","name":"balance","internalType":"uint256"},{"type":"address","name":"recipient","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"withdraw","inputs":[{"type":"uint256","name":"amount","internalType":"uint256"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"withdraw","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"withdrawPenaltyTokens","inputs":[{"type":"uint256","name":"balance","internalType":"uint256"}]}]
Contract Creation Code
0x608060405234801561001057600080fd5b50613a65806100206000396000f3fe608060405234801561001057600080fd5b50600436106101d95760003560e01c806374c2e2fc11610104578063bcb5c636116100a2578063ddb6e6e111610071578063ddb6e6e114610500578063ec5ffac21461051c578063f21aec061461053a578063f95d71b114610556576101d9565b8063bcb5c6361461047c578063c00007b014610498578063d3dbad7d146104b4578063dc157ce2146104e4576101d9565b8063842648c2116100de578063842648c21461040a578063a498072c14610426578063b5c6b45314610442578063bc97978714610460576101d9565b806374c2e2fc146103b45780637acb7757146103d0578063817b1cd2146103ec576101d9565b8063233e99031161017c57806340b964821161014b57806340b964821461031a578063499199661461033657806350d17b5e1461036657806370a0823114610384576101d9565b8063233e9903146102ba57806327a199d0146102d65780633560db3c146102f45780633ccfd60b14610310576101d9565b80630e9ed68b116101b85780630e9ed68b1461023257806310fe9ae8146102505780631d62ebd91461026e5780631dc4ab3c1461029e576101d9565b8062f714ce146101de57806302fa04c9146101fa5780630a0e3dea14610216575b600080fd5b6101f860048036038101906101f391906131d7565b610572565b005b610214600480360381019061020f91906131d7565b6109d4565b005b610230600480360381019061022b91906131d7565b610db5565b005b61023a611029565b6040516102479190613226565b60405180910390f35b610258611188565b6040516102659190613226565b60405180910390f35b61028860048036038101906102839190613241565b6112e7565b604051610295919061327d565b60405180910390f35b6102b860048036038101906102b391906133f1565b611440565b005b6102d460048036038101906102cf919061343a565b6114f2565b005b6102de6115a8565b6040516102eb9190613482565b60405180910390f35b61030e600480360381019061030991906131d7565b6115c8565b005b610318611734565b005b610334600480360381019061032f9190613241565b61181f565b005b610350600480360381019061034b9190613241565b611a36565b60405161035d9190613482565b60405180910390f35b61036e611c50565b60405161037b9190613226565b60405180910390f35b61039e60048036038101906103999190613241565b611c83565b6040516103ab919061327d565b60405180910390f35b6103ce60048036038101906103c99190613241565b611ddc565b005b6103ea60048036038101906103e591906131d7565b611ee3565b005b6103f46121af565b604051610401919061327d565b60405180910390f35b610424600480360381019061041f91906134c9565b6121c2565b005b610440600480360381019061043b9190613241565b61228b565b005b61044a612392565b604051610457919061327d565b60405180910390f35b61047a60048036038101906104759190613241565b6123a5565b005b6104966004803603810190610491919061343a565b612664565b005b6104b260048036038101906104ad9190613241565b61271a565b005b6104ce60048036038101906104c99190613241565b612a1c565b6040516104db9190613482565b60405180910390f35b6104fe60048036038101906104f9919061343a565b612b82565b005b61051a6004803603810190610515919061343a565b612ced565b005b610524612da3565b604051610531919061327d565b60405180910390f35b610554600480360381019061054f91906134f6565b612db6565b005b610570600480360381019061056b9190613241565b612fa3565b005b61057a611029565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146105e957336040517fc95e6e490000000000000000000000000000000000000000000000000000000081526004016105e09190613226565b60405180910390fd5b60008203610623576040517fc377136000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600061062d611029565b905060008173ffffffffffffffffffffffffffffffffffffffff1663857b76636040518163ffffffff1660e01b8152600401600060405180830381865afa15801561067c573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f820116820180604052508101906106a591906135e2565b90506000805b825181101561071d578473ffffffffffffffffffffffffffffffffffffffff168382815181106106de576106dd61362b565b5b602002602001015173ffffffffffffffffffffffffffffffffffffffff160361070a576001915061071d565b808061071590613689565b9150506106ab565b508015610756576040517f74fc692a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8461075f613093565b60010160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101561082d576107ae613093565b60010160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054856040517ffdf3c18d0000000000000000000000000000000000000000000000000000000081526004016108249291906136d1565b60405180910390fd5b84610836613093565b6008015461084491906136fa565b61084c613093565b600801819055508461085c613093565b60010160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546108a791906136fa565b6108af613093565b60010160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555060006108fd611188565b90508073ffffffffffffffffffffffffffffffffffffffff1663a9059cbb86886040518363ffffffff1660e01b815260040161093a92919061372e565b6020604051808303816000875af1158015610959573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061097d919061376c565b508473ffffffffffffffffffffffffffffffffffffffff167f7084f5476618d8e60b11ef0d7d3f06914655adb8793e28ff7f018d4c76d505d5876040516109c4919061327d565b60405180910390a2505050505050565b6109dc611029565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610a4b57336040517fc95e6e49000000000000000000000000000000000000000000000000000000008152600401610a429190613226565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff16610a6b613093565b60040160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610d03576000610af1611029565b90508073ffffffffffffffffffffffffffffffffffffffff166340550a1c610b17613093565b60040160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040518263ffffffff1660e01b8152600401610b949190613226565b602060405180830381865afa158015610bb1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bd5919061376c565b15610c9657610be2613093565b60040160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167fa9e8db6c256a1ab8ca3b7b20e4e5c2e09f608d9f4fa22cb330ef2da1850fcdb583604051610c889190613226565b60405180910390a250610db1565b610c9e613093565b60040160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169150505b81610d0c613093565b60020160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254610d5b9190613799565b925050819055508073ffffffffffffffffffffffffffffffffffffffff167f38cbdc591b5cf62cc9a88b92dcee4809f0d0ca6cd9bdad9f818d74c38e78bf2983604051610da8919061327d565b60405180910390a25b5050565b610dbd611029565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610e2c57336040517fc95e6e49000000000000000000000000000000000000000000000000000000008152600401610e239190613226565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff16610e4c613093565b60040160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610f3457610ed0613093565b60040160008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690505b81610f3d613093565b60010160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254610f8c91906136fa565b9250508190555081610f9c613093565b6008016000828254610fae91906136fa565b9250508190555081610fbe613093565b600b016000828254610fd09190613799565b925050819055508073ffffffffffffffffffffffffffffffffffffffff167f3c3e99c9508723e2a5fd42a570a42b3bd7781ff4900273df394dcc1a9d0660368360405161101d919061327d565b60405180910390a25050565b6000611033613093565b60000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16638e8dfd1661107a613093565b60000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663da19ddfb6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156110e8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061110c9190613803565b611114613093565b60000160149054906101000a900460ff166040518363ffffffff1660e01b81526004016111429291906138b6565b602060405180830381865afa15801561115f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061118391906138df565b905090565b6000611192613093565b60000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16638e8dfd166111d9613093565b60000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663df3806936040518163ffffffff1660e01b8152600401602060405180830381865afa158015611247573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061126b9190613803565b611273613093565b60000160149054906101000a900460ff166040518363ffffffff1660e01b81526004016112a19291906138b6565b602060405180830381865afa1580156112be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112e291906138df565b905090565b60008073ffffffffffffffffffffffffffffffffffffffff16611308613093565b60040160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146113f05761138c613093565b60040160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1691505b6113f8613093565b60020160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6114486130a2565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146114ac576040517f5cd8319200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60005b81518110156114ee576114db8282815181106114ce576114cd61362b565b5b6020026020010151611ddc565b80806114e690613689565b9150506114af565b5050565b6114fa6130a2565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461155e576040517f5cd8319200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80611567613093565b600601819055507fe933824a81d0b6aa53640e0e8df82b08c3f5297409b86d5beb73c41253518b298160405161159d919061327d565b60405180910390a150565b60006115b2613093565b60090160009054906101000a900460ff16905090565b6115d06130a2565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611634576040517f5cd8319200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61163c613093565b600b0154821115611682576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161167990613969565b60405180910390fd5b8161168b613093565b600b01600082825461169d91906136fa565b9250508190555060006116ae611188565b90508073ffffffffffffffffffffffffffffffffffffffff1663a9059cbb83856040518363ffffffff1660e01b81526004016116eb92919061372e565b6020604051808303816000875af115801561170a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061172e919061376c565b50505050565b61173c6130a2565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146117a0576040517f5cd8319200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600047905060003373ffffffffffffffffffffffffffffffffffffffff16826040516117cb906139ba565b60006040518083038185875af1925050503d8060008114611808576040519150601f19603f3d011682016040523d82523d6000602084013e61180d565b606091505b505090508061181b57600080fd5b5050565b611827613093565b600a0154611833613093565b60050160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054106118fe57611881613093565b60050160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040517f2176682c0000000000000000000000000000000000000000000000000000000081526004016118f5919061327d565b60405180910390fd5b33611907613093565b60040160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600161198f613093565b60050160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546119de9190613799565b925050819055503373ffffffffffffffffffffffffffffffffffffffff167f7f05f6fc05d05f3345962cb9fd7d4e4e1ec2546697378950c0901cea523dfaa182604051611a2b9190613226565b60405180910390a250565b60008073ffffffffffffffffffffffffffffffffffffffff16611a57613093565b60040160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611b3f57611adb613093565b60040160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1691505b6000611b49613093565b60010160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050611b94613093565b60060154811015611be95780611ba8613093565b600601546040517f4806a505000000000000000000000000000000000000000000000000000000008152600401611be09291906136d1565b60405180910390fd5b611bf1613093565b60070154811115611c465780611c05613093565b600701546040517f2b3c6b63000000000000000000000000000000000000000000000000000000008152600401611c3d9291906136d1565b60405180910390fd5b6001915050919050565b6000611c5a613093565b60000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60008073ffffffffffffffffffffffffffffffffffffffff16611ca4613093565b60040160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611d8c57611d28613093565b60040160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1691505b611d94613093565b60010160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b611de46130a2565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611e48576040517f5cd8319200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001611e52613093565b60030160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055507f35126091a4da6c3bafab49ae849a4e1e1fdf396d951f2d6fadb89417927e931b81604051611ed89190613226565b60405180910390a150565b611eeb611029565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611f5a57336040517fc95e6e49000000000000000000000000000000000000000000000000000000008152600401611f519190613226565b60405180910390fd5b60008203611f94576040517f6a76ff9f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611f9c613093565b60090160009054906101000a900460ff16801561200c5750611fbc613093565b60030160008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b1561204e57806040517f924a59100000000000000000000000000000000000000000000000000000000081526004016120459190613226565b60405180910390fd5b6000612058611188565b90508073ffffffffffffffffffffffffffffffffffffffff166323b872dd8330866040518463ffffffff1660e01b8152600401612097939291906139cf565b6020604051808303816000875af11580156120b6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120da919061376c565b50826120e4613093565b60010160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546121339190613799565b9250508190555082612143613093565b60080160008282546121559190613799565b925050819055508173ffffffffffffffffffffffffffffffffffffffff167f9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d846040516121a2919061327d565b60405180910390a2505050565b60006121b9613093565b60080154905090565b6121ca6130a2565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461222e576040517f5cd8319200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80612237613093565b60090160006101000a81548160ff0219169083151502179055507fe1138a93dc3399cb895e183d0551777813ef4cdb31cae3f89e5fbded2a6e8a1f816040516122809190613482565b60405180910390a150565b6122936130a2565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146122f7576040517f5cd8319200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000612301613093565b60030160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055507f56c24084818c4d30108b4d428745a95153b8e6dafb1c7094c2c65e19de2c1a9a816040516123879190613226565b60405180910390a150565b600061239c613093565b60070154905090565b3373ffffffffffffffffffffffffffffffffffffffff166123c4613093565b60040160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461247f5780336040517fb1b82d79000000000000000000000000000000000000000000000000000000008152600401612476929190613a06565b60405180910390fd5b6000612489611029565b90508073ffffffffffffffffffffffffffffffffffffffff166340550a1c836040518263ffffffff1660e01b81526004016124c49190613226565b602060405180830381865afa1580156124e1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612505919061376c565b1561254757816040517fc400065d00000000000000000000000000000000000000000000000000000000815260040161253e9190613226565b60405180910390fd5b61254f613093565b60040160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81549073ffffffffffffffffffffffffffffffffffffffff021916905560016125bc613093565b60050160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461260b91906136fa565b925050819055503373ffffffffffffffffffffffffffffffffffffffff167f8ece38c85474a2f8e9e848069caf92d8134ec2d972bf868889161ebe8ce3c485836040516126589190613226565b60405180910390a25050565b61266c6130a2565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146126d0576040517f5cd8319200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b806126d9613093565b600701819055507f723c6a8b97a26222f03a0b1afb5bd5da562f1fdaee45f114f392b66a512951d58160405161270f919061327d565b60405180910390a150565b612722611029565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461279157336040517fc95e6e490000000000000000000000000000000000000000000000000000000081526004016127889190613226565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff166127b1613093565b60040160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461289957612835613093565b60040160008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690505b60006128a3613093565b60020160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490506000811115612a185760006128f9613093565b60020160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506000612947611029565b90508073ffffffffffffffffffffffffffffffffffffffff1663a9059cbb84846040518363ffffffff1660e01b815260040161298492919061372e565b6020604051808303816000875af11580156129a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129c7919061376c565b508273ffffffffffffffffffffffffffffffffffffffff167fe2403640ba68fed3a2f88b7557551d1993f84b99bb10ff833f0cf8db0c5e048683604051612a0e919061327d565b60405180910390a2505b5050565b60008073ffffffffffffffffffffffffffffffffffffffff16612a3d613093565b60040160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614612b2557612ac1613093565b60040160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1691505b612b2d613093565b60030160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050919050565b612b8a6130a2565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614612bee576040517f5cd8319200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b612bf6613093565b600b0154811115612c3c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612c3390613969565b60405180910390fd5b80612c45613093565b600b016000828254612c5791906136fa565b925050819055506000612c68611188565b90508073ffffffffffffffffffffffffffffffffffffffff1663a9059cbb33846040518363ffffffff1660e01b8152600401612ca592919061372e565b6020604051808303816000875af1158015612cc4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ce8919061376c565b505050565b612cf56130a2565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614612d59576040517f5cd8319200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80612d62613093565b600a01819055507f25cb00833e709e42533f8e7818f46cff79dbaf85d1a141eb0416f2c30c36228781604051612d98919061327d565b60405180910390a150565b6000612dad613093565b60060154905090565b612dbe6130a2565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614612e22576040517f5cd8319200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b612e2a613093565b600b0154811115612e70576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612e6790613969565b60405180910390fd5b80612e79613093565b6008016000828254612e8b9190613799565b9250508190555080612e9b613093565b600b016000828254612ead91906136fa565b9250508190555080612ebd613093565b60010160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254612f0c9190613799565b925050819055506000612f1d611188565b90508073ffffffffffffffffffffffffffffffffffffffff1663a9059cbb30846040518363ffffffff1660e01b8152600401612f5a92919061372e565b6020604051808303816000875af1158015612f79573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f9d919061376c565b50505050565b612fab6130a2565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461300f576040517f5cd8319200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80613018613093565b60000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055507f2b5fe80d5061b20e017f0cde52b331309601bfcab0cb14cfcf6a4096410a6075816040516130889190613226565b60405180910390a150565b600061309d6130d5565b905090565b60006130ac613102565b60030160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6000807fdf98007abd433720cd95c1c05e1f3b131f8366fba05e85eff73f410550ddc0c990508091505090565b6000807fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c90508091505090565b6000604051905090565b600080fd5b600080fd5b6000819050919050565b61315681613143565b811461316157600080fd5b50565b6000813590506131738161314d565b92915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006131a482613179565b9050919050565b6131b481613199565b81146131bf57600080fd5b50565b6000813590506131d1816131ab565b92915050565b600080604083850312156131ee576131ed613139565b5b60006131fc85828601613164565b925050602061320d858286016131c2565b9150509250929050565b61322081613199565b82525050565b600060208201905061323b6000830184613217565b92915050565b60006020828403121561325757613256613139565b5b6000613265848285016131c2565b91505092915050565b61327781613143565b82525050565b6000602082019050613292600083018461326e565b92915050565b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6132e68261329d565b810181811067ffffffffffffffff82111715613305576133046132ae565b5b80604052505050565b600061331861312f565b905061332482826132dd565b919050565b600067ffffffffffffffff821115613344576133436132ae565b5b602082029050602081019050919050565b600080fd5b600061336d61336884613329565b61330e565b905080838252602082019050602084028301858111156133905761338f613355565b5b835b818110156133b957806133a588826131c2565b845260208401935050602081019050613392565b5050509392505050565b600082601f8301126133d8576133d7613298565b5b81356133e884826020860161335a565b91505092915050565b60006020828403121561340757613406613139565b5b600082013567ffffffffffffffff8111156134255761342461313e565b5b613431848285016133c3565b91505092915050565b6000602082840312156134505761344f613139565b5b600061345e84828501613164565b91505092915050565b60008115159050919050565b61347c81613467565b82525050565b60006020820190506134976000830184613473565b92915050565b6134a681613467565b81146134b157600080fd5b50565b6000813590506134c38161349d565b92915050565b6000602082840312156134df576134de613139565b5b60006134ed848285016134b4565b91505092915050565b6000806040838503121561350d5761350c613139565b5b600061351b858286016131c2565b925050602061352c85828601613164565b9150509250929050565b600081519050613545816131ab565b92915050565b600061355e61355984613329565b61330e565b9050808382526020820190506020840283018581111561358157613580613355565b5b835b818110156135aa57806135968882613536565b845260208401935050602081019050613583565b5050509392505050565b600082601f8301126135c9576135c8613298565b5b81516135d984826020860161354b565b91505092915050565b6000602082840312156135f8576135f7613139565b5b600082015167ffffffffffffffff8111156136165761361561313e565b5b613622848285016135b4565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600061369482613143565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82036136c6576136c561365a565b5b600182019050919050565b60006040820190506136e6600083018561326e565b6136f3602083018461326e565b9392505050565b600061370582613143565b915061371083613143565b92508282039050818111156137285761372761365a565b5b92915050565b60006040820190506137436000830185613217565b613750602083018461326e565b9392505050565b6000815190506137668161349d565b92915050565b60006020828403121561378257613781613139565b5b600061379084828501613757565b91505092915050565b60006137a482613143565b91506137af83613143565b92508282019050808211156137c7576137c661365a565b5b92915050565b6000819050919050565b6137e0816137cd565b81146137eb57600080fd5b50565b6000815190506137fd816137d7565b92915050565b60006020828403121561381957613818613139565b5b6000613827848285016137ee565b91505092915050565b613839816137cd565b82525050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b6003811061387f5761387e61383f565b5b50565b60008190506138908261386e565b919050565b60006138a082613882565b9050919050565b6138b081613895565b82525050565b60006040820190506138cb6000830185613830565b6138d860208301846138a7565b9392505050565b6000602082840312156138f5576138f4613139565b5b600061390384828501613536565b91505092915050565b600082825260208201905092915050565b7f4e6f7420656e6f7567682070656e616c74792062616c616e6365000000000000600082015250565b6000613953601a8361390c565b915061395e8261391d565b602082019050919050565b6000602082019050818103600083015261398281613946565b9050919050565b600081905092915050565b50565b60006139a4600083613989565b91506139af82613994565b600082019050919050565b60006139c582613997565b9150819050919050565b60006060820190506139e46000830186613217565b6139f16020830185613217565b6139fe604083018461326e565b949350505050565b6000604082019050613a1b6000830185613217565b613a286020830184613217565b939250505056fea26469706673582212203db364bd398fcd1ef142cc3a4c23684f031a4a4db15691d918cf7052b05b256f64736f6c63430008110033
Deployed ByteCode
0x608060405234801561001057600080fd5b50600436106101d95760003560e01c806374c2e2fc11610104578063bcb5c636116100a2578063ddb6e6e111610071578063ddb6e6e114610500578063ec5ffac21461051c578063f21aec061461053a578063f95d71b114610556576101d9565b8063bcb5c6361461047c578063c00007b014610498578063d3dbad7d146104b4578063dc157ce2146104e4576101d9565b8063842648c2116100de578063842648c21461040a578063a498072c14610426578063b5c6b45314610442578063bc97978714610460576101d9565b806374c2e2fc146103b45780637acb7757146103d0578063817b1cd2146103ec576101d9565b8063233e99031161017c57806340b964821161014b57806340b964821461031a578063499199661461033657806350d17b5e1461036657806370a0823114610384576101d9565b8063233e9903146102ba57806327a199d0146102d65780633560db3c146102f45780633ccfd60b14610310576101d9565b80630e9ed68b116101b85780630e9ed68b1461023257806310fe9ae8146102505780631d62ebd91461026e5780631dc4ab3c1461029e576101d9565b8062f714ce146101de57806302fa04c9146101fa5780630a0e3dea14610216575b600080fd5b6101f860048036038101906101f391906131d7565b610572565b005b610214600480360381019061020f91906131d7565b6109d4565b005b610230600480360381019061022b91906131d7565b610db5565b005b61023a611029565b6040516102479190613226565b60405180910390f35b610258611188565b6040516102659190613226565b60405180910390f35b61028860048036038101906102839190613241565b6112e7565b604051610295919061327d565b60405180910390f35b6102b860048036038101906102b391906133f1565b611440565b005b6102d460048036038101906102cf919061343a565b6114f2565b005b6102de6115a8565b6040516102eb9190613482565b60405180910390f35b61030e600480360381019061030991906131d7565b6115c8565b005b610318611734565b005b610334600480360381019061032f9190613241565b61181f565b005b610350600480360381019061034b9190613241565b611a36565b60405161035d9190613482565b60405180910390f35b61036e611c50565b60405161037b9190613226565b60405180910390f35b61039e60048036038101906103999190613241565b611c83565b6040516103ab919061327d565b60405180910390f35b6103ce60048036038101906103c99190613241565b611ddc565b005b6103ea60048036038101906103e591906131d7565b611ee3565b005b6103f46121af565b604051610401919061327d565b60405180910390f35b610424600480360381019061041f91906134c9565b6121c2565b005b610440600480360381019061043b9190613241565b61228b565b005b61044a612392565b604051610457919061327d565b60405180910390f35b61047a60048036038101906104759190613241565b6123a5565b005b6104966004803603810190610491919061343a565b612664565b005b6104b260048036038101906104ad9190613241565b61271a565b005b6104ce60048036038101906104c99190613241565b612a1c565b6040516104db9190613482565b60405180910390f35b6104fe60048036038101906104f9919061343a565b612b82565b005b61051a6004803603810190610515919061343a565b612ced565b005b610524612da3565b604051610531919061327d565b60405180910390f35b610554600480360381019061054f91906134f6565b612db6565b005b610570600480360381019061056b9190613241565b612fa3565b005b61057a611029565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146105e957336040517fc95e6e490000000000000000000000000000000000000000000000000000000081526004016105e09190613226565b60405180910390fd5b60008203610623576040517fc377136000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600061062d611029565b905060008173ffffffffffffffffffffffffffffffffffffffff1663857b76636040518163ffffffff1660e01b8152600401600060405180830381865afa15801561067c573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f820116820180604052508101906106a591906135e2565b90506000805b825181101561071d578473ffffffffffffffffffffffffffffffffffffffff168382815181106106de576106dd61362b565b5b602002602001015173ffffffffffffffffffffffffffffffffffffffff160361070a576001915061071d565b808061071590613689565b9150506106ab565b508015610756576040517f74fc692a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8461075f613093565b60010160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101561082d576107ae613093565b60010160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054856040517ffdf3c18d0000000000000000000000000000000000000000000000000000000081526004016108249291906136d1565b60405180910390fd5b84610836613093565b6008015461084491906136fa565b61084c613093565b600801819055508461085c613093565b60010160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546108a791906136fa565b6108af613093565b60010160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555060006108fd611188565b90508073ffffffffffffffffffffffffffffffffffffffff1663a9059cbb86886040518363ffffffff1660e01b815260040161093a92919061372e565b6020604051808303816000875af1158015610959573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061097d919061376c565b508473ffffffffffffffffffffffffffffffffffffffff167f7084f5476618d8e60b11ef0d7d3f06914655adb8793e28ff7f018d4c76d505d5876040516109c4919061327d565b60405180910390a2505050505050565b6109dc611029565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610a4b57336040517fc95e6e49000000000000000000000000000000000000000000000000000000008152600401610a429190613226565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff16610a6b613093565b60040160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610d03576000610af1611029565b90508073ffffffffffffffffffffffffffffffffffffffff166340550a1c610b17613093565b60040160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040518263ffffffff1660e01b8152600401610b949190613226565b602060405180830381865afa158015610bb1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bd5919061376c565b15610c9657610be2613093565b60040160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167fa9e8db6c256a1ab8ca3b7b20e4e5c2e09f608d9f4fa22cb330ef2da1850fcdb583604051610c889190613226565b60405180910390a250610db1565b610c9e613093565b60040160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169150505b81610d0c613093565b60020160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254610d5b9190613799565b925050819055508073ffffffffffffffffffffffffffffffffffffffff167f38cbdc591b5cf62cc9a88b92dcee4809f0d0ca6cd9bdad9f818d74c38e78bf2983604051610da8919061327d565b60405180910390a25b5050565b610dbd611029565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610e2c57336040517fc95e6e49000000000000000000000000000000000000000000000000000000008152600401610e239190613226565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff16610e4c613093565b60040160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610f3457610ed0613093565b60040160008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690505b81610f3d613093565b60010160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254610f8c91906136fa565b9250508190555081610f9c613093565b6008016000828254610fae91906136fa565b9250508190555081610fbe613093565b600b016000828254610fd09190613799565b925050819055508073ffffffffffffffffffffffffffffffffffffffff167f3c3e99c9508723e2a5fd42a570a42b3bd7781ff4900273df394dcc1a9d0660368360405161101d919061327d565b60405180910390a25050565b6000611033613093565b60000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16638e8dfd1661107a613093565b60000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663da19ddfb6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156110e8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061110c9190613803565b611114613093565b60000160149054906101000a900460ff166040518363ffffffff1660e01b81526004016111429291906138b6565b602060405180830381865afa15801561115f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061118391906138df565b905090565b6000611192613093565b60000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16638e8dfd166111d9613093565b60000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663df3806936040518163ffffffff1660e01b8152600401602060405180830381865afa158015611247573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061126b9190613803565b611273613093565b60000160149054906101000a900460ff166040518363ffffffff1660e01b81526004016112a19291906138b6565b602060405180830381865afa1580156112be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112e291906138df565b905090565b60008073ffffffffffffffffffffffffffffffffffffffff16611308613093565b60040160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146113f05761138c613093565b60040160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1691505b6113f8613093565b60020160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6114486130a2565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146114ac576040517f5cd8319200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60005b81518110156114ee576114db8282815181106114ce576114cd61362b565b5b6020026020010151611ddc565b80806114e690613689565b9150506114af565b5050565b6114fa6130a2565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461155e576040517f5cd8319200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80611567613093565b600601819055507fe933824a81d0b6aa53640e0e8df82b08c3f5297409b86d5beb73c41253518b298160405161159d919061327d565b60405180910390a150565b60006115b2613093565b60090160009054906101000a900460ff16905090565b6115d06130a2565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611634576040517f5cd8319200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61163c613093565b600b0154821115611682576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161167990613969565b60405180910390fd5b8161168b613093565b600b01600082825461169d91906136fa565b9250508190555060006116ae611188565b90508073ffffffffffffffffffffffffffffffffffffffff1663a9059cbb83856040518363ffffffff1660e01b81526004016116eb92919061372e565b6020604051808303816000875af115801561170a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061172e919061376c565b50505050565b61173c6130a2565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146117a0576040517f5cd8319200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600047905060003373ffffffffffffffffffffffffffffffffffffffff16826040516117cb906139ba565b60006040518083038185875af1925050503d8060008114611808576040519150601f19603f3d011682016040523d82523d6000602084013e61180d565b606091505b505090508061181b57600080fd5b5050565b611827613093565b600a0154611833613093565b60050160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054106118fe57611881613093565b60050160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040517f2176682c0000000000000000000000000000000000000000000000000000000081526004016118f5919061327d565b60405180910390fd5b33611907613093565b60040160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600161198f613093565b60050160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546119de9190613799565b925050819055503373ffffffffffffffffffffffffffffffffffffffff167f7f05f6fc05d05f3345962cb9fd7d4e4e1ec2546697378950c0901cea523dfaa182604051611a2b9190613226565b60405180910390a250565b60008073ffffffffffffffffffffffffffffffffffffffff16611a57613093565b60040160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611b3f57611adb613093565b60040160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1691505b6000611b49613093565b60010160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050611b94613093565b60060154811015611be95780611ba8613093565b600601546040517f4806a505000000000000000000000000000000000000000000000000000000008152600401611be09291906136d1565b60405180910390fd5b611bf1613093565b60070154811115611c465780611c05613093565b600701546040517f2b3c6b63000000000000000000000000000000000000000000000000000000008152600401611c3d9291906136d1565b60405180910390fd5b6001915050919050565b6000611c5a613093565b60000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60008073ffffffffffffffffffffffffffffffffffffffff16611ca4613093565b60040160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611d8c57611d28613093565b60040160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1691505b611d94613093565b60010160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b611de46130a2565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611e48576040517f5cd8319200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001611e52613093565b60030160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055507f35126091a4da6c3bafab49ae849a4e1e1fdf396d951f2d6fadb89417927e931b81604051611ed89190613226565b60405180910390a150565b611eeb611029565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611f5a57336040517fc95e6e49000000000000000000000000000000000000000000000000000000008152600401611f519190613226565b60405180910390fd5b60008203611f94576040517f6a76ff9f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611f9c613093565b60090160009054906101000a900460ff16801561200c5750611fbc613093565b60030160008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b1561204e57806040517f924a59100000000000000000000000000000000000000000000000000000000081526004016120459190613226565b60405180910390fd5b6000612058611188565b90508073ffffffffffffffffffffffffffffffffffffffff166323b872dd8330866040518463ffffffff1660e01b8152600401612097939291906139cf565b6020604051808303816000875af11580156120b6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120da919061376c565b50826120e4613093565b60010160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546121339190613799565b9250508190555082612143613093565b60080160008282546121559190613799565b925050819055508173ffffffffffffffffffffffffffffffffffffffff167f9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d846040516121a2919061327d565b60405180910390a2505050565b60006121b9613093565b60080154905090565b6121ca6130a2565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461222e576040517f5cd8319200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80612237613093565b60090160006101000a81548160ff0219169083151502179055507fe1138a93dc3399cb895e183d0551777813ef4cdb31cae3f89e5fbded2a6e8a1f816040516122809190613482565b60405180910390a150565b6122936130a2565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146122f7576040517f5cd8319200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000612301613093565b60030160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055507f56c24084818c4d30108b4d428745a95153b8e6dafb1c7094c2c65e19de2c1a9a816040516123879190613226565b60405180910390a150565b600061239c613093565b60070154905090565b3373ffffffffffffffffffffffffffffffffffffffff166123c4613093565b60040160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461247f5780336040517fb1b82d79000000000000000000000000000000000000000000000000000000008152600401612476929190613a06565b60405180910390fd5b6000612489611029565b90508073ffffffffffffffffffffffffffffffffffffffff166340550a1c836040518263ffffffff1660e01b81526004016124c49190613226565b602060405180830381865afa1580156124e1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612505919061376c565b1561254757816040517fc400065d00000000000000000000000000000000000000000000000000000000815260040161253e9190613226565b60405180910390fd5b61254f613093565b60040160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81549073ffffffffffffffffffffffffffffffffffffffff021916905560016125bc613093565b60050160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461260b91906136fa565b925050819055503373ffffffffffffffffffffffffffffffffffffffff167f8ece38c85474a2f8e9e848069caf92d8134ec2d972bf868889161ebe8ce3c485836040516126589190613226565b60405180910390a25050565b61266c6130a2565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146126d0576040517f5cd8319200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b806126d9613093565b600701819055507f723c6a8b97a26222f03a0b1afb5bd5da562f1fdaee45f114f392b66a512951d58160405161270f919061327d565b60405180910390a150565b612722611029565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461279157336040517fc95e6e490000000000000000000000000000000000000000000000000000000081526004016127889190613226565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff166127b1613093565b60040160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461289957612835613093565b60040160008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690505b60006128a3613093565b60020160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490506000811115612a185760006128f9613093565b60020160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506000612947611029565b90508073ffffffffffffffffffffffffffffffffffffffff1663a9059cbb84846040518363ffffffff1660e01b815260040161298492919061372e565b6020604051808303816000875af11580156129a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129c7919061376c565b508273ffffffffffffffffffffffffffffffffffffffff167fe2403640ba68fed3a2f88b7557551d1993f84b99bb10ff833f0cf8db0c5e048683604051612a0e919061327d565b60405180910390a2505b5050565b60008073ffffffffffffffffffffffffffffffffffffffff16612a3d613093565b60040160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614612b2557612ac1613093565b60040160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1691505b612b2d613093565b60030160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050919050565b612b8a6130a2565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614612bee576040517f5cd8319200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b612bf6613093565b600b0154811115612c3c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612c3390613969565b60405180910390fd5b80612c45613093565b600b016000828254612c5791906136fa565b925050819055506000612c68611188565b90508073ffffffffffffffffffffffffffffffffffffffff1663a9059cbb33846040518363ffffffff1660e01b8152600401612ca592919061372e565b6020604051808303816000875af1158015612cc4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ce8919061376c565b505050565b612cf56130a2565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614612d59576040517f5cd8319200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80612d62613093565b600a01819055507f25cb00833e709e42533f8e7818f46cff79dbaf85d1a141eb0416f2c30c36228781604051612d98919061327d565b60405180910390a150565b6000612dad613093565b60060154905090565b612dbe6130a2565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614612e22576040517f5cd8319200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b612e2a613093565b600b0154811115612e70576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612e6790613969565b60405180910390fd5b80612e79613093565b6008016000828254612e8b9190613799565b9250508190555080612e9b613093565b600b016000828254612ead91906136fa565b9250508190555080612ebd613093565b60010160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254612f0c9190613799565b925050819055506000612f1d611188565b90508073ffffffffffffffffffffffffffffffffffffffff1663a9059cbb30846040518363ffffffff1660e01b8152600401612f5a92919061372e565b6020604051808303816000875af1158015612f79573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f9d919061376c565b50505050565b612fab6130a2565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461300f576040517f5cd8319200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80613018613093565b60000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055507f2b5fe80d5061b20e017f0cde52b331309601bfcab0cb14cfcf6a4096410a6075816040516130889190613226565b60405180910390a150565b600061309d6130d5565b905090565b60006130ac613102565b60030160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6000807fdf98007abd433720cd95c1c05e1f3b131f8366fba05e85eff73f410550ddc0c990508091505090565b6000807fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c90508091505090565b6000604051905090565b600080fd5b600080fd5b6000819050919050565b61315681613143565b811461316157600080fd5b50565b6000813590506131738161314d565b92915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006131a482613179565b9050919050565b6131b481613199565b81146131bf57600080fd5b50565b6000813590506131d1816131ab565b92915050565b600080604083850312156131ee576131ed613139565b5b60006131fc85828601613164565b925050602061320d858286016131c2565b9150509250929050565b61322081613199565b82525050565b600060208201905061323b6000830184613217565b92915050565b60006020828403121561325757613256613139565b5b6000613265848285016131c2565b91505092915050565b61327781613143565b82525050565b6000602082019050613292600083018461326e565b92915050565b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6132e68261329d565b810181811067ffffffffffffffff82111715613305576133046132ae565b5b80604052505050565b600061331861312f565b905061332482826132dd565b919050565b600067ffffffffffffffff821115613344576133436132ae565b5b602082029050602081019050919050565b600080fd5b600061336d61336884613329565b61330e565b905080838252602082019050602084028301858111156133905761338f613355565b5b835b818110156133b957806133a588826131c2565b845260208401935050602081019050613392565b5050509392505050565b600082601f8301126133d8576133d7613298565b5b81356133e884826020860161335a565b91505092915050565b60006020828403121561340757613406613139565b5b600082013567ffffffffffffffff8111156134255761342461313e565b5b613431848285016133c3565b91505092915050565b6000602082840312156134505761344f613139565b5b600061345e84828501613164565b91505092915050565b60008115159050919050565b61347c81613467565b82525050565b60006020820190506134976000830184613473565b92915050565b6134a681613467565b81146134b157600080fd5b50565b6000813590506134c38161349d565b92915050565b6000602082840312156134df576134de613139565b5b60006134ed848285016134b4565b91505092915050565b6000806040838503121561350d5761350c613139565b5b600061351b858286016131c2565b925050602061352c85828601613164565b9150509250929050565b600081519050613545816131ab565b92915050565b600061355e61355984613329565b61330e565b9050808382526020820190506020840283018581111561358157613580613355565b5b835b818110156135aa57806135968882613536565b845260208401935050602081019050613583565b5050509392505050565b600082601f8301126135c9576135c8613298565b5b81516135d984826020860161354b565b91505092915050565b6000602082840312156135f8576135f7613139565b5b600082015167ffffffffffffffff8111156136165761361561313e565b5b613622848285016135b4565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600061369482613143565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82036136c6576136c561365a565b5b600182019050919050565b60006040820190506136e6600083018561326e565b6136f3602083018461326e565b9392505050565b600061370582613143565b915061371083613143565b92508282039050818111156137285761372761365a565b5b92915050565b60006040820190506137436000830185613217565b613750602083018461326e565b9392505050565b6000815190506137668161349d565b92915050565b60006020828403121561378257613781613139565b5b600061379084828501613757565b91505092915050565b60006137a482613143565b91506137af83613143565b92508282019050808211156137c7576137c661365a565b5b92915050565b6000819050919050565b6137e0816137cd565b81146137eb57600080fd5b50565b6000815190506137fd816137d7565b92915050565b60006020828403121561381957613818613139565b5b6000613827848285016137ee565b91505092915050565b613839816137cd565b82525050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b6003811061387f5761387e61383f565b5b50565b60008190506138908261386e565b919050565b60006138a082613882565b9050919050565b6138b081613895565b82525050565b60006040820190506138cb6000830185613830565b6138d860208301846138a7565b9392505050565b6000602082840312156138f5576138f4613139565b5b600061390384828501613536565b91505092915050565b600082825260208201905092915050565b7f4e6f7420656e6f7567682070656e616c74792062616c616e6365000000000000600082015250565b6000613953601a8361390c565b915061395e8261391d565b602082019050919050565b6000602082019050818103600083015261398281613946565b9050919050565b600081905092915050565b50565b60006139a4600083613989565b91506139af82613994565b600082019050919050565b60006139c582613997565b9150819050919050565b60006060820190506139e46000830186613217565b6139f16020830185613217565b6139fe604083018461326e565b949350505050565b6000604082019050613a1b6000830185613217565b613a286020830184613217565b939250505056fea26469706673582212203db364bd398fcd1ef142cc3a4c23684f031a4a4db15691d918cf7052b05b256f64736f6c63430008110033