More Info
Private Name Tags
ContractCreator
Latest 25 from a total of 22,472 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Swap Tokens For ... | 11006776 | 131 days ago | IN | 0 ETH | 0.00000002 | ||||
Emegency Withdra... | 11006759 | 131 days ago | IN | 0 ETH | 0.00000002 | ||||
Swap Tokens For ... | 10306274 | 147 days ago | IN | 0 ETH | 0.00000005 | ||||
Swap Tokens For ... | 10305834 | 147 days ago | IN | 0 ETH | 0.00000006 | ||||
Emegency Withdra... | 8003956 | 201 days ago | IN | 0 ETH | 0.00000159 | ||||
Withdraw NFT | 7580229 | 210 days ago | IN | 0 ETH | 0.00000055 | ||||
Withdraw NFT | 7317348 | 216 days ago | IN | 0 ETH | 0.00000048 | ||||
Set Winner | 7276712 | 217 days ago | IN | 0 ETH | 0.00000028 | ||||
Set Winner | 7276709 | 217 days ago | IN | 0 ETH | 0.00000049 | ||||
Set Winner | 7276706 | 217 days ago | IN | 0 ETH | 0.00000049 | ||||
Set Winner | 7276703 | 217 days ago | IN | 0 ETH | 0.00000049 | ||||
Set Winner | 7276699 | 217 days ago | IN | 0 ETH | 0.00000048 | ||||
Set Winner | 7276696 | 217 days ago | IN | 0 ETH | 0.00000048 | ||||
Set Winner | 7274930 | 217 days ago | IN | 0 ETH | 0.0000019 | ||||
Set Winner | 7274927 | 217 days ago | IN | 0 ETH | 0.00000194 | ||||
Set Winner | 7274924 | 217 days ago | IN | 0 ETH | 0.00000194 | ||||
Set Winner | 7274920 | 217 days ago | IN | 0 ETH | 0.00000194 | ||||
Set Winner | 7274917 | 217 days ago | IN | 0 ETH | 0.00000193 | ||||
Set Winner | 7274914 | 217 days ago | IN | 0 ETH | 0.00000193 | ||||
Set Winner | 7274911 | 217 days ago | IN | 0 ETH | 0.00000193 | ||||
Set Winner | 7274907 | 217 days ago | IN | 0 ETH | 0.00000192 | ||||
Set Winner | 7274904 | 217 days ago | IN | 0 ETH | 0.00000192 | ||||
Set Winner | 7274900 | 217 days ago | IN | 0 ETH | 0.00000191 | ||||
Set Winner | 7274897 | 217 days ago | IN | 0 ETH | 0.00000192 | ||||
Set Winner | 7273129 | 218 days ago | IN | 0 ETH | 0.00000193 |
Latest 25 internal transactions (View All)
Parent Transaction Hash | Block | From | To | |||
---|---|---|---|---|---|---|
8003956 | 201 days ago | 0.95253001 ETH | ||||
7695356 | 208 days ago | 0.00061463 ETH | ||||
7695356 | 208 days ago | 0.00184391 ETH | ||||
7677420 | 208 days ago | 0.0005252 ETH | ||||
7677420 | 208 days ago | 0.0015756 ETH | ||||
7674656 | 208 days ago | 0.00082172 ETH | ||||
7674656 | 208 days ago | 0.00246516 ETH | ||||
7671208 | 208 days ago | 0.0009533 ETH | ||||
7671208 | 208 days ago | 0.0028599 ETH | ||||
7670024 | 208 days ago | 0.0046625 ETH | ||||
7670024 | 208 days ago | 0.01398751 ETH | ||||
7642827 | 209 days ago | 0.00125506 ETH | ||||
7642827 | 209 days ago | 0.0037652 ETH | ||||
7629321 | 209 days ago | 0.00648286 ETH | ||||
7629321 | 209 days ago | 0.0194486 ETH | ||||
7615300 | 210 days ago | 0.01132529 ETH | ||||
7615300 | 210 days ago | 0.03397587 ETH | ||||
7611052 | 210 days ago | 0.00285587 ETH | ||||
7611052 | 210 days ago | 0.00856762 ETH | ||||
7609477 | 210 days ago | 0.00235854 ETH | ||||
7609477 | 210 days ago | 0.00707562 ETH | ||||
7608139 | 210 days ago | 0.02738321 ETH | ||||
7608139 | 210 days ago | 0.08214964 ETH | ||||
7603253 | 210 days ago | 0.0004957 ETH | ||||
7603253 | 210 days ago | 0.0014871 ETH |
Loading...
Loading
Contract Name:
GangsterArena
Compiler Version
v0.8.20+commit.a1b79de6
Optimization Enabled:
No with 200 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import '@openzeppelin/contracts/access/AccessControl.sol'; import '@openzeppelin/contracts/utils/ReentrancyGuard.sol'; import './Gangster.sol'; import './GREED.sol'; import './IGangsterArena.sol'; import './libs/SafeTransferLib.sol'; import './libs/SignerLib.sol'; import './interfaces/IBlast.sol'; // import 'hardhat/console.sol'; contract GangsterArena is AccessControl, ReentrancyGuard, IGangsterArena { IBlast public constant BLAST = IBlast(0x4300000000000000000000000000000000000002); using SafeTransferLib for address payable; using SignerLib for address; IUniswapV2Router02 public uniswapV2Router; // Uniswap router Gangster public immutable nft; // NFT token GREED public immutable greedToken; // greedToken token address private immutable signer; // Signer address bytes32 public constant WORKER_ROLE = keccak256('WORKER_ROLE'); // Worker role - process game transaction bytes32 public constant ADMIN_ROLE = keccak256('ADMIN_ROLE'); // Admin role - setting contract /* **************** * Game config **************** */ uint256 public constant tokenId = 1; // NFT tokenId uint256 public MAX_PER_BATCH = 500; // Max NFT minting perbatch uint256 public tokenSwapLimit = 5000 ether; //limit token for LP, swap to ether when over uint256 public burnRate = 20_00; uint256 public communityRate = 20_00; uint256 public prizeRate = 30_00; uint256 public ethRate = 30_00; uint256 public vtd = 60; // valid timestamp different //**************** // Game Contract Balance //**************** uint256 public ethPrize; // eth prize uint256 public tokenPrize; // token prize uint256 public tokenForLP; // token hold before swap to eth //**************** // Game Address //**************** address public devAddr_; address public immutable pointsOperator_; address public gasFeeOperator_; address public communityTreasury_; address public spinPoolAddr_; //**************** // Game Data //**************** bool public gameClosed; // Flag toggle when game close bool public lockNFT; // flag when nft is locked mapping(address => mapping(uint256 => uint256)) public lastB; // address -> type -> timestamp mapping(address => uint256) public gangsterBought; // address -> number of gangster bought mapping(uint256 => bool) usedNonces; // Nonces of transaction mapping(address => uint256) public gangster; // address -> number of staked gangster - NFT when user deposit constructor( address _defaultAdmin, address _adminAddress, address _workerAddress, address _signerAddress, address _gangsterAddress, address payable _fiatAddress, address _pointsOperator, address _blastPointAddr ) { nft = Gangster(_gangsterAddress); greedToken = GREED(_fiatAddress); signer = _signerAddress; pointsOperator_ = _pointsOperator; communityTreasury_ = _defaultAdmin; _grantRole(DEFAULT_ADMIN_ROLE, _defaultAdmin); _grantRole(ADMIN_ROLE, _adminAddress); _grantRole(WORKER_ROLE, _workerAddress); if (_blastPointAddr != address(0)) { IBlastPoints(_blastPointAddr).configurePointsOperator(_pointsOperator); BLAST.configureClaimableGas(); BLAST.configureClaimableYield(); } } receive() external payable { ethPrize += msg.value; emit Received(msg.sender, msg.value); } fallback() external payable { ethPrize += msg.value; emit Received(msg.sender, msg.value); } /** * @notice ERC1155 receiver */ function onERC1155Received( address operator, address from, uint256 id, uint256 value, bytes calldata data ) external returns (bytes4) { return bytes4(keccak256('onERC1155Received(address,address,uint256,uint256,bytes)')); } // Modifier to check token allowance // modifier checkAllowance(uint _amount) { // require(greedToken.allowance(msg.sender, address(this)) >= _amount, 'Error'); // _; // } //*************************** // Public //*************************** function addReward(uint256 _dev, uint256 _reputationPrize_, uint256 _rankPrize_) public payable { uint256 totalValue = _dev + _reputationPrize_ + _rankPrize_; require(msg.value >= totalValue, 'Need to send more ether'); ethPrize += _rankPrize_ + _reputationPrize_; if (_dev > 0) { address payable receiver = payable(devAddr_); (bool sent, ) = receiver.call{value: _dev}(''); require(sent, 'Failed to send Ether'); } uint256 extraValue = msg.value - totalValue; if (extraValue > 0) { address payable receiver = payable(msg.sender); (bool sent, ) = receiver.call{value: extraValue}(''); require(sent, 'Failed to send Ether'); } emit AddReward(msg.sender, totalValue); } function addTokenReward(uint256 _value) public { greedToken.transferFrom(msg.sender, address(this), _value); tokenPrize += _value; } /** * @notice Buy Asset * typeA: type of Asset, 0 is Gangster, 1 is goon, 2 is safehouse * amount: amount of asset * value: value user have to pay in token * lastB: lastB time block time * sTime: signature time * nonce: application transaction nonce * sig: signatire from application */ function buyAsset( uint256 _typeA, uint256 _amount, uint256 _value, uint256 _lastB, uint256 _sTime, uint256 _nonce, bytes memory _sig ) public { require(greedToken.allowance(msg.sender, address(this)) >= _value, 'Error'); require(!gameClosed, 'Game is closed'); require(lastB[msg.sender][_typeA] == _lastB, 'Invalid last buy time'); require(block.timestamp < _sTime + vtd, 'Invalid timestamp'); require(!usedNonces[_nonce], 'Nonce is used'); bytes32 message = SignerLib.prefixed( keccak256(abi.encodePacked(msg.sender, _typeA, _amount, _value, _lastB, _sTime, _nonce)) ); require(signer.verifyAddressSigner(message, _sig), 'Invalid signature'); usedNonces[_nonce] = true; lastB[msg.sender][_typeA] = block.timestamp; uint256 burnValue = (_value * burnRate) / 100_00; uint256 communityValue = (_value * communityRate) / 100_00; uint256 lpValue = (_value * ethRate) / 100_00; uint256 prizeValue = (_value * prizeRate) / 100_00; greedToken.transferFrom(msg.sender, address(this), _value); tokenForLP += lpValue; tokenPrize += prizeValue; if (burnValue > 0) greedToken.burn(burnValue); if (communityValue > 0) greedToken.transfer(communityTreasury_, communityValue); if (_typeA == 0 && _amount > 0) { mintNFT(msg.sender, _amount); emit BuyGangster(msg.sender, tokenId, _amount, _nonce); } if (_typeA == 1) emit BuyGoon(msg.sender, _amount, _nonce); if (_typeA == 2) emit BuySafeHouse(msg.sender, _amount, _nonce); } /** * @notice Buy spin * type: type of spint, default is 1 * amount: number of spin * value: value user have to pay in token * _lastP: last time user spin in block time * sTime: signature time * nonce: application transaction nonce * sig: signatire from application */ function spin( uint256 _spinType, uint256 _amount, uint256 _value, uint256 _sTime, uint256 _nonce, bytes memory _sig ) public { require(greedToken.allowance(msg.sender, address(this)) >= _value, 'Error'); require(!gameClosed, 'Game is closed'); require(block.timestamp < _sTime + vtd, 'Invalid timestamp'); require(!usedNonces[_nonce], 'Nonce is used'); bytes32 message = SignerLib.prefixed( keccak256(abi.encodePacked(msg.sender, _spinType, _amount, _value, _sTime, _nonce)) ); require(signer.verifyAddressSigner(message, _sig), 'Invalid signature'); usedNonces[_nonce] = true; greedToken.transferFrom(msg.sender, spinPoolAddr_, _value); emit DailySpin(msg.sender, _spinType, _amount, _value, _nonce); } function pickCrew(uint256 _value, uint256 _sTime, uint256 _nonce, bytes memory _sig) public { require(greedToken.allowance(msg.sender, address(this)) >= _value, 'Error'); require(!gameClosed, 'Game is closed'); require(block.timestamp < _sTime + vtd, 'Invalid timestamp'); require(!usedNonces[_nonce], 'Nonce is used'); bytes32 message = SignerLib.prefixed(keccak256(abi.encodePacked(msg.sender, _value, _sTime, _nonce))); require(signer.verifyAddressSigner(message, _sig), 'Invalid signature'); usedNonces[_nonce] = true; greedToken.burnFrom(msg.sender, _value); emit JoinCrew(msg.sender, _nonce); } /** * @notice depositNFT */ function depositNFT(address _to, uint256 _amount) public { require(!gameClosed, 'Game is closed'); nft.safeTransferFrom(msg.sender, address(this), tokenId, _amount, ''); gangster[_to] += _amount; emit Deposit(_to, tokenId, _amount); } /** * @notice withdrawNFT */ function withdrawNFT(address _to, uint256 _amount) public { require(!lockNFT, 'NFT is locked'); require(gangster[msg.sender] >= _amount, 'Insufficient balance'); gangster[msg.sender] -= _amount; nft.safeTransferFrom(address(this), _to, tokenId, _amount, ''); emit Withdraw(msg.sender, tokenId, _amount); } /** * *************************** * Claim Gas * *************************** */ function claimGas(bool _maxOnly) public onlyRole(ADMIN_ROLE) { require(gasFeeOperator_ != address(0), 'gasFee is not set'); if (_maxOnly) { BLAST.claimMaxGas(address(this), gasFeeOperator_); } else { BLAST.claimAllGas(address(this), gasFeeOperator_); } } function claimAllYield() public onlyRole(ADMIN_ROLE) { BLAST.claimAllYield(address(this), gasFeeOperator_); } function finalWarResult(address[] memory _addr, uint256[] memory _lGang) public onlyRole(WORKER_ROLE) { require(!gameClosed, 'Game is closed'); require(_addr.length == _lGang.length, 'Input array is not match'); for (uint256 i = 0; i < _addr.length; i++) { require(gangster[_addr[i]] >= _lGang[i], 'Invalid amount to burn'); } uint256 total = sumOf(_lGang); for (uint256 i = 0; i < _addr.length; i++) { gangster[_addr[i]] -= _lGang[i]; } nft.burn(address(this), tokenId, total); emit WarResult(_addr, _lGang); } function setLockNFT(bool _lock) public onlyRole(WORKER_ROLE) { lockNFT = _lock; } /** * @notice update winners and payout */ function setWinner( address[] memory _to, uint256[] memory _ethReward, uint256[] memory _tokenReward ) public onlyRole(WORKER_ROLE) { require(gameClosed, 'Game is not closed'); require(_to.length == _ethReward.length && _ethReward.length == _tokenReward.length, 'Invalid input array length'); for (uint256 i = 0; i < _to.length; i++) { require(address(this).balance >= _ethReward[i], 'Over eth balance'); require(greedToken.balanceOf(address(this)) >= _tokenReward[i], 'Over token balance'); if (_ethReward[i] > 0) { address payable receiver = payable(_to[i]); (bool sent, ) = receiver.call{value: _ethReward[i]}(''); require(sent, 'Failed to send Ether'); } if (_tokenReward[i] > 0) greedToken.transfer(_to[i], _tokenReward[i]); } } /** * @notice set game close status */ function setGameClosed(bool _value) public onlyRole(WORKER_ROLE) { gameClosed = _value; } function swapTokensForEth(uint256 amountOutMin) public onlyRole(WORKER_ROLE) { // generate the uniswap pair path of token -> weth address[] memory path = new address[](2); path[0] = address(greedToken); path[1] = uniswapV2Router.WETH(); uint256 amountIn = tokenForLP; greedToken.approve(address(uniswapV2Router), amountIn); tokenForLP = 0; // make the swap uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( amountIn, amountOutMin, // accept any amount of ETH path, address(this), block.timestamp ); } /** *************************** *Customization for the contract (ADMIN_ROLE) *************************** */ /** * @notice set Base Price Gangster */ function setGameConfig( uint256 _vtd, uint256 _tokenSwapLimit, uint256 _burnRate, uint256 _communityRate, uint256 _prizeRate ) public onlyRole(ADMIN_ROLE) { vtd = _vtd; tokenSwapLimit = _tokenSwapLimit; burnRate = _burnRate; communityRate = _communityRate; prizeRate = _prizeRate; ethRate = 100_00 - _burnRate - _communityRate - _prizeRate; } function setGameAddress( address _devAddr, address _gasFeeOperator, address _communityTreasury, address _spinPool, address _uniswapV2Router ) public onlyRole(ADMIN_ROLE) { devAddr_ = _devAddr; gasFeeOperator_ = _gasFeeOperator; communityTreasury_ = _communityTreasury; spinPoolAddr_ = _spinPool; uniswapV2Router = IUniswapV2Router02(_uniswapV2Router); // greedToken.approve(communityTreasury_, 2 ** 256 - 1); } /** *************************** DEFAULT_ADMIN_ROLE Function *************************** */ function emegencyWithdraw() public onlyRole(DEFAULT_ADMIN_ROLE) { require(gameClosed, 'Game is not closed'); require(address(this).balance > 0, 'Nothing to withdraw'); address payable receiver = payable(msg.sender); (bool sent, ) = receiver.call{value: address(this).balance}(''); require(sent, 'Failed to send Ether'); } /** *************************** Internal Function *************************** */ /** * @notice common logic for buy nft in-game */ function mintNFT(address sender, uint256 amount) private { require(amount != 0, 'Invalid amount'); require(amount <= MAX_PER_BATCH, 'Max per batch reached'); nft.mint(address(this), tokenId, amount, ''); gangster[sender] += amount; } /** * @notice sum of array */ function sumOf(uint256[] memory arr) internal pure returns (uint256 result) { for (uint256 i = 0; i < arr.length; i++) { result += arr[i]; } return result; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol) pragma solidity ^0.8.20; import {IAccessControl} from "@openzeppelin/contracts/access/IAccessControl.sol"; import {ContextUpgradeable} from "../utils/ContextUpgradeable.sol"; import {ERC165Upgradeable} from "../utils/introspection/ERC165Upgradeable.sol"; import {Initializable} from "../proxy/utils/Initializable.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 AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControl, ERC165Upgradeable { struct RoleData { mapping(address account => bool) hasRole; bytes32 adminRole; } bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /// @custom:storage-location erc7201:openzeppelin.storage.AccessControl struct AccessControlStorage { mapping(bytes32 role => RoleData) _roles; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.AccessControl")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant AccessControlStorageLocation = 0x02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800; function _getAccessControlStorage() private pure returns (AccessControlStorage storage $) { assembly { $.slot := AccessControlStorageLocation } } /** * @dev Modifier that checks that an account has a specific role. Reverts * with an {AccessControlUnauthorizedAccount} error including the required role. */ modifier onlyRole(bytes32 role) { _checkRole(role); _; } function __AccessControl_init() internal onlyInitializing { } function __AccessControl_init_unchained() internal onlyInitializing { } /** * @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 returns (bool) { AccessControlStorage storage $ = _getAccessControlStorage(); return $._roles[role].hasRole[account]; } /** * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()` * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier. */ function _checkRole(bytes32 role) internal view virtual { _checkRole(role, _msgSender()); } /** * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account` * is missing `role`. */ function _checkRole(bytes32 role, address account) internal view virtual { if (!hasRole(role, account)) { revert AccessControlUnauthorizedAccount(account, role); } } /** * @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 returns (bytes32) { AccessControlStorage storage $ = _getAccessControlStorage(); 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 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 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 `callerConfirmation`. * * May emit a {RoleRevoked} event. */ function renounceRole(bytes32 role, address callerConfirmation) public virtual { if (callerConfirmation != _msgSender()) { revert AccessControlBadConfirmation(); } _revokeRole(role, callerConfirmation); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { AccessControlStorage storage $ = _getAccessControlStorage(); bytes32 previousAdminRole = getRoleAdmin(role); $._roles[role].adminRole = adminRole; emit RoleAdminChanged(role, previousAdminRole, adminRole); } /** * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted. * * Internal function without access restriction. * * May emit a {RoleGranted} event. */ function _grantRole(bytes32 role, address account) internal virtual returns (bool) { AccessControlStorage storage $ = _getAccessControlStorage(); if (!hasRole(role, account)) { $._roles[role].hasRole[account] = true; emit RoleGranted(role, account, _msgSender()); return true; } else { return false; } } /** * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked. * * Internal function without access restriction. * * May emit a {RoleRevoked} event. */ function _revokeRole(bytes32 role, address account) internal virtual returns (bool) { AccessControlStorage storage $ = _getAccessControlStorage(); if (hasRole(role, account)) { $._roles[role].hasRole[account] = false; emit RoleRevoked(role, account, _msgSender()); return true; } else { return false; } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol) pragma solidity ^0.8.20; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in * case an upgrade adds a module that needs to be initialized. * * For example: * * [.hljs-theme-light.nopadding] * ```solidity * contract MyToken is ERC20Upgradeable { * function initialize() initializer public { * __ERC20_init("MyToken", "MTK"); * } * } * * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable { * function initializeV2() reinitializer(2) public { * __ERC20Permit_init("MyToken"); * } * } * ``` * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() { * _disableInitializers(); * } * ``` * ==== */ abstract contract Initializable { /** * @dev Storage of the initializable contract. * * It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions * when using with upgradeable contracts. * * @custom:storage-location erc7201:openzeppelin.storage.Initializable */ struct InitializableStorage { /** * @dev Indicates that the contract has been initialized. */ uint64 _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool _initializing; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Initializable")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00; /** * @dev The contract is already initialized. */ error InvalidInitialization(); /** * @dev The contract is not initializing. */ error NotInitializing(); /** * @dev Triggered when the contract has been initialized or reinitialized. */ event Initialized(uint64 version); /** * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope, * `onlyInitializing` functions can be used to initialize parent contracts. * * Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any * number of times. This behavior in the constructor can be useful during testing and is not expected to be used in * production. * * Emits an {Initialized} event. */ modifier initializer() { // solhint-disable-next-line var-name-mixedcase InitializableStorage storage $ = _getInitializableStorage(); // Cache values to avoid duplicated sloads bool isTopLevelCall = !$._initializing; uint64 initialized = $._initialized; // Allowed calls: // - initialSetup: the contract is not in the initializing state and no previous version was // initialized // - construction: the contract is initialized at version 1 (no reininitialization) and the // current contract is just being deployed bool initialSetup = initialized == 0 && isTopLevelCall; bool construction = initialized == 1 && address(this).code.length == 0; if (!initialSetup && !construction) { revert InvalidInitialization(); } $._initialized = 1; if (isTopLevelCall) { $._initializing = true; } _; if (isTopLevelCall) { $._initializing = false; emit Initialized(1); } } /** * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be * used to initialize parent contracts. * * A reinitializer may be used after the original initialization step. This is essential to configure modules that * are added through upgrades and that require initialization. * * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer` * cannot be nested. If one is invoked in the context of another, execution will revert. * * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in * a contract, executing them in the right order is up to the developer or operator. * * WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization. * * Emits an {Initialized} event. */ modifier reinitializer(uint64 version) { // solhint-disable-next-line var-name-mixedcase InitializableStorage storage $ = _getInitializableStorage(); if ($._initializing || $._initialized >= version) { revert InvalidInitialization(); } $._initialized = version; $._initializing = true; _; $._initializing = false; emit Initialized(version); } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} and {reinitializer} modifiers, directly or indirectly. */ modifier onlyInitializing() { _checkInitializing(); _; } /** * @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}. */ function _checkInitializing() internal view virtual { if (!_isInitializing()) { revert NotInitializing(); } } /** * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call. * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized * to any version. It is recommended to use this to lock implementation contracts that are designed to be called * through proxies. * * Emits an {Initialized} event the first time it is successfully executed. */ function _disableInitializers() internal virtual { // solhint-disable-next-line var-name-mixedcase InitializableStorage storage $ = _getInitializableStorage(); if ($._initializing) { revert InvalidInitialization(); } if ($._initialized != type(uint64).max) { $._initialized = type(uint64).max; emit Initialized(type(uint64).max); } } /** * @dev Returns the highest version that has been initialized. See {reinitializer}. */ function _getInitializedVersion() internal view returns (uint64) { return _getInitializableStorage()._initialized; } /** * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}. */ function _isInitializing() internal view returns (bool) { return _getInitializableStorage()._initializing; } /** * @dev Returns a pointer to the storage namespace. */ // solhint-disable-next-line var-name-mixedcase function _getInitializableStorage() private pure returns (InitializableStorage storage $) { assembly { $.slot := INITIALIZABLE_STORAGE } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/UUPSUpgradeable.sol) pragma solidity ^0.8.20; import {IERC1822Proxiable} from "@openzeppelin/contracts/interfaces/draft-IERC1822.sol"; import {ERC1967Utils} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.sol"; import {Initializable} from "./Initializable.sol"; /** * @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an * {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy. * * A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is * reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing * `UUPSUpgradeable` with a custom implementation of upgrades. * * The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism. */ abstract contract UUPSUpgradeable is Initializable, IERC1822Proxiable { /// @custom:oz-upgrades-unsafe-allow state-variable-immutable address private immutable __self = address(this); /** * @dev The version of the upgrade interface of the contract. If this getter is missing, both `upgradeTo(address)` * and `upgradeToAndCall(address,bytes)` are present, and `upgradeTo` must be used if no function should be called, * while `upgradeToAndCall` will invoke the `receive` function if the second argument is the empty byte string. * If the getter returns `"5.0.0"`, only `upgradeToAndCall(address,bytes)` is present, and the second argument must * be the empty byte string if no function should be called, making it impossible to invoke the `receive` function * during an upgrade. */ string public constant UPGRADE_INTERFACE_VERSION = "5.0.0"; /** * @dev The call is from an unauthorized context. */ error UUPSUnauthorizedCallContext(); /** * @dev The storage `slot` is unsupported as a UUID. */ error UUPSUnsupportedProxiableUUID(bytes32 slot); /** * @dev Check that the execution is being performed through a delegatecall call and that the execution context is * a proxy contract with an implementation (as defined in ERC1967) pointing to self. This should only be the case * for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a * function through ERC1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to * fail. */ modifier onlyProxy() { _checkProxy(); _; } /** * @dev Check that the execution is not being performed through a delegate call. This allows a function to be * callable on the implementing contract but not through proxies. */ modifier notDelegated() { _checkNotDelegated(); _; } function __UUPSUpgradeable_init() internal onlyInitializing { } function __UUPSUpgradeable_init_unchained() internal onlyInitializing { } /** * @dev Implementation of the ERC1822 {proxiableUUID} function. This returns the storage slot used by the * implementation. It is used to validate the implementation's compatibility when performing an upgrade. * * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this * function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier. */ function proxiableUUID() external view virtual notDelegated returns (bytes32) { return ERC1967Utils.IMPLEMENTATION_SLOT; } /** * @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call * encoded in `data`. * * Calls {_authorizeUpgrade}. * * Emits an {Upgraded} event. * * @custom:oz-upgrades-unsafe-allow-reachable delegatecall */ function upgradeToAndCall(address newImplementation, bytes memory data) public payable virtual onlyProxy { _authorizeUpgrade(newImplementation); _upgradeToAndCallUUPS(newImplementation, data); } /** * @dev Reverts if the execution is not performed via delegatecall or the execution * context is not of a proxy with an ERC1967-compliant implementation pointing to self. * See {_onlyProxy}. */ function _checkProxy() internal view virtual { if ( address(this) == __self || // Must be called through delegatecall ERC1967Utils.getImplementation() != __self // Must be called through an active proxy ) { revert UUPSUnauthorizedCallContext(); } } /** * @dev Reverts if the execution is performed via delegatecall. * See {notDelegated}. */ function _checkNotDelegated() internal view virtual { if (address(this) != __self) { // Must not be called through delegatecall revert UUPSUnauthorizedCallContext(); } } /** * @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by * {upgradeToAndCall}. * * Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}. * * ```solidity * function _authorizeUpgrade(address) internal onlyOwner {} * ``` */ function _authorizeUpgrade(address newImplementation) internal virtual; /** * @dev Performs an implementation upgrade with a security check for UUPS proxies, and additional setup call. * * As a security check, {proxiableUUID} is invoked in the new implementation, and the return value * is expected to be the implementation slot in ERC1967. * * Emits an {IERC1967-Upgraded} event. */ function _upgradeToAndCallUUPS(address newImplementation, bytes memory data) private { try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) { if (slot != ERC1967Utils.IMPLEMENTATION_SLOT) { revert UUPSUnsupportedProxiableUUID(slot); } ERC1967Utils.upgradeToAndCall(newImplementation, data); } catch { // The implementation is not UUPS revert ERC1967Utils.ERC1967InvalidImplementation(newImplementation); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/ERC20.sol) pragma solidity ^0.8.20; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol"; import {ContextUpgradeable} from "../../utils/ContextUpgradeable.sol"; import {IERC20Errors} from "@openzeppelin/contracts/interfaces/draft-IERC6093.sol"; import {Initializable} from "../../proxy/utils/Initializable.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}. * * 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. */ abstract contract ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20, IERC20Metadata, IERC20Errors { /// @custom:storage-location erc7201:openzeppelin.storage.ERC20 struct ERC20Storage { mapping(address account => uint256) _balances; mapping(address account => mapping(address spender => uint256)) _allowances; uint256 _totalSupply; string _name; string _symbol; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.ERC20")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant ERC20StorageLocation = 0x52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace00; function _getERC20Storage() private pure returns (ERC20Storage storage $) { assembly { $.slot := ERC20StorageLocation } } /** * @dev Sets the values for {name} and {symbol}. * * All two of these values are immutable: they can only be set once during * construction. */ function __ERC20_init(string memory name_, string memory symbol_) internal onlyInitializing { __ERC20_init_unchained(name_, symbol_); } function __ERC20_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing { ERC20Storage storage $ = _getERC20Storage(); $._name = name_; $._symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual returns (string memory) { ERC20Storage storage $ = _getERC20Storage(); return $._name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual returns (string memory) { ERC20Storage storage $ = _getERC20Storage(); 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 returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual returns (uint256) { ERC20Storage storage $ = _getERC20Storage(); return $._totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual returns (uint256) { ERC20Storage storage $ = _getERC20Storage(); return $._balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `to` cannot be the zero address. * - the caller must have a balance of at least `value`. */ function transfer(address to, uint256 value) public virtual returns (bool) { address owner = _msgSender(); _transfer(owner, to, value); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual returns (uint256) { ERC20Storage storage $ = _getERC20Storage(); return $._allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * NOTE: If `value` 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 value) public virtual returns (bool) { address owner = _msgSender(); _approve(owner, spender, value); 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 `value`. * - the caller must have allowance for ``from``'s tokens of at least * `value`. */ function transferFrom(address from, address to, uint256 value) public virtual returns (bool) { address spender = _msgSender(); _spendAllowance(from, spender, value); _transfer(from, to, value); return true; } /** * @dev Moves a `value` 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. * * NOTE: This function is not virtual, {_update} should be overridden instead. */ function _transfer(address from, address to, uint256 value) internal { if (from == address(0)) { revert ERC20InvalidSender(address(0)); } if (to == address(0)) { revert ERC20InvalidReceiver(address(0)); } _update(from, to, value); } /** * @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from` * (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding * this function. * * Emits a {Transfer} event. */ function _update(address from, address to, uint256 value) internal virtual { ERC20Storage storage $ = _getERC20Storage(); if (from == address(0)) { // Overflow check required: The rest of the code assumes that totalSupply never overflows $._totalSupply += value; } else { uint256 fromBalance = $._balances[from]; if (fromBalance < value) { revert ERC20InsufficientBalance(from, fromBalance, value); } unchecked { // Overflow not possible: value <= fromBalance <= totalSupply. $._balances[from] = fromBalance - value; } } if (to == address(0)) { unchecked { // Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply. $._totalSupply -= value; } } else { unchecked { // Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256. $._balances[to] += value; } } emit Transfer(from, to, value); } /** * @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0). * Relies on the `_update` mechanism * * Emits a {Transfer} event with `from` set to the zero address. * * NOTE: This function is not virtual, {_update} should be overridden instead. */ function _mint(address account, uint256 value) internal { if (account == address(0)) { revert ERC20InvalidReceiver(address(0)); } _update(address(0), account, value); } /** * @dev Destroys a `value` amount of tokens from `account`, lowering the total supply. * Relies on the `_update` mechanism. * * Emits a {Transfer} event with `to` set to the zero address. * * NOTE: This function is not virtual, {_update} should be overridden instead */ function _burn(address account, uint256 value) internal { if (account == address(0)) { revert ERC20InvalidSender(address(0)); } _update(account, address(0), value); } /** * @dev Sets `value` 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. * * Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument. */ function _approve(address owner, address spender, uint256 value) internal { _approve(owner, spender, value, true); } /** * @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event. * * By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by * `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any * `Approval` event during `transferFrom` operations. * * Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to * true using the following override: * ``` * function _approve(address owner, address spender, uint256 value, bool) internal virtual override { * super._approve(owner, spender, value, true); * } * ``` * * Requirements are the same as {_approve}. */ function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual { ERC20Storage storage $ = _getERC20Storage(); if (owner == address(0)) { revert ERC20InvalidApprover(address(0)); } if (spender == address(0)) { revert ERC20InvalidSpender(address(0)); } $._allowances[owner][spender] = value; if (emitEvent) { emit Approval(owner, spender, value); } } /** * @dev Updates `owner` s allowance for `spender` based on spent `value`. * * Does not update the allowance value in case of infinite allowance. * Revert if not enough allowance is available. * * Does not emit an {Approval} event. */ function _spendAllowance(address owner, address spender, uint256 value) internal virtual { uint256 currentAllowance = allowance(owner, spender); if (currentAllowance != type(uint256).max) { if (currentAllowance < value) { revert ERC20InsufficientAllowance(spender, currentAllowance, value); } unchecked { _approve(owner, spender, currentAllowance - value, false); } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/ERC20Burnable.sol) pragma solidity ^0.8.20; import {ERC20Upgradeable} from "../ERC20Upgradeable.sol"; import {ContextUpgradeable} from "../../../utils/ContextUpgradeable.sol"; import {Initializable} from "../../../proxy/utils/Initializable.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 ERC20BurnableUpgradeable is Initializable, ContextUpgradeable, ERC20Upgradeable { function __ERC20Burnable_init() internal onlyInitializing { } function __ERC20Burnable_init_unchained() internal onlyInitializing { } /** * @dev Destroys a `value` amount of tokens from the caller. * * See {ERC20-_burn}. */ function burn(uint256 value) public virtual { _burn(_msgSender(), value); } /** * @dev Destroys a `value` amount of 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 * `value`. */ function burnFrom(address account, uint256 value) public virtual { _spendAllowance(account, _msgSender(), value); _burn(account, value); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/ERC20Permit.sol) pragma solidity ^0.8.20; import {IERC20Permit} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol"; import {ERC20Upgradeable} from "../ERC20Upgradeable.sol"; import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; import {EIP712Upgradeable} from "../../../utils/cryptography/EIP712Upgradeable.sol"; import {NoncesUpgradeable} from "../../../utils/NoncesUpgradeable.sol"; import {Initializable} from "../../../proxy/utils/Initializable.sol"; /** * @dev Implementation of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. */ abstract contract ERC20PermitUpgradeable is Initializable, ERC20Upgradeable, IERC20Permit, EIP712Upgradeable, NoncesUpgradeable { bytes32 private constant PERMIT_TYPEHASH = keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"); /** * @dev Permit deadline has expired. */ error ERC2612ExpiredSignature(uint256 deadline); /** * @dev Mismatched signature. */ error ERC2612InvalidSigner(address signer, address owner); /** * @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `"1"`. * * It's a good idea to use the same `name` that is defined as the ERC20 token name. */ function __ERC20Permit_init(string memory name) internal onlyInitializing { __EIP712_init_unchained(name, "1"); } function __ERC20Permit_init_unchained(string memory) internal onlyInitializing {} /** * @inheritdoc IERC20Permit */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) public virtual { if (block.timestamp > deadline) { revert ERC2612ExpiredSignature(deadline); } bytes32 structHash = keccak256(abi.encode(PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline)); bytes32 hash = _hashTypedDataV4(structHash); address signer = ECDSA.recover(hash, v, r, s); if (signer != owner) { revert ERC2612InvalidSigner(signer, owner); } _approve(owner, spender, value); } /** * @inheritdoc IERC20Permit */ function nonces(address owner) public view virtual override(IERC20Permit, NoncesUpgradeable) returns (uint256) { return super.nonces(owner); } /** * @inheritdoc IERC20Permit */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view virtual returns (bytes32) { return _domainSeparatorV4(); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol) pragma solidity ^0.8.20; import {Initializable} from "../proxy/utils/Initializable.sol"; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract ContextUpgradeable is Initializable { function __Context_init() internal onlyInitializing { } function __Context_init_unchained() internal onlyInitializing { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } function _contextSuffixLength() internal view virtual returns (uint256) { return 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/EIP712.sol) pragma solidity ^0.8.20; import {MessageHashUtils} from "@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol"; import {IERC5267} from "@openzeppelin/contracts/interfaces/IERC5267.sol"; import {Initializable} from "../../proxy/utils/Initializable.sol"; /** * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data. * * The encoding scheme specified in the EIP requires a domain separator and a hash of the typed structured data, whose * encoding is very generic and therefore its implementation in Solidity is not feasible, thus this contract * does not implement the encoding itself. Protocols need to implement the type-specific encoding they need in order to * produce the hash of their typed data using a combination of `abi.encode` and `keccak256`. * * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA * ({_hashTypedDataV4}). * * The implementation of the domain separator was designed to be as efficient as possible while still properly updating * the chain id to protect against replay attacks on an eventual fork of the chain. * * NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask]. * * NOTE: In the upgradeable version of this contract, the cached values will correspond to the address, and the domain * separator of the implementation contract. This will cause the {_domainSeparatorV4} function to always rebuild the * separator from the immutable values, which is cheaper than accessing a cached version in cold storage. */ abstract contract EIP712Upgradeable is Initializable, IERC5267 { bytes32 private constant TYPE_HASH = keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"); /// @custom:storage-location erc7201:openzeppelin.storage.EIP712 struct EIP712Storage { /// @custom:oz-renamed-from _HASHED_NAME bytes32 _hashedName; /// @custom:oz-renamed-from _HASHED_VERSION bytes32 _hashedVersion; string _name; string _version; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.EIP712")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant EIP712StorageLocation = 0xa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d100; function _getEIP712Storage() private pure returns (EIP712Storage storage $) { assembly { $.slot := EIP712StorageLocation } } /** * @dev Initializes the domain separator and parameter caches. * * The meaning of `name` and `version` is specified in * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]: * * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol. * - `version`: the current major version of the signing domain. * * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart * contract upgrade]. */ function __EIP712_init(string memory name, string memory version) internal onlyInitializing { __EIP712_init_unchained(name, version); } function __EIP712_init_unchained(string memory name, string memory version) internal onlyInitializing { EIP712Storage storage $ = _getEIP712Storage(); $._name = name; $._version = version; // Reset prior values in storage if upgrading $._hashedName = 0; $._hashedVersion = 0; } /** * @dev Returns the domain separator for the current chain. */ function _domainSeparatorV4() internal view returns (bytes32) { return _buildDomainSeparator(); } function _buildDomainSeparator() private view returns (bytes32) { return keccak256(abi.encode(TYPE_HASH, _EIP712NameHash(), _EIP712VersionHash(), block.chainid, address(this))); } /** * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this * function returns the hash of the fully encoded EIP712 message for this domain. * * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example: * * ```solidity * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode( * keccak256("Mail(address to,string contents)"), * mailTo, * keccak256(bytes(mailContents)) * ))); * address signer = ECDSA.recover(digest, signature); * ``` */ function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) { return MessageHashUtils.toTypedDataHash(_domainSeparatorV4(), structHash); } /** * @dev See {IERC-5267}. */ function eip712Domain() public view virtual returns ( bytes1 fields, string memory name, string memory version, uint256 chainId, address verifyingContract, bytes32 salt, uint256[] memory extensions ) { EIP712Storage storage $ = _getEIP712Storage(); // If the hashed name and version in storage are non-zero, the contract hasn't been properly initialized // and the EIP712 domain is not reliable, as it will be missing name and version. require($._hashedName == 0 && $._hashedVersion == 0, "EIP712: Uninitialized"); return ( hex"0f", // 01111 _EIP712Name(), _EIP712Version(), block.chainid, address(this), bytes32(0), new uint256[](0) ); } /** * @dev The name parameter for the EIP712 domain. * * NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs * are a concern. */ function _EIP712Name() internal view virtual returns (string memory) { EIP712Storage storage $ = _getEIP712Storage(); return $._name; } /** * @dev The version parameter for the EIP712 domain. * * NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs * are a concern. */ function _EIP712Version() internal view virtual returns (string memory) { EIP712Storage storage $ = _getEIP712Storage(); return $._version; } /** * @dev The hash of the name parameter for the EIP712 domain. * * NOTE: In previous versions this function was virtual. In this version you should override `_EIP712Name` instead. */ function _EIP712NameHash() internal view returns (bytes32) { EIP712Storage storage $ = _getEIP712Storage(); string memory name = _EIP712Name(); if (bytes(name).length > 0) { return keccak256(bytes(name)); } else { // If the name is empty, the contract may have been upgraded without initializing the new storage. // We return the name hash in storage if non-zero, otherwise we assume the name is empty by design. bytes32 hashedName = $._hashedName; if (hashedName != 0) { return hashedName; } else { return keccak256(""); } } } /** * @dev The hash of the version parameter for the EIP712 domain. * * NOTE: In previous versions this function was virtual. In this version you should override `_EIP712Version` instead. */ function _EIP712VersionHash() internal view returns (bytes32) { EIP712Storage storage $ = _getEIP712Storage(); string memory version = _EIP712Version(); if (bytes(version).length > 0) { return keccak256(bytes(version)); } else { // If the version is empty, the contract may have been upgraded without initializing the new storage. // We return the version hash in storage if non-zero, otherwise we assume the version is empty by design. bytes32 hashedVersion = $._hashedVersion; if (hashedVersion != 0) { return hashedVersion; } else { return keccak256(""); } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol) pragma solidity ^0.8.20; import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol"; import {Initializable} from "../../proxy/utils/Initializable.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); * } * ``` */ abstract contract ERC165Upgradeable is Initializable, IERC165 { function __ERC165_init() internal onlyInitializing { } function __ERC165_init_unchained() internal onlyInitializing { } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) { return interfaceId == type(IERC165).interfaceId; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/Nonces.sol) pragma solidity ^0.8.20; import {Initializable} from "../proxy/utils/Initializable.sol"; /** * @dev Provides tracking nonces for addresses. Nonces will only increment. */ abstract contract NoncesUpgradeable is Initializable { /** * @dev The nonce used for an `account` is not the expected current nonce. */ error InvalidAccountNonce(address account, uint256 currentNonce); /// @custom:storage-location erc7201:openzeppelin.storage.Nonces struct NoncesStorage { mapping(address account => uint256) _nonces; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Nonces")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant NoncesStorageLocation = 0x5ab42ced628888259c08ac98db1eb0cf702fc1501344311d8b100cd1bfe4bb00; function _getNoncesStorage() private pure returns (NoncesStorage storage $) { assembly { $.slot := NoncesStorageLocation } } function __Nonces_init() internal onlyInitializing { } function __Nonces_init_unchained() internal onlyInitializing { } /** * @dev Returns the next unused nonce for an address. */ function nonces(address owner) public view virtual returns (uint256) { NoncesStorage storage $ = _getNoncesStorage(); return $._nonces[owner]; } /** * @dev Consumes a nonce. * * Returns the current value and increments nonce. */ function _useNonce(address owner) internal virtual returns (uint256) { NoncesStorage storage $ = _getNoncesStorage(); // For each account, the nonce has an initial value of 0, can only be incremented by one, and cannot be // decremented or reset. This guarantees that the nonce never overflows. unchecked { // It is important to do x++ and not ++x here. return $._nonces[owner]++; } } /** * @dev Same as {_useNonce} but checking that `nonce` is the next valid for `owner`. */ function _useCheckedNonce(address owner, uint256 nonce) internal virtual { uint256 current = _useNonce(owner); if (nonce != current) { revert InvalidAccountNonce(owner, current); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/ReentrancyGuard.sol) pragma solidity ^0.8.20; import {Initializable} from "../proxy/utils/Initializable.sol"; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuardUpgradeable is Initializable { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant NOT_ENTERED = 1; uint256 private constant ENTERED = 2; /// @custom:storage-location erc7201:openzeppelin.storage.ReentrancyGuard struct ReentrancyGuardStorage { uint256 _status; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.ReentrancyGuard")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant ReentrancyGuardStorageLocation = 0x9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00; function _getReentrancyGuardStorage() private pure returns (ReentrancyGuardStorage storage $) { assembly { $.slot := ReentrancyGuardStorageLocation } } /** * @dev Unauthorized reentrant call. */ error ReentrancyGuardReentrantCall(); function __ReentrancyGuard_init() internal onlyInitializing { __ReentrancyGuard_init_unchained(); } function __ReentrancyGuard_init_unchained() internal onlyInitializing { ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage(); $._status = NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { _nonReentrantBefore(); _; _nonReentrantAfter(); } function _nonReentrantBefore() private { ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage(); // On the first call to nonReentrant, _status will be NOT_ENTERED if ($._status == ENTERED) { revert ReentrancyGuardReentrantCall(); } // Any calls to nonReentrant after this point will fail $._status = ENTERED; } function _nonReentrantAfter() private { ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage(); // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) $._status = NOT_ENTERED; } /** * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a * `nonReentrant` function in the call stack. */ function _reentrancyGuardEntered() internal view returns (bool) { ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage(); return $._status == ENTERED; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol) pragma solidity ^0.8.20; import {IAccessControl} from "./IAccessControl.sol"; import {Context} from "../utils/Context.sol"; import {ERC165} from "../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 account => bool) hasRole; bytes32 adminRole; } mapping(bytes32 role => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Modifier that checks that an account has a specific role. Reverts * with an {AccessControlUnauthorizedAccount} error including the required role. */ 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 returns (bool) { return _roles[role].hasRole[account]; } /** * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()` * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier. */ function _checkRole(bytes32 role) internal view virtual { _checkRole(role, _msgSender()); } /** * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account` * is missing `role`. */ function _checkRole(bytes32 role, address account) internal view virtual { if (!hasRole(role, account)) { revert AccessControlUnauthorizedAccount(account, role); } } /** * @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 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 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 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 `callerConfirmation`. * * May emit a {RoleRevoked} event. */ function renounceRole(bytes32 role, address callerConfirmation) public virtual { if (callerConfirmation != _msgSender()) { revert AccessControlBadConfirmation(); } _revokeRole(role, callerConfirmation); } /** * @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 Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted. * * Internal function without access restriction. * * May emit a {RoleGranted} event. */ function _grantRole(bytes32 role, address account) internal virtual returns (bool) { if (!hasRole(role, account)) { _roles[role].hasRole[account] = true; emit RoleGranted(role, account, _msgSender()); return true; } else { return false; } } /** * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked. * * Internal function without access restriction. * * May emit a {RoleRevoked} event. */ function _revokeRole(bytes32 role, address account) internal virtual returns (bool) { if (hasRole(role, account)) { _roles[role].hasRole[account] = false; emit RoleRevoked(role, account, _msgSender()); return true; } else { return false; } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol) pragma solidity ^0.8.20; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControl { /** * @dev The `account` is missing a role. */ error AccessControlUnauthorizedAccount(address account, bytes32 neededRole); /** * @dev The caller of a function is not the expected one. * * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}. */ error AccessControlBadConfirmation(); /** * @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. */ 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 `callerConfirmation`. */ function renounceRole(bytes32 role, address callerConfirmation) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (interfaces/draft-IERC1822.sol) pragma solidity ^0.8.20; /** * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified * proxy whose upgrades are fully controlled by the current implementation. */ interface IERC1822Proxiable { /** * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation * address. * * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this * function revert if invoked through a proxy. */ function proxiableUUID() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (interfaces/draft-IERC6093.sol) pragma solidity ^0.8.20; /** * @dev Standard ERC20 Errors * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC20 tokens. */ interface IERC20Errors { /** * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. * @param balance Current balance for the interacting account. * @param needed Minimum amount required to perform a transfer. */ error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed); /** * @dev Indicates a failure with the token `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. */ error ERC20InvalidSender(address sender); /** * @dev Indicates a failure with the token `receiver`. Used in transfers. * @param receiver Address to which tokens are being transferred. */ error ERC20InvalidReceiver(address receiver); /** * @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers. * @param spender Address that may be allowed to operate on tokens without being their owner. * @param allowance Amount of tokens a `spender` is allowed to operate with. * @param needed Minimum amount required to perform a transfer. */ error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed); /** * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals. * @param approver Address initiating an approval operation. */ error ERC20InvalidApprover(address approver); /** * @dev Indicates a failure with the `spender` to be approved. Used in approvals. * @param spender Address that may be allowed to operate on tokens without being their owner. */ error ERC20InvalidSpender(address spender); } /** * @dev Standard ERC721 Errors * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC721 tokens. */ interface IERC721Errors { /** * @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in EIP-20. * Used in balance queries. * @param owner Address of the current owner of a token. */ error ERC721InvalidOwner(address owner); /** * @dev Indicates a `tokenId` whose `owner` is the zero address. * @param tokenId Identifier number of a token. */ error ERC721NonexistentToken(uint256 tokenId); /** * @dev Indicates an error related to the ownership over a particular token. Used in transfers. * @param sender Address whose tokens are being transferred. * @param tokenId Identifier number of a token. * @param owner Address of the current owner of a token. */ error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner); /** * @dev Indicates a failure with the token `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. */ error ERC721InvalidSender(address sender); /** * @dev Indicates a failure with the token `receiver`. Used in transfers. * @param receiver Address to which tokens are being transferred. */ error ERC721InvalidReceiver(address receiver); /** * @dev Indicates a failure with the `operator`’s approval. Used in transfers. * @param operator Address that may be allowed to operate on tokens without being their owner. * @param tokenId Identifier number of a token. */ error ERC721InsufficientApproval(address operator, uint256 tokenId); /** * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals. * @param approver Address initiating an approval operation. */ error ERC721InvalidApprover(address approver); /** * @dev Indicates a failure with the `operator` to be approved. Used in approvals. * @param operator Address that may be allowed to operate on tokens without being their owner. */ error ERC721InvalidOperator(address operator); } /** * @dev Standard ERC1155 Errors * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC1155 tokens. */ interface IERC1155Errors { /** * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. * @param balance Current balance for the interacting account. * @param needed Minimum amount required to perform a transfer. * @param tokenId Identifier number of a token. */ error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId); /** * @dev Indicates a failure with the token `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. */ error ERC1155InvalidSender(address sender); /** * @dev Indicates a failure with the token `receiver`. Used in transfers. * @param receiver Address to which tokens are being transferred. */ error ERC1155InvalidReceiver(address receiver); /** * @dev Indicates a failure with the `operator`’s approval. Used in transfers. * @param operator Address that may be allowed to operate on tokens without being their owner. * @param owner Address of the current owner of a token. */ error ERC1155MissingApprovalForAll(address operator, address owner); /** * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals. * @param approver Address initiating an approval operation. */ error ERC1155InvalidApprover(address approver); /** * @dev Indicates a failure with the `operator` to be approved. Used in approvals. * @param operator Address that may be allowed to operate on tokens without being their owner. */ error ERC1155InvalidOperator(address operator); /** * @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation. * Used in batch transfers. * @param idsLength Length of the array of token identifiers * @param valuesLength Length of the array of token amounts */ error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC5267.sol) pragma solidity ^0.8.20; interface IERC5267 { /** * @dev MAY be emitted to signal that the domain could have changed. */ event EIP712DomainChanged(); /** * @dev returns the fields and values that describe the domain separator used by this contract for EIP-712 * signature. */ function eip712Domain() external view returns ( bytes1 fields, string memory name, string memory version, uint256 chainId, address verifyingContract, bytes32 salt, uint256[] memory extensions ); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (proxy/beacon/IBeacon.sol) pragma solidity ^0.8.20; /** * @dev This is the interface that {BeaconProxy} expects of its beacon. */ interface IBeacon { /** * @dev Must return an address that can be used as a delegate call target. * * {UpgradeableBeacon} will check that this address is a contract. */ function implementation() external view returns (address); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (proxy/ERC1967/ERC1967Utils.sol) pragma solidity ^0.8.20; import {IBeacon} from "../beacon/IBeacon.sol"; import {Address} from "../../utils/Address.sol"; import {StorageSlot} from "../../utils/StorageSlot.sol"; /** * @dev This abstract contract provides getters and event emitting update functions for * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots. */ library ERC1967Utils { // We re-declare ERC-1967 events here because they can't be used directly from IERC1967. // This will be fixed in Solidity 0.8.21. At that point we should remove these events. /** * @dev Emitted when the implementation is upgraded. */ event Upgraded(address indexed implementation); /** * @dev Emitted when the admin account has changed. */ event AdminChanged(address previousAdmin, address newAdmin); /** * @dev Emitted when the beacon is changed. */ event BeaconUpgraded(address indexed beacon); /** * @dev Storage slot with the address of the current implementation. * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1. */ // solhint-disable-next-line private-vars-leading-underscore bytes32 internal constant IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /** * @dev The `implementation` of the proxy is invalid. */ error ERC1967InvalidImplementation(address implementation); /** * @dev The `admin` of the proxy is invalid. */ error ERC1967InvalidAdmin(address admin); /** * @dev The `beacon` of the proxy is invalid. */ error ERC1967InvalidBeacon(address beacon); /** * @dev An upgrade function sees `msg.value > 0` that may be lost. */ error ERC1967NonPayable(); /** * @dev Returns the current implementation address. */ function getImplementation() internal view returns (address) { return StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value; } /** * @dev Stores a new address in the EIP1967 implementation slot. */ function _setImplementation(address newImplementation) private { if (newImplementation.code.length == 0) { revert ERC1967InvalidImplementation(newImplementation); } StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value = newImplementation; } /** * @dev Performs implementation upgrade with additional setup call if data is nonempty. * This function is payable only if the setup call is performed, otherwise `msg.value` is rejected * to avoid stuck value in the contract. * * Emits an {IERC1967-Upgraded} event. */ function upgradeToAndCall(address newImplementation, bytes memory data) internal { _setImplementation(newImplementation); emit Upgraded(newImplementation); if (data.length > 0) { Address.functionDelegateCall(newImplementation, data); } else { _checkNonPayable(); } } /** * @dev Storage slot with the admin of the contract. * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1. */ // solhint-disable-next-line private-vars-leading-underscore bytes32 internal constant ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103; /** * @dev Returns the current admin. * * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using * the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103` */ function getAdmin() internal view returns (address) { return StorageSlot.getAddressSlot(ADMIN_SLOT).value; } /** * @dev Stores a new address in the EIP1967 admin slot. */ function _setAdmin(address newAdmin) private { if (newAdmin == address(0)) { revert ERC1967InvalidAdmin(address(0)); } StorageSlot.getAddressSlot(ADMIN_SLOT).value = newAdmin; } /** * @dev Changes the admin of the proxy. * * Emits an {IERC1967-AdminChanged} event. */ function changeAdmin(address newAdmin) internal { emit AdminChanged(getAdmin(), newAdmin); _setAdmin(newAdmin); } /** * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy. * This is the keccak-256 hash of "eip1967.proxy.beacon" subtracted by 1. */ // solhint-disable-next-line private-vars-leading-underscore bytes32 internal constant BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50; /** * @dev Returns the current beacon. */ function getBeacon() internal view returns (address) { return StorageSlot.getAddressSlot(BEACON_SLOT).value; } /** * @dev Stores a new beacon in the EIP1967 beacon slot. */ function _setBeacon(address newBeacon) private { if (newBeacon.code.length == 0) { revert ERC1967InvalidBeacon(newBeacon); } StorageSlot.getAddressSlot(BEACON_SLOT).value = newBeacon; address beaconImplementation = IBeacon(newBeacon).implementation(); if (beaconImplementation.code.length == 0) { revert ERC1967InvalidImplementation(beaconImplementation); } } /** * @dev Change the beacon and trigger a setup call if data is nonempty. * This function is payable only if the setup call is performed, otherwise `msg.value` is rejected * to avoid stuck value in the contract. * * Emits an {IERC1967-BeaconUpgraded} event. * * CAUTION: Invoking this function has no effect on an instance of {BeaconProxy} since v5, since * it uses an immutable beacon without looking at the value of the ERC-1967 beacon slot for * efficiency. */ function upgradeBeaconToAndCall(address newBeacon, bytes memory data) internal { _setBeacon(newBeacon); emit BeaconUpgraded(newBeacon); if (data.length > 0) { Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data); } else { _checkNonPayable(); } } /** * @dev Reverts if `msg.value` is not zero. It can be used to avoid `msg.value` stuck in the contract * if an upgrade doesn't perform an initialization call. */ function _checkNonPayable() private { if (msg.value > 0) { revert ERC1967NonPayable(); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC1155/ERC1155.sol) pragma solidity ^0.8.20; import {IERC1155} from "./IERC1155.sol"; import {IERC1155Receiver} from "./IERC1155Receiver.sol"; import {IERC1155MetadataURI} from "./extensions/IERC1155MetadataURI.sol"; import {Context} from "../../utils/Context.sol"; import {IERC165, ERC165} from "../../utils/introspection/ERC165.sol"; import {Arrays} from "../../utils/Arrays.sol"; import {IERC1155Errors} from "../../interfaces/draft-IERC6093.sol"; /** * @dev Implementation of the basic standard multi-token. * See https://eips.ethereum.org/EIPS/eip-1155 * Originally based on code by Enjin: https://github.com/enjin/erc-1155 */ abstract contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI, IERC1155Errors { using Arrays for uint256[]; using Arrays for address[]; mapping(uint256 id => mapping(address account => uint256)) private _balances; mapping(address account => mapping(address operator => bool)) private _operatorApprovals; // Used as the URI for all token types by relying on ID substitution, e.g. https://token-cdn-domain/{id}.json string private _uri; /** * @dev See {_setURI}. */ constructor(string memory uri_) { _setURI(uri_); } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC1155).interfaceId || interfaceId == type(IERC1155MetadataURI).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC1155MetadataURI-uri}. * * This implementation returns the same URI for *all* token types. It relies * on the token type ID substitution mechanism * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP]. * * Clients calling this function must replace the `\{id\}` substring with the * actual token type ID. */ function uri(uint256 /* id */) public view virtual returns (string memory) { return _uri; } /** * @dev See {IERC1155-balanceOf}. */ function balanceOf(address account, uint256 id) public view virtual returns (uint256) { return _balances[id][account]; } /** * @dev See {IERC1155-balanceOfBatch}. * * Requirements: * * - `accounts` and `ids` must have the same length. */ function balanceOfBatch( address[] memory accounts, uint256[] memory ids ) public view virtual returns (uint256[] memory) { if (accounts.length != ids.length) { revert ERC1155InvalidArrayLength(ids.length, accounts.length); } uint256[] memory batchBalances = new uint256[](accounts.length); for (uint256 i = 0; i < accounts.length; ++i) { batchBalances[i] = balanceOf(accounts.unsafeMemoryAccess(i), ids.unsafeMemoryAccess(i)); } return batchBalances; } /** * @dev See {IERC1155-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC1155-isApprovedForAll}. */ function isApprovedForAll(address account, address operator) public view virtual returns (bool) { return _operatorApprovals[account][operator]; } /** * @dev See {IERC1155-safeTransferFrom}. */ function safeTransferFrom(address from, address to, uint256 id, uint256 value, bytes memory data) public virtual { address sender = _msgSender(); if (from != sender && !isApprovedForAll(from, sender)) { revert ERC1155MissingApprovalForAll(sender, from); } _safeTransferFrom(from, to, id, value, data); } /** * @dev See {IERC1155-safeBatchTransferFrom}. */ function safeBatchTransferFrom( address from, address to, uint256[] memory ids, uint256[] memory values, bytes memory data ) public virtual { address sender = _msgSender(); if (from != sender && !isApprovedForAll(from, sender)) { revert ERC1155MissingApprovalForAll(sender, from); } _safeBatchTransferFrom(from, to, ids, values, data); } /** * @dev Transfers a `value` amount of tokens of type `id` from `from` to `to`. Will mint (or burn) if `from` * (or `to`) is the zero address. * * Emits a {TransferSingle} event if the arrays contain one element, and {TransferBatch} otherwise. * * Requirements: * * - If `to` refers to a smart contract, it must implement either {IERC1155Receiver-onERC1155Received} * or {IERC1155Receiver-onERC1155BatchReceived} and return the acceptance magic value. * - `ids` and `values` must have the same length. * * NOTE: The ERC-1155 acceptance check is not performed in this function. See {_updateWithAcceptanceCheck} instead. */ function _update(address from, address to, uint256[] memory ids, uint256[] memory values) internal virtual { if (ids.length != values.length) { revert ERC1155InvalidArrayLength(ids.length, values.length); } address operator = _msgSender(); for (uint256 i = 0; i < ids.length; ++i) { uint256 id = ids.unsafeMemoryAccess(i); uint256 value = values.unsafeMemoryAccess(i); if (from != address(0)) { uint256 fromBalance = _balances[id][from]; if (fromBalance < value) { revert ERC1155InsufficientBalance(from, fromBalance, value, id); } unchecked { // Overflow not possible: value <= fromBalance _balances[id][from] = fromBalance - value; } } if (to != address(0)) { _balances[id][to] += value; } } if (ids.length == 1) { uint256 id = ids.unsafeMemoryAccess(0); uint256 value = values.unsafeMemoryAccess(0); emit TransferSingle(operator, from, to, id, value); } else { emit TransferBatch(operator, from, to, ids, values); } } /** * @dev Version of {_update} that performs the token acceptance check by calling * {IERC1155Receiver-onERC1155Received} or {IERC1155Receiver-onERC1155BatchReceived} on the receiver address if it * contains code (eg. is a smart contract at the moment of execution). * * IMPORTANT: Overriding this function is discouraged because it poses a reentrancy risk from the receiver. So any * update to the contract state after this function would break the check-effect-interaction pattern. Consider * overriding {_update} instead. */ function _updateWithAcceptanceCheck( address from, address to, uint256[] memory ids, uint256[] memory values, bytes memory data ) internal virtual { _update(from, to, ids, values); if (to != address(0)) { address operator = _msgSender(); if (ids.length == 1) { uint256 id = ids.unsafeMemoryAccess(0); uint256 value = values.unsafeMemoryAccess(0); _doSafeTransferAcceptanceCheck(operator, from, to, id, value, data); } else { _doSafeBatchTransferAcceptanceCheck(operator, from, to, ids, values, data); } } } /** * @dev Transfers a `value` tokens of token type `id` from `from` to `to`. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - `from` must have a balance of tokens of type `id` of at least `value` amount. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function _safeTransferFrom(address from, address to, uint256 id, uint256 value, bytes memory data) internal { if (to == address(0)) { revert ERC1155InvalidReceiver(address(0)); } if (from == address(0)) { revert ERC1155InvalidSender(address(0)); } (uint256[] memory ids, uint256[] memory values) = _asSingletonArrays(id, value); _updateWithAcceptanceCheck(from, to, ids, values, data); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_safeTransferFrom}. * * Emits a {TransferBatch} event. * * Requirements: * * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. * - `ids` and `values` must have the same length. */ function _safeBatchTransferFrom( address from, address to, uint256[] memory ids, uint256[] memory values, bytes memory data ) internal { if (to == address(0)) { revert ERC1155InvalidReceiver(address(0)); } if (from == address(0)) { revert ERC1155InvalidSender(address(0)); } _updateWithAcceptanceCheck(from, to, ids, values, data); } /** * @dev Sets a new URI for all token types, by relying on the token type ID * substitution mechanism * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP]. * * By this mechanism, any occurrence of the `\{id\}` substring in either the * URI or any of the values in the JSON file at said URI will be replaced by * clients with the token type ID. * * For example, the `https://token-cdn-domain/\{id\}.json` URI would be * interpreted by clients as * `https://token-cdn-domain/000000000000000000000000000000000000000000000000000000000004cce0.json` * for token type ID 0x4cce0. * * See {uri}. * * Because these URIs cannot be meaningfully represented by the {URI} event, * this function emits no events. */ function _setURI(string memory newuri) internal virtual { _uri = newuri; } /** * @dev Creates a `value` amount of tokens of type `id`, and assigns them to `to`. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function _mint(address to, uint256 id, uint256 value, bytes memory data) internal { if (to == address(0)) { revert ERC1155InvalidReceiver(address(0)); } (uint256[] memory ids, uint256[] memory values) = _asSingletonArrays(id, value); _updateWithAcceptanceCheck(address(0), to, ids, values, data); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_mint}. * * Emits a {TransferBatch} event. * * Requirements: * * - `ids` and `values` must have the same length. * - `to` cannot be the zero address. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function _mintBatch(address to, uint256[] memory ids, uint256[] memory values, bytes memory data) internal { if (to == address(0)) { revert ERC1155InvalidReceiver(address(0)); } _updateWithAcceptanceCheck(address(0), to, ids, values, data); } /** * @dev Destroys a `value` amount of tokens of type `id` from `from` * * Emits a {TransferSingle} event. * * Requirements: * * - `from` cannot be the zero address. * - `from` must have at least `value` amount of tokens of type `id`. */ function _burn(address from, uint256 id, uint256 value) internal { if (from == address(0)) { revert ERC1155InvalidSender(address(0)); } (uint256[] memory ids, uint256[] memory values) = _asSingletonArrays(id, value); _updateWithAcceptanceCheck(from, address(0), ids, values, ""); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_burn}. * * Emits a {TransferBatch} event. * * Requirements: * * - `from` cannot be the zero address. * - `from` must have at least `value` amount of tokens of type `id`. * - `ids` and `values` must have the same length. */ function _burnBatch(address from, uint256[] memory ids, uint256[] memory values) internal { if (from == address(0)) { revert ERC1155InvalidSender(address(0)); } _updateWithAcceptanceCheck(from, address(0), ids, values, ""); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits an {ApprovalForAll} event. * * Requirements: * * - `operator` cannot be the zero address. */ function _setApprovalForAll(address owner, address operator, bool approved) internal virtual { if (operator == address(0)) { revert ERC1155InvalidOperator(address(0)); } _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Performs an acceptance check by calling {IERC1155-onERC1155Received} on the `to` address * if it contains code at the moment of execution. */ function _doSafeTransferAcceptanceCheck( address operator, address from, address to, uint256 id, uint256 value, bytes memory data ) private { if (to.code.length > 0) { try IERC1155Receiver(to).onERC1155Received(operator, from, id, value, data) returns (bytes4 response) { if (response != IERC1155Receiver.onERC1155Received.selector) { // Tokens rejected revert ERC1155InvalidReceiver(to); } } catch (bytes memory reason) { if (reason.length == 0) { // non-ERC1155Receiver implementer revert ERC1155InvalidReceiver(to); } else { /// @solidity memory-safe-assembly assembly { revert(add(32, reason), mload(reason)) } } } } } /** * @dev Performs a batch acceptance check by calling {IERC1155-onERC1155BatchReceived} on the `to` address * if it contains code at the moment of execution. */ function _doSafeBatchTransferAcceptanceCheck( address operator, address from, address to, uint256[] memory ids, uint256[] memory values, bytes memory data ) private { if (to.code.length > 0) { try IERC1155Receiver(to).onERC1155BatchReceived(operator, from, ids, values, data) returns ( bytes4 response ) { if (response != IERC1155Receiver.onERC1155BatchReceived.selector) { // Tokens rejected revert ERC1155InvalidReceiver(to); } } catch (bytes memory reason) { if (reason.length == 0) { // non-ERC1155Receiver implementer revert ERC1155InvalidReceiver(to); } else { /// @solidity memory-safe-assembly assembly { revert(add(32, reason), mload(reason)) } } } } } /** * @dev Creates an array in memory with only one value for each of the elements provided. */ function _asSingletonArrays( uint256 element1, uint256 element2 ) private pure returns (uint256[] memory array1, uint256[] memory array2) { /// @solidity memory-safe-assembly assembly { // Load the free memory pointer array1 := mload(0x40) // Set array length to 1 mstore(array1, 1) // Store the single element at the next word after the length (where content starts) mstore(add(array1, 0x20), element1) // Repeat for next array locating it right after the first array array2 := add(array1, 0x40) mstore(array2, 1) mstore(add(array2, 0x20), element2) // Update the free memory pointer by pointing after the second array mstore(0x40, add(array2, 0x40)) } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC1155/extensions/ERC1155Burnable.sol) pragma solidity ^0.8.20; import {ERC1155} from "../ERC1155.sol"; /** * @dev Extension of {ERC1155} that allows token holders to destroy both their * own tokens and those that they have been approved to use. */ abstract contract ERC1155Burnable is ERC1155 { function burn(address account, uint256 id, uint256 value) public virtual { if (account != _msgSender() && !isApprovedForAll(account, _msgSender())) { revert ERC1155MissingApprovalForAll(_msgSender(), account); } _burn(account, id, value); } function burnBatch(address account, uint256[] memory ids, uint256[] memory values) public virtual { if (account != _msgSender() && !isApprovedForAll(account, _msgSender())) { revert ERC1155MissingApprovalForAll(_msgSender(), account); } _burnBatch(account, ids, values); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC1155/extensions/ERC1155Supply.sol) pragma solidity ^0.8.20; import {ERC1155} from "../ERC1155.sol"; /** * @dev Extension of ERC1155 that adds tracking of total supply per id. * * Useful for scenarios where Fungible and Non-fungible tokens have to be * clearly identified. Note: While a totalSupply of 1 might mean the * corresponding is an NFT, there is no guarantees that no other token with the * same id are not going to be minted. * * NOTE: This contract implies a global limit of 2**256 - 1 to the number of tokens * that can be minted. * * CAUTION: This extension should not be added in an upgrade to an already deployed contract. */ abstract contract ERC1155Supply is ERC1155 { mapping(uint256 id => uint256) private _totalSupply; uint256 private _totalSupplyAll; /** * @dev Total value of tokens in with a given id. */ function totalSupply(uint256 id) public view virtual returns (uint256) { return _totalSupply[id]; } /** * @dev Total value of tokens. */ function totalSupply() public view virtual returns (uint256) { return _totalSupplyAll; } /** * @dev Indicates whether any token exist with a given id, or not. */ function exists(uint256 id) public view virtual returns (bool) { return totalSupply(id) > 0; } /** * @dev See {ERC1155-_update}. */ function _update( address from, address to, uint256[] memory ids, uint256[] memory values ) internal virtual override { super._update(from, to, ids, values); if (from == address(0)) { uint256 totalMintValue = 0; for (uint256 i = 0; i < ids.length; ++i) { uint256 value = values[i]; // Overflow check required: The rest of the code assumes that totalSupply never overflows _totalSupply[ids[i]] += value; totalMintValue += value; } // Overflow check required: The rest of the code assumes that totalSupplyAll never overflows _totalSupplyAll += totalMintValue; } if (to == address(0)) { uint256 totalBurnValue = 0; for (uint256 i = 0; i < ids.length; ++i) { uint256 value = values[i]; unchecked { // Overflow not possible: values[i] <= balanceOf(from, ids[i]) <= totalSupply(ids[i]) _totalSupply[ids[i]] -= value; // Overflow not possible: sum_i(values[i]) <= sum_i(totalSupply(ids[i])) <= totalSupplyAll totalBurnValue += value; } } unchecked { // Overflow not possible: totalBurnValue = sum_i(values[i]) <= sum_i(totalSupply(ids[i])) <= totalSupplyAll _totalSupplyAll -= totalBurnValue; } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC1155/extensions/IERC1155MetadataURI.sol) pragma solidity ^0.8.20; import {IERC1155} from "../IERC1155.sol"; /** * @dev Interface of the optional ERC1155MetadataExtension interface, as defined * in the https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[EIP]. */ interface IERC1155MetadataURI is IERC1155 { /** * @dev Returns the URI for token type `id`. * * If the `\{id\}` substring is present in the URI, it must be replaced by * clients with the actual token type ID. */ function uri(uint256 id) external view returns (string memory); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.1) (token/ERC1155/IERC1155.sol) pragma solidity ^0.8.20; import {IERC165} from "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC1155 compliant contract, as defined in the * https://eips.ethereum.org/EIPS/eip-1155[EIP]. */ interface IERC1155 is IERC165 { /** * @dev Emitted when `value` amount of tokens of type `id` are transferred from `from` to `to` by `operator`. */ event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value); /** * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all * transfers. */ event TransferBatch( address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values ); /** * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to * `approved`. */ event ApprovalForAll(address indexed account, address indexed operator, bool approved); /** * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI. * * If an {URI} event was emitted for `id`, the standard * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value * returned by {IERC1155MetadataURI-uri}. */ event URI(string value, uint256 indexed id); /** * @dev Returns the value of tokens of token type `id` owned by `account`. * * Requirements: * * - `account` cannot be the zero address. */ function balanceOf(address account, uint256 id) external view returns (uint256); /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}. * * Requirements: * * - `accounts` and `ids` must have the same length. */ function balanceOfBatch( address[] calldata accounts, uint256[] calldata ids ) external view returns (uint256[] memory); /** * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`, * * Emits an {ApprovalForAll} event. * * Requirements: * * - `operator` cannot be the caller. */ function setApprovalForAll(address operator, bool approved) external; /** * @dev Returns true if `operator` is approved to transfer ``account``'s tokens. * * See {setApprovalForAll}. */ function isApprovedForAll(address account, address operator) external view returns (bool); /** * @dev Transfers a `value` amount of tokens of type `id` from `from` to `to`. * * WARNING: This function can potentially allow a reentrancy attack when transferring tokens * to an untrusted contract, when invoking {onERC1155Received} on the receiver. * Ensure to follow the checks-effects-interactions pattern and consider employing * reentrancy guards when interacting with untrusted contracts. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}. * - `from` must have a balance of tokens of type `id` of at least `value` amount. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function safeTransferFrom(address from, address to, uint256 id, uint256 value, bytes calldata data) external; /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}. * * WARNING: This function can potentially allow a reentrancy attack when transferring tokens * to an untrusted contract, when invoking {onERC1155BatchReceived} on the receiver. * Ensure to follow the checks-effects-interactions pattern and consider employing * reentrancy guards when interacting with untrusted contracts. * * Emits either a {TransferSingle} or a {TransferBatch} event, depending on the length of the array arguments. * * Requirements: * * - `ids` and `values` must have the same length. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function safeBatchTransferFrom( address from, address to, uint256[] calldata ids, uint256[] calldata values, bytes calldata data ) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC1155/IERC1155Receiver.sol) pragma solidity ^0.8.20; import {IERC165} from "../../utils/introspection/IERC165.sol"; /** * @dev Interface that must be implemented by smart contracts in order to receive * ERC-1155 token transfers. */ interface IERC1155Receiver is IERC165 { /** * @dev Handles the receipt of a single ERC1155 token type. This function is * called at the end of a `safeTransferFrom` after the balance has been updated. * * NOTE: To accept the transfer, this must return * `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` * (i.e. 0xf23a6e61, or its own function selector). * * @param operator The address which initiated the transfer (i.e. msg.sender) * @param from The address which previously owned the token * @param id The ID of the token being transferred * @param value The amount of tokens being transferred * @param data Additional data with no specified format * @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed */ function onERC1155Received( address operator, address from, uint256 id, uint256 value, bytes calldata data ) external returns (bytes4); /** * @dev Handles the receipt of a multiple ERC1155 token types. This function * is called at the end of a `safeBatchTransferFrom` after the balances have * been updated. * * NOTE: To accept the transfer(s), this must return * `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` * (i.e. 0xbc197c81, or its own function selector). * * @param operator The address which initiated the batch transfer (i.e. msg.sender) * @param from The address which previously owned the token * @param ids An array containing ids of each token being transferred (order and length must match values array) * @param values An array containing amounts of each token being transferred (order and length must match ids array) * @param data Additional data with no specified format * @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed */ function onERC1155BatchReceived( address operator, address from, uint256[] calldata ids, uint256[] calldata values, bytes calldata data ) external returns (bytes4); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/ERC20.sol) pragma solidity ^0.8.20; import {IERC20} from "./IERC20.sol"; import {IERC20Metadata} from "./extensions/IERC20Metadata.sol"; import {Context} from "../../utils/Context.sol"; import {IERC20Errors} from "../../interfaces/draft-IERC6093.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}. * * 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. */ abstract contract ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors { mapping(address account => uint256) private _balances; mapping(address account => mapping(address spender => 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 returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual 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 returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual 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 `value`. */ function transfer(address to, uint256 value) public virtual returns (bool) { address owner = _msgSender(); _transfer(owner, to, value); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * NOTE: If `value` 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 value) public virtual returns (bool) { address owner = _msgSender(); _approve(owner, spender, value); 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 `value`. * - the caller must have allowance for ``from``'s tokens of at least * `value`. */ function transferFrom(address from, address to, uint256 value) public virtual returns (bool) { address spender = _msgSender(); _spendAllowance(from, spender, value); _transfer(from, to, value); return true; } /** * @dev Moves a `value` 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. * * NOTE: This function is not virtual, {_update} should be overridden instead. */ function _transfer(address from, address to, uint256 value) internal { if (from == address(0)) { revert ERC20InvalidSender(address(0)); } if (to == address(0)) { revert ERC20InvalidReceiver(address(0)); } _update(from, to, value); } /** * @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from` * (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding * this function. * * Emits a {Transfer} event. */ function _update(address from, address to, uint256 value) internal virtual { if (from == address(0)) { // Overflow check required: The rest of the code assumes that totalSupply never overflows _totalSupply += value; } else { uint256 fromBalance = _balances[from]; if (fromBalance < value) { revert ERC20InsufficientBalance(from, fromBalance, value); } unchecked { // Overflow not possible: value <= fromBalance <= totalSupply. _balances[from] = fromBalance - value; } } if (to == address(0)) { unchecked { // Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply. _totalSupply -= value; } } else { unchecked { // Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256. _balances[to] += value; } } emit Transfer(from, to, value); } /** * @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0). * Relies on the `_update` mechanism * * Emits a {Transfer} event with `from` set to the zero address. * * NOTE: This function is not virtual, {_update} should be overridden instead. */ function _mint(address account, uint256 value) internal { if (account == address(0)) { revert ERC20InvalidReceiver(address(0)); } _update(address(0), account, value); } /** * @dev Destroys a `value` amount of tokens from `account`, lowering the total supply. * Relies on the `_update` mechanism. * * Emits a {Transfer} event with `to` set to the zero address. * * NOTE: This function is not virtual, {_update} should be overridden instead */ function _burn(address account, uint256 value) internal { if (account == address(0)) { revert ERC20InvalidSender(address(0)); } _update(account, address(0), value); } /** * @dev Sets `value` 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. * * Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument. */ function _approve(address owner, address spender, uint256 value) internal { _approve(owner, spender, value, true); } /** * @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event. * * By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by * `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any * `Approval` event during `transferFrom` operations. * * Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to * true using the following override: * ``` * function _approve(address owner, address spender, uint256 value, bool) internal virtual override { * super._approve(owner, spender, value, true); * } * ``` * * Requirements are the same as {_approve}. */ function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual { if (owner == address(0)) { revert ERC20InvalidApprover(address(0)); } if (spender == address(0)) { revert ERC20InvalidSpender(address(0)); } _allowances[owner][spender] = value; if (emitEvent) { emit Approval(owner, spender, value); } } /** * @dev Updates `owner` s allowance for `spender` based on spent `value`. * * Does not update the allowance value in case of infinite allowance. * Revert if not enough allowance is available. * * Does not emit an {Approval} event. */ function _spendAllowance(address owner, address spender, uint256 value) internal virtual { uint256 currentAllowance = allowance(owner, spender); if (currentAllowance != type(uint256).max) { if (currentAllowance < value) { revert ERC20InsufficientAllowance(spender, currentAllowance, value); } unchecked { _approve(owner, spender, currentAllowance - value, false); } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.20; import {IERC20} from "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. */ 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); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. * * ==== Security Considerations * * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be * considered as an intention to spend the allowance in any specific way. The second is that because permits have * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be * generally recommended is: * * ```solidity * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public { * try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {} * doThing(..., value); * } * * function doThing(..., uint256 value) public { * token.safeTransferFrom(msg.sender, address(this), value); * ... * } * ``` * * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also * {SafeERC20-safeTransferFrom}). * * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so * contracts should have entry points that don't rely on permit. */ interface IERC20Permit { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. * * CAUTION: See Security Considerations above. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.20; /** * @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 value of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the value of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves a `value` amount of 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 value) 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 a `value` amount of tokens 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 value) external returns (bool); /** * @dev Moves a `value` amount of tokens from `from` to `to` using the * allowance mechanism. `value` 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 value) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol) pragma solidity ^0.8.20; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev The ETH balance of the account is not enough to perform the operation. */ error AddressInsufficientBalance(address account); /** * @dev There's no code at `target` (it is not a contract). */ error AddressEmptyCode(address target); /** * @dev A call to an address target failed. The target may have reverted. */ error FailedInnerCall(); /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { if (address(this).balance < amount) { revert AddressInsufficientBalance(address(this)); } (bool success, ) = recipient.call{value: amount}(""); if (!success) { revert FailedInnerCall(); } } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason or custom error, it is bubbled * up by this function (like regular Solidity function calls). However, if * the call reverted with no returned reason, this function reverts with a * {FailedInnerCall} error. * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { if (address(this).balance < value) { revert AddressInsufficientBalance(address(this)); } (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an * unsuccessful call. */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata ) internal view returns (bytes memory) { if (!success) { _revert(returndata); } else { // only check if target is a contract if the call was successful and the return data is empty // otherwise we already know that it was a contract if (returndata.length == 0 && target.code.length == 0) { revert AddressEmptyCode(target); } return returndata; } } /** * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the * revert reason or with a default {FailedInnerCall} error. */ function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) { if (!success) { _revert(returndata); } else { return returndata; } } /** * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}. */ function _revert(bytes memory returndata) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert FailedInnerCall(); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/Arrays.sol) pragma solidity ^0.8.20; import {StorageSlot} from "./StorageSlot.sol"; import {Math} from "./math/Math.sol"; /** * @dev Collection of functions related to array types. */ library Arrays { using StorageSlot for bytes32; /** * @dev Searches a sorted `array` and returns the first index that contains * a value greater or equal to `element`. If no such index exists (i.e. all * values in the array are strictly less than `element`), the array length is * returned. Time complexity O(log n). * * `array` is expected to be sorted in ascending order, and to contain no * repeated elements. */ function findUpperBound(uint256[] storage array, uint256 element) internal view returns (uint256) { uint256 low = 0; uint256 high = array.length; if (high == 0) { return 0; } while (low < high) { uint256 mid = Math.average(low, high); // Note that mid will always be strictly less than high (i.e. it will be a valid array index) // because Math.average rounds towards zero (it does integer division with truncation). if (unsafeAccess(array, mid).value > element) { high = mid; } else { low = mid + 1; } } // At this point `low` is the exclusive upper bound. We will return the inclusive upper bound. if (low > 0 && unsafeAccess(array, low - 1).value == element) { return low - 1; } else { return low; } } /** * @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check. * * WARNING: Only use if you are certain `pos` is lower than the array length. */ function unsafeAccess(address[] storage arr, uint256 pos) internal pure returns (StorageSlot.AddressSlot storage) { bytes32 slot; // We use assembly to calculate the storage slot of the element at index `pos` of the dynamic array `arr` // following https://docs.soliditylang.org/en/v0.8.20/internals/layout_in_storage.html#mappings-and-dynamic-arrays. /// @solidity memory-safe-assembly assembly { mstore(0, arr.slot) slot := add(keccak256(0, 0x20), pos) } return slot.getAddressSlot(); } /** * @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check. * * WARNING: Only use if you are certain `pos` is lower than the array length. */ function unsafeAccess(bytes32[] storage arr, uint256 pos) internal pure returns (StorageSlot.Bytes32Slot storage) { bytes32 slot; // We use assembly to calculate the storage slot of the element at index `pos` of the dynamic array `arr` // following https://docs.soliditylang.org/en/v0.8.20/internals/layout_in_storage.html#mappings-and-dynamic-arrays. /// @solidity memory-safe-assembly assembly { mstore(0, arr.slot) slot := add(keccak256(0, 0x20), pos) } return slot.getBytes32Slot(); } /** * @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check. * * WARNING: Only use if you are certain `pos` is lower than the array length. */ function unsafeAccess(uint256[] storage arr, uint256 pos) internal pure returns (StorageSlot.Uint256Slot storage) { bytes32 slot; // We use assembly to calculate the storage slot of the element at index `pos` of the dynamic array `arr` // following https://docs.soliditylang.org/en/v0.8.20/internals/layout_in_storage.html#mappings-and-dynamic-arrays. /// @solidity memory-safe-assembly assembly { mstore(0, arr.slot) slot := add(keccak256(0, 0x20), pos) } return slot.getUint256Slot(); } /** * @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check. * * WARNING: Only use if you are certain `pos` is lower than the array length. */ function unsafeMemoryAccess(uint256[] memory arr, uint256 pos) internal pure returns (uint256 res) { assembly { res := mload(add(add(arr, 0x20), mul(pos, 0x20))) } } /** * @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check. * * WARNING: Only use if you are certain `pos` is lower than the array length. */ function unsafeMemoryAccess(address[] memory arr, uint256 pos) internal pure returns (address res) { assembly { res := mload(add(add(arr, 0x20), mul(pos, 0x20))) } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol) pragma solidity ^0.8.20; /** * @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; } function _contextSuffixLength() internal view virtual returns (uint256) { return 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/ECDSA.sol) pragma solidity ^0.8.20; /** * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations. * * These functions can be used to verify that a message was signed by the holder * of the private keys of a given address. */ library ECDSA { enum RecoverError { NoError, InvalidSignature, InvalidSignatureLength, InvalidSignatureS } /** * @dev The signature derives the `address(0)`. */ error ECDSAInvalidSignature(); /** * @dev The signature has an invalid length. */ error ECDSAInvalidSignatureLength(uint256 length); /** * @dev The signature has an S value that is in the upper half order. */ error ECDSAInvalidSignatureS(bytes32 s); /** * @dev Returns the address that signed a hashed message (`hash`) with `signature` or an error. This will not * return address(0) without also returning an error description. Errors are documented using an enum (error type) * and a bytes32 providing additional information about the error. * * If no error is returned, then the address can be used for verification purposes. * * The `ecrecover` EVM precompile allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it. * * Documentation for signature generation: * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js] * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers] */ function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError, bytes32) { if (signature.length == 65) { bytes32 r; bytes32 s; uint8 v; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. /// @solidity memory-safe-assembly assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } return tryRecover(hash, v, r, s); } else { return (address(0), RecoverError.InvalidSignatureLength, bytes32(signature.length)); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature`. This address can then be used for verification purposes. * * The `ecrecover` EVM precompile allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it. */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, signature); _throwError(error, errorArg); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately. * * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures] */ function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError, bytes32) { unchecked { bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff); // We do not check for an overflow here since the shift operation results in 0 or 1. uint8 v = uint8((uint256(vs) >> 255) + 27); return tryRecover(hash, v, r, s); } } /** * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately. */ function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) { (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, r, vs); _throwError(error, errorArg); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `v`, * `r` and `s` signature fields separately. */ function tryRecover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address, RecoverError, bytes32) { // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most // signatures from current libraries generate a unique signature with an s-value in the lower half order. // // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept // these malleable signatures as well. if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { return (address(0), RecoverError.InvalidSignatureS, s); } // If the signature is valid (and not malleable), return the signer address address signer = ecrecover(hash, v, r, s); if (signer == address(0)) { return (address(0), RecoverError.InvalidSignature, bytes32(0)); } return (signer, RecoverError.NoError, bytes32(0)); } /** * @dev Overload of {ECDSA-recover} that receives the `v`, * `r` and `s` signature fields separately. */ function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) { (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, v, r, s); _throwError(error, errorArg); return recovered; } /** * @dev Optionally reverts with the corresponding custom error according to the `error` argument provided. */ function _throwError(RecoverError error, bytes32 errorArg) private pure { if (error == RecoverError.NoError) { return; // no error: do nothing } else if (error == RecoverError.InvalidSignature) { revert ECDSAInvalidSignature(); } else if (error == RecoverError.InvalidSignatureLength) { revert ECDSAInvalidSignatureLength(uint256(errorArg)); } else if (error == RecoverError.InvalidSignatureS) { revert ECDSAInvalidSignatureS(errorArg); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/MessageHashUtils.sol) pragma solidity ^0.8.20; import {Strings} from "../Strings.sol"; /** * @dev Signature message hash utilities for producing digests to be consumed by {ECDSA} recovery or signing. * * The library provides methods for generating a hash of a message that conforms to the * https://eips.ethereum.org/EIPS/eip-191[EIP 191] and https://eips.ethereum.org/EIPS/eip-712[EIP 712] * specifications. */ library MessageHashUtils { /** * @dev Returns the keccak256 digest of an EIP-191 signed data with version * `0x45` (`personal_sign` messages). * * The digest is calculated by prefixing a bytes32 `messageHash` with * `"\x19Ethereum Signed Message:\n32"` and hashing the result. It corresponds with the * hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method. * * NOTE: The `messageHash` parameter is intended to be the result of hashing a raw message with * keccak256, although any bytes32 value can be safely used because the final digest will * be re-hashed. * * See {ECDSA-recover}. */ function toEthSignedMessageHash(bytes32 messageHash) internal pure returns (bytes32 digest) { /// @solidity memory-safe-assembly assembly { mstore(0x00, "\x19Ethereum Signed Message:\n32") // 32 is the bytes-length of messageHash mstore(0x1c, messageHash) // 0x1c (28) is the length of the prefix digest := keccak256(0x00, 0x3c) // 0x3c is the length of the prefix (0x1c) + messageHash (0x20) } } /** * @dev Returns the keccak256 digest of an EIP-191 signed data with version * `0x45` (`personal_sign` messages). * * The digest is calculated by prefixing an arbitrary `message` with * `"\x19Ethereum Signed Message:\n" + len(message)` and hashing the result. It corresponds with the * hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method. * * See {ECDSA-recover}. */ function toEthSignedMessageHash(bytes memory message) internal pure returns (bytes32) { return keccak256(bytes.concat("\x19Ethereum Signed Message:\n", bytes(Strings.toString(message.length)), message)); } /** * @dev Returns the keccak256 digest of an EIP-191 signed data with version * `0x00` (data with intended validator). * * The digest is calculated by prefixing an arbitrary `data` with `"\x19\x00"` and the intended * `validator` address. Then hashing the result. * * See {ECDSA-recover}. */ function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) { return keccak256(abi.encodePacked(hex"19_00", validator, data)); } /** * @dev Returns the keccak256 digest of an EIP-712 typed data (EIP-191 version `0x01`). * * The digest is calculated from a `domainSeparator` and a `structHash`, by prefixing them with * `\x19\x01` and hashing the result. It corresponds to the hash signed by the * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] JSON-RPC method as part of EIP-712. * * See {ECDSA-recover}. */ function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 digest) { /// @solidity memory-safe-assembly assembly { let ptr := mload(0x40) mstore(ptr, hex"19_01") mstore(add(ptr, 0x02), domainSeparator) mstore(add(ptr, 0x22), structHash) digest := keccak256(ptr, 0x42) } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol) pragma solidity ^0.8.20; import {IERC165} from "./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); * } * ``` */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) { return interfaceId == type(IERC165).interfaceId; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol) pragma solidity ^0.8.20; /** * @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); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol) pragma solidity ^0.8.20; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { /** * @dev Muldiv operation overflow. */ error MathOverflowedMulDiv(); enum Rounding { Floor, // Toward negative infinity Ceil, // Toward positive infinity Trunc, // Toward zero Expand // Away from zero } /** * @dev Returns the addition of two unsigned integers, with an overflow flag. */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the subtraction of two unsigned integers, with an overflow flag. */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @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 towards infinity instead * of rounding towards zero. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { if (b == 0) { // Guarantee the same behavior as in a regular Solidity division. return a / b; } // (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 = x * y; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) 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. if (denominator <= prod1) { revert MathOverflowedMulDiv(); } /////////////////////////////////////////////// // 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. uint256 twos = denominator & (0 - denominator); 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 (unsignedRoundsUp(rounding) && 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 * towards zero. * * 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 + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2 of a positive value rounded towards zero. * 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 + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10 of a positive value rounded towards zero. * 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 + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0); } } /** * @dev Return the log in base 256 of a positive value rounded towards zero. * 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 + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0); } } /** * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers. */ function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) { return uint8(rounding) % 2 == 1; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SignedMath.sol) pragma solidity ^0.8.20; /** * @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); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/ReentrancyGuard.sol) pragma solidity ^0.8.20; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant NOT_ENTERED = 1; uint256 private constant ENTERED = 2; uint256 private _status; /** * @dev Unauthorized reentrant call. */ error ReentrancyGuardReentrantCall(); constructor() { _status = NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { _nonReentrantBefore(); _; _nonReentrantAfter(); } function _nonReentrantBefore() private { // On the first call to nonReentrant, _status will be NOT_ENTERED if (_status == ENTERED) { revert ReentrancyGuardReentrantCall(); } // Any calls to nonReentrant after this point will fail _status = ENTERED; } function _nonReentrantAfter() private { // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = NOT_ENTERED; } /** * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a * `nonReentrant` function in the call stack. */ function _reentrancyGuardEntered() internal view returns (bool) { return _status == ENTERED; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/StorageSlot.sol) // This file was procedurally generated from scripts/generate/templates/StorageSlot.js. pragma solidity ^0.8.20; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ```solidity * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(newImplementation.code.length > 0); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } struct StringSlot { string value; } struct BytesSlot { bytes value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `StringSlot` with member `value` located at `slot`. */ function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `StringSlot` representation of the string storage pointer `store`. */ function getStringSlot(string storage store) internal pure returns (StringSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := store.slot } } /** * @dev Returns an `BytesSlot` with member `value` located at `slot`. */ function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`. */ function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := store.slot } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/Strings.sol) pragma solidity ^0.8.20; import {Math} from "./math/Math.sol"; import {SignedMath} from "./math/SignedMath.sol"; /** * @dev String operations. */ library Strings { bytes16 private constant HEX_DIGITS = "0123456789abcdef"; uint8 private constant ADDRESS_LENGTH = 20; /** * @dev The `value` string doesn't fit in the specified `length`. */ error StringsInsufficientHexLength(uint256 value, uint256 length); /** * @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), HEX_DIGITS)) } value /= 10; if (value == 0) break; } return buffer; } } /** * @dev Converts a `int256` to its ASCII `string` decimal representation. */ function toStringSigned(int256 value) internal pure returns (string memory) { return string.concat(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) { uint256 localValue = value; 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] = HEX_DIGITS[localValue & 0xf]; localValue >>= 4; } if (localValue != 0) { revert StringsInsufficientHexLength(value, length); } 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 bytes(a).length == bytes(b).length && keccak256(bytes(a)) == keccak256(bytes(b)); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import '@openzeppelin/contracts/utils/introspection/ERC165.sol'; interface IERC2981Royalties { function royaltyInfo( uint256 _tokenId, uint256 _value ) external view returns (address _receiver, uint256 _royaltyAmount); } /// @dev This is a contract used to add ERC2981 support to ERC721 and 1155 abstract contract ERC2981Base is ERC165, IERC2981Royalties { struct RoyaltyInfo { address recipient; uint24 amount; } /// @inheritdoc ERC165 function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC2981Royalties).interfaceId || super.supportsInterface(interfaceId); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import '@openzeppelin/contracts/token/ERC1155/ERC1155.sol'; import '@openzeppelin/contracts/access/AccessControl.sol'; import '@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Burnable.sol'; import '@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Supply.sol'; import './ERC2981Base.sol'; import './libs/SafeMath.sol'; import './libs/SignedSafeMath.sol'; import './interfaces/IBlast.sol'; // import 'hardhat/console.sol'; contract Gangster is ERC1155, AccessControl, ERC1155Burnable, ERC1155Supply, ERC2981Base { using SafeMath for uint256; using SignedSafeMath for int256; IBlast public constant BLAST = IBlast(0x4300000000000000000000000000000000000002); bytes32 public constant URI_SETTER_ROLE = keccak256('URI_SETTER_ROLE'); bytes32 public constant MINTER_ROLE = keccak256('MINTER_ROLE'); RoyaltyInfo private _royalties; address private gasFeeOperator_; string public name = 'Gangster'; string public symbol = 'Gangster'; constructor(address defaultAdmin, address minter) ERC1155('') { _grantRole(DEFAULT_ADMIN_ROLE, defaultAdmin); _grantRole(URI_SETTER_ROLE, defaultAdmin); _grantRole(MINTER_ROLE, defaultAdmin); _grantRole(MINTER_ROLE, minter); BLAST.configureClaimableGas(); } /** * Claim gas */ function claimGas(bool _maxOnly) public onlyRole(DEFAULT_ADMIN_ROLE) { require(gasFeeOperator_ != address(0), 'gasFee is not set'); if (_maxOnly) { BLAST.claimMaxGas(address(this), gasFeeOperator_); } else { BLAST.claimAllGas(address(this), gasFeeOperator_); } } function setURI(string memory newuri) public onlyRole(URI_SETTER_ROLE) { _setURI(newuri); } /** * set GasFeeOperator */ function setGasFeeOperator(address _gasFeeOperator) public onlyRole(DEFAULT_ADMIN_ROLE) { gasFeeOperator_ = _gasFeeOperator; } /** * @notice Pre-sale buy gangster */ function mint(address account, uint256 id, uint256 amount, bytes memory data) public onlyRole(MINTER_ROLE) { _mint(account, id, amount, data); } /** * @dev See {IERC1155-setApprovalForAll}. */ function approvalForWithdraw(address operator, bool approved) public onlyRole(DEFAULT_ADMIN_ROLE) { _setApprovalForAll(address(this), operator, approved); } // The following functions are overrides required by Solidity. function _update( address from, address to, uint256[] memory ids, uint256[] memory values ) internal override(ERC1155, ERC1155Supply) { super._update(from, to, ids, values); } // Value is in basis points so 10000 = 100% , 100 = 1% etc function setRoyalties(address recipient, uint256 value) external onlyRole(DEFAULT_ADMIN_ROLE) { require(value <= 10000, 'ERC2981Royalties: Too high'); _royalties = RoyaltyInfo(recipient, uint24(value)); } function royaltyInfo( uint256, uint256 value ) external view override returns (address receiver, uint256 royaltyAmount) { RoyaltyInfo memory royalties = _royalties; receiver = royalties.recipient; royaltyAmount = (value * royalties.amount) / 10000; } function supportsInterface( bytes4 interfaceId ) public view virtual override(ERC1155, AccessControl, ERC2981Base) returns (bool) { return super.supportsInterface(interfaceId); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; // import '@openzeppelin/contracts/token/ERC20/ERC20.sol'; // import '@openzeppelin/contracts/token/ERC20/IERC20.sol'; // import '@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol'; // import '@openzeppelin/contracts/access/AccessControl.sol'; // import '@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol'; // import '@openzeppelin/contracts/utils/ReentrancyGuard.sol'; import '@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol'; import '@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20BurnableUpgradeable.sol'; import '@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol'; import '@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20PermitUpgradeable.sol'; import '@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol'; import '@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol'; import '@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol'; // import '@openzeppelin/contracts/access/Ownable.sol'; import './libs/SafeMath.sol'; import './libs/SafeTransferLib.sol'; import './interfaces/IUniswapV2Factory.sol'; import './interfaces/IUniswapV2Pair.sol'; import './interfaces/IUniswapV2Router02.sol'; import './IGangsterArena.sol'; import './interfaces/IBlast.sol'; // import 'hardhat/console.sol'; contract GREED is Initializable, ERC20Upgradeable, ERC20BurnableUpgradeable, AccessControlUpgradeable, ERC20PermitUpgradeable, UUPSUpgradeable, ReentrancyGuardUpgradeable { using SafeMath for uint256; using SafeTransferLib for address payable; IBlast public constant BLAST = IBlast(0x4300000000000000000000000000000000000002); address private gasFeeOperator_; bytes32 public constant MINTER_ROLE = keccak256('MINTER_ROLE'); bytes32 public constant UPGRADER_ROLE = keccak256('UPGRADER_ROLE'); IUniswapV2Router02 public uniswapV2Router; address public uniswapV2Pair; IGangsterArena public gangsterArena; address public _defaultAdmin; // swap everytime this contract hold more than 1k fiat uint256 public swapTokensAtAmount; uint256 public totalFees; // 5_00 = 5% uint256 public prizeFee; // 2_50 = 2.5% uint256 public liquidityFee; // 1_00 = 1% uint256 public devFee; // 1_50 = 1.5% uint256 public burnFee; // 0% uint256 public tokensForRevShare; uint256 public tokensForLiquidity; uint256 public tokensForTeam; uint256 public percentOfRankPrize; // 60_00= 60% /******************/ mapping(address => bool) private _isExcludedFromFees; event ExcludeFromFees(address indexed account, bool isExcluded); event SwapAndLiquify(uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiquidity); /// @custom:oz-upgrades-unsafe-allow constructor constructor() { _disableInitializers(); } function initialize(address defaultAdmin, address minter, address upgrader) public initializer { __ERC20_init('GREED', 'GREED'); __ERC20Burnable_init(); __AccessControl_init(); __ERC20Permit_init('GREED'); __UUPSUpgradeable_init(); _grantRole(DEFAULT_ADMIN_ROLE, defaultAdmin); _grantRole(MINTER_ROLE, minter); _grantRole(UPGRADER_ROLE, upgrader); _defaultAdmin = defaultAdmin; excludeFromFees(address(0), true); excludeFromFees(address(this), true); excludeFromFees(_defaultAdmin, true); // BLAST.configureClaimableGas(); // Init configuration swapTokensAtAmount = 1000 * 1e18; totalFees = 5_00; // 5% prizeFee = 2_50; // 2.5% liquidityFee = 1_00; // 1% devFee = 1_50; // 1.5% burnFee = 0; // 0% percentOfRankPrize = 50_00; //50% } receive() external payable {} /** *************************** * UPGRADER_ROLE *************************** */ function _authorizeUpgrade(address newImplementation) internal override onlyRole(UPGRADER_ROLE) {} /** *************************** * Public *************************** */ /** * Claim gas */ function claimGas(bool _maxOnly) public onlyRole(DEFAULT_ADMIN_ROLE) { require(gasFeeOperator_ != address(0), 'gasFee is not set'); if (_maxOnly) { BLAST.claimMaxGas(address(this), gasFeeOperator_); } else { BLAST.claimAllGas(address(this), gasFeeOperator_); } } /** *************************** * DEFAULT_ADMIN_ROLE *************************** */ function mint(address to, uint256 amount) public onlyRole(MINTER_ROLE) { _mint(to, amount); } function batchMint(address[] calldata receivers, uint256[] calldata amounts) public onlyRole(MINTER_ROLE) { require(receivers.length == amounts.length); for (uint256 i = 0; i < receivers.length; i++) { _mint(receivers[i], amounts[i]); } } /** *************************** * Customization for the contract (ADMIN_ROLE) *************************** */ /** * set GasFeeOperator */ function setGasFeeOperator(address _gasFeeOperator) public onlyRole(DEFAULT_ADMIN_ROLE) { gasFeeOperator_ = _gasFeeOperator; } function manualSwapBack() public onlyRole(DEFAULT_ADMIN_ROLE) { swapBack(); } function updateUniswapAddresses( address _uniswapV2Pair, address _uniswapV2Router ) public onlyRole(DEFAULT_ADMIN_ROLE) { uniswapV2Pair = _uniswapV2Pair; uniswapV2Router = IUniswapV2Router02(_uniswapV2Router); } function updateGangsterArenaAddress(address _address) public onlyRole(DEFAULT_ADMIN_ROLE) { gangsterArena = IGangsterArena(_address); } function updateSwapTokensAtAmount(uint256 newAmount) public onlyRole(DEFAULT_ADMIN_ROLE) { swapTokensAtAmount = newAmount; } function updateFees( uint256 _prizeFee, uint256 _liquidityFee, uint256 _devFee, uint256 _burnFee, uint256 _percentOfRankPrize ) external onlyRole(DEFAULT_ADMIN_ROLE) { require(_prizeFee + _liquidityFee + _devFee + _burnFee <= 10000, 'Fees must be <= 10000.'); require(_percentOfRankPrize <= 10000, 'percen must be <= 10000.'); prizeFee = _prizeFee; liquidityFee = _liquidityFee; devFee = _devFee; burnFee = _burnFee; totalFees = _prizeFee + _liquidityFee + _devFee + _burnFee; percentOfRankPrize = _percentOfRankPrize; } function excludeFromFees(address account, bool excluded) public onlyRole(DEFAULT_ADMIN_ROLE) { _isExcludedFromFees[account] = excluded; emit ExcludeFromFees(account, excluded); } function isExcludedFromFees(address account) public view returns (bool) { return _isExcludedFromFees[account]; } function withdrawStuckToken() external onlyRole(DEFAULT_ADMIN_ROLE) { uint256 balance = IERC20(address(this)).balanceOf(address(this)); IERC20(address(this)).transfer(msg.sender, balance); payable(msg.sender).transfer(address(this).balance); } function withdrawStuckEth(address toAddr) external onlyRole(DEFAULT_ADMIN_ROLE) { payable(toAddr).safeTransferETH(address(this).balance); } /** *************************** Private *************************** */ function _update(address from, address to, uint256 amount) internal override { if (amount == 0) return; bool isBuy = from == uniswapV2Pair; bool isSell = to == uniswapV2Pair; // only take fees on buys/sells, do not take on wallet transfers bool takeFee = !_isExcludedFromFees[from] && !_isExcludedFromFees[to] && (isSell || isBuy); uint256 fees = 0; uint256 contractTokenBalance = balanceOf(address(this)); bool canSwap = contractTokenBalance >= swapTokensAtAmount; if (canSwap && isSell && !_isExcludedFromFees[from] && !_isExcludedFromFees[to]) { swapBack(); } if (takeFee) { fees = amount.mul(totalFees).div(10000); tokensForLiquidity += (fees * liquidityFee) / totalFees; tokensForTeam += (fees * devFee) / totalFees; tokensForRevShare += (fees * prizeFee) / totalFees; uint256 tokensForBurn = (fees * burnFee) / totalFees; amount -= fees; if (fees > 0) { if (tokensForBurn > 0) super._update(from, address(0), tokensForBurn); super._update(from, address(this), fees - tokensForBurn); } } super._update(from, to, amount); } function swapTokensForEth(uint256 tokenAmount) private { // generate the uniswap pair path of token -> weth address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); // make the swap uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), block.timestamp ); } function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { // approve token transfer to cover all possible scenarios _approve(address(this), address(uniswapV2Router), tokenAmount); // add the liquidity uniswapV2Router.addLiquidityETH{value: ethAmount}( address(this), tokenAmount, 0, // slippage is unavoidable 0, // slippage is unavoidable _defaultAdmin, block.timestamp ); } function swapBack() internal nonReentrant { uint256 contractBalance = balanceOf(address(this)); uint256 totalTokensToSwap = tokensForLiquidity + tokensForRevShare + tokensForTeam; if (contractBalance == 0 || totalTokensToSwap == 0) { return; } uint256 liquidityTokens = (contractBalance.mul(tokensForLiquidity)).div(totalTokensToSwap); uint256 addLPAmount = liquidityTokens.div(2); uint256 amountTokenForTeam = (contractBalance * tokensForTeam) / totalTokensToSwap; uint256 amountToSwapForETH = contractBalance.sub(addLPAmount); uint256 initialETHBalance = address(this).balance; swapTokensForEth(amountToSwapForETH); uint256 ethBalance = address(this).balance.sub(initialETHBalance); uint256 ethForTeam = ethBalance.mul(amountTokenForTeam).div(amountToSwapForETH); uint256 ethForLiquidity = ethBalance.mul(addLPAmount).div(amountToSwapForETH); uint256 ethForRevShare = ethBalance - ethForTeam - ethForLiquidity; uint256 ethForRankPrize = (ethForRevShare * percentOfRankPrize) / 10000; if (addLPAmount > 0 && ethForLiquidity > 0) { addLiquidity(addLPAmount, ethForLiquidity); // console.log(liquidityTokens, ethForLiquidity); emit SwapAndLiquify(amountToSwapForETH, ethForLiquidity, tokensForLiquidity); } tokensForLiquidity = 0; tokensForRevShare = 0; tokensForTeam = 0; gangsterArena.addReward{value: ethForTeam + ethForRevShare}( ethForTeam, ethForRankPrize, ethForRevShare - ethForRankPrize ); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; interface IGangsterArena { /** *************************** Event *************************** */ event Received(address, uint); event AddReward(address, uint); event BuyGangster(address indexed to, uint256 tokenId, uint256 amount, uint256 nonce); event BuyGoon(address indexed to, uint256 amount, uint256 nonce); event BuySafeHouse(address indexed to, uint256 amount, uint256 nonce); event DailySpin(address indexed to, uint256 spinType, uint256 amount, uint256 value, uint256 nonce); event Deposit(address indexed to, uint256 tokenId, uint256 amount); event Withdraw(address indexed to, uint256 tokenId, uint256 amount); event Burn(address[] to, uint256[] tokenId, uint256[] amount); event BurnGoon(address[] to, uint256[] amount); event Retire(address to, uint256 reward, uint256 nonce); event WarResult(address[] addr, uint256[] _lGang); event JoinCrew(address to, uint256 _nonce); /** *************************** Function *************************** */ /** * public send reward from ourside to contract (ex: from LP) * */ function addReward(uint256 devValue, uint256 rankPrize, uint256 reputationPrize) external payable; /** * Buy Gangster as NFT */ // function buyGangster( // uint256 amount, // uint256 value, // uint256 time, // uint256 nGangster, // uint256 nonce, // uint256 bType, // bytes memory sig // ) external; /** * Buy game asset (Goon/Safehouse) */ function buyAsset( uint256 _typeA, uint256 _amount, uint256 _value, uint256 _lastB, uint256 _sTime, uint256 _nonce, bytes memory _sig ) external; /** * Deposit NFT to game */ function depositNFT(address to, uint256 amount) external; /** * Withdraw NFT from game */ function withdrawNFT(address to, uint256 amount) external; /** * War result pay out */ function finalWarResult(address[] memory addr, uint256[] memory _lGang) external; /** * Winner pay out */ function setWinner(address[] memory to, uint256[] memory _ethReward, uint256[] memory _tokenReward) external; }
// SPDX-License-Identifier: MIT pragma solidity 0.8.20; enum YieldMode { AUTOMATIC, VOID, CLAIMABLE } enum GasMode { VOID, CLAIMABLE } interface IBlast { // configure function configureContract(address contractAddress, YieldMode _yield, GasMode gasMode, address governor) external; function configure(YieldMode _yield, GasMode gasMode, address governor) external; // base configuration options function configureClaimableYield() external; function configureClaimableYieldOnBehalf(address contractAddress) external; function configureAutomaticYield() external; function configureAutomaticYieldOnBehalf(address contractAddress) external; function configureVoidYield() external; function configureVoidYieldOnBehalf(address contractAddress) external; function configureClaimableGas() external; function configureClaimableGasOnBehalf(address contractAddress) external; function configureVoidGas() external; function configureVoidGasOnBehalf(address contractAddress) external; function configureGovernor(address _governor) external; function configureGovernorOnBehalf(address _newGovernor, address contractAddress) external; // claim yield function claimYield(address contractAddress, address recipientOfYield, uint256 amount) external returns (uint256); function claimAllYield(address contractAddress, address recipientOfYield) external returns (uint256); // claim gas function claimAllGas(address contractAddress, address recipientOfGas) external returns (uint256); function claimGasAtMinClaimRate( address contractAddress, address recipientOfGas, uint256 minClaimRateBips ) external returns (uint256); function claimMaxGas(address contractAddress, address recipientOfGas) external returns (uint256); function claimGas( address contractAddress, address recipientOfGas, uint256 gasToClaim, uint256 gasSecondsToConsume ) external returns (uint256); // read functions function readClaimableYield(address contractAddress) external view returns (uint256); function readYieldConfiguration(address contractAddress) external view returns (uint8); function readGasParams( address contractAddress ) external view returns (uint256 etherSeconds, uint256 etherBalance, uint256 lastUpdated, GasMode); } interface IBlastPoints { function configurePointsOperator(address operator) external; function configurePointsOperatorOnBehalf(address contractAddress, address operator) external; }
// SPDX-License-Identifier: MIT pragma solidity 0.8.20; interface IUniswapV2Factory { event PairCreated(address indexed token0, address indexed token1, address pair, uint256); function feeTo() external view returns (address); function feeToSetter() external view returns (address); function getPair(address tokenA, address tokenB) external view returns (address pair); function allPairs(uint256) external view returns (address pair); function allPairsLength() external view returns (uint256); function createPair(address tokenA, address tokenB) external returns (address pair); function setFeeTo(address) external; function setFeeToSetter(address) external; }
// SPDX-License-Identifier: MIT pragma solidity 0.8.20; interface IUniswapV2Pair { event Approval(address indexed owner, address indexed spender, uint256 value); event Transfer(address indexed from, address indexed to, uint256 value); function name() external pure returns (string memory); function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint256); function balanceOf(address owner) external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 value) external returns (bool); function transfer(address to, uint256 value) external returns (bool); function transferFrom(address from, address to, uint256 value) external returns (bool); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address owner) external view returns (uint256); function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; event Mint(address indexed sender, uint256 amount0, uint256 amount1); event Burn(address indexed sender, uint256 amount0, uint256 amount1, address indexed to); event Swap( address indexed sender, uint256 amount0In, uint256 amount1In, uint256 amount0Out, uint256 amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); function MINIMUM_LIQUIDITY() external pure returns (uint256); function factory() external view returns (address); function token0() external view returns (address); function token1() external view returns (address); function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast); function price0CumulativeLast() external view returns (uint256); function price1CumulativeLast() external view returns (uint256); function kLast() external view returns (uint256); function mint(address to) external returns (uint256 liquidity); function burn(address to) external returns (uint256 amount0, uint256 amount1); function swap(uint256 amount0Out, uint256 amount1Out, address to, bytes calldata data) external; function skim(address to) external; function sync() external; function initialize(address, address) external; }
// SPDX-License-Identifier: MIT pragma solidity 0.8.20; interface IUniswapV2Router02 { function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidity( address tokenA, address tokenB, uint256 amountADesired, uint256 amountBDesired, uint256 amountAMin, uint256 amountBMin, address to, uint256 deadline ) external returns (uint256 amountA, uint256 amountB, uint256 liquidity); function addLiquidityETH( address token, uint256 amountTokenDesired, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline ) external payable returns (uint256 amountToken, uint256 amountETH, uint256 liquidity); function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external; function swapExactETHForTokensSupportingFeeOnTransferTokens( uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external payable; function swapExactTokensForETHSupportingFeeOnTransferTokens( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/math/SafeMath.sol) pragma solidity ^0.8.0; // CAUTION // This version of SafeMath should only be used with Solidity 0.8 or later, // because it relies on the compiler's built in overflow checks. /** * @dev Wrappers over Solidity's arithmetic operations. * * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler * now has built in overflow checking. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the subtraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { return a + b; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { return a * b; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b <= a, errorMessage); return a - b; } } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a / b; } } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a % b; } } }
// SPDX-License-Identifier: AGPL-3.0-only pragma solidity >=0.8.0; import {ERC20} from '@openzeppelin/contracts/token/ERC20/ERC20.sol'; /// @notice Safe ETH and ERC20 transfer library that gracefully handles missing return values. /// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/SafeTransferLib.sol) /// @dev Use with caution! Some functions in this library knowingly create dirty bits at the destination of the free memory pointer. /// @dev Note that none of the functions in this library check that a token has code at all! That responsibility is delegated to the caller. library SafeTransferLib { /*////////////////////////////////////////////////////////////// ETH OPERATIONS //////////////////////////////////////////////////////////////*/ function safeTransferETH(address to, uint256 amount) internal { bool success; /// @solidity memory-safe-assembly assembly { // Transfer the ETH and store if it succeeded or not. success := call(gas(), to, amount, 0, 0, 0, 0) } require(success, 'ETH_TRANSFER_FAILED'); } /*////////////////////////////////////////////////////////////// ERC20 OPERATIONS //////////////////////////////////////////////////////////////*/ function safeTransferFrom(ERC20 token, address from, address to, uint256 amount) internal { bool success; /// @solidity memory-safe-assembly assembly { // Get a pointer to some free memory. let freeMemoryPointer := mload(0x40) // Write the abi-encoded calldata into memory, beginning with the function selector. mstore(freeMemoryPointer, 0x23b872dd00000000000000000000000000000000000000000000000000000000) mstore(add(freeMemoryPointer, 4), and(from, 0xffffffffffffffffffffffffffffffffffffffff)) // Append and mask the "from" argument. mstore(add(freeMemoryPointer, 36), and(to, 0xffffffffffffffffffffffffffffffffffffffff)) // Append and mask the "to" argument. mstore(add(freeMemoryPointer, 68), amount) // Append the "amount" argument. Masking not required as it's a full 32 byte type. success := and( // Set success to whether the call reverted, if not we check it either // returned exactly 1 (can't just be non-zero data), or had no return data. or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())), // We use 100 because the length of our calldata totals up like so: 4 + 32 * 3. // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space. // Counterintuitively, this call must be positioned second to the or() call in the // surrounding and() call or else returndatasize() will be zero during the computation. call(gas(), token, 0, freeMemoryPointer, 100, 0, 32) ) } require(success, 'TRANSFER_FROM_FAILED'); } function safeTransfer(ERC20 token, address to, uint256 amount) internal { bool success; /// @solidity memory-safe-assembly assembly { // Get a pointer to some free memory. let freeMemoryPointer := mload(0x40) // Write the abi-encoded calldata into memory, beginning with the function selector. mstore(freeMemoryPointer, 0xa9059cbb00000000000000000000000000000000000000000000000000000000) mstore(add(freeMemoryPointer, 4), and(to, 0xffffffffffffffffffffffffffffffffffffffff)) // Append and mask the "to" argument. mstore(add(freeMemoryPointer, 36), amount) // Append the "amount" argument. Masking not required as it's a full 32 byte type. success := and( // Set success to whether the call reverted, if not we check it either // returned exactly 1 (can't just be non-zero data), or had no return data. or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())), // We use 68 because the length of our calldata totals up like so: 4 + 32 * 2. // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space. // Counterintuitively, this call must be positioned second to the or() call in the // surrounding and() call or else returndatasize() will be zero during the computation. call(gas(), token, 0, freeMemoryPointer, 68, 0, 32) ) } require(success, 'TRANSFER_FAILED'); } function safeApprove(ERC20 token, address to, uint256 amount) internal { bool success; /// @solidity memory-safe-assembly assembly { // Get a pointer to some free memory. let freeMemoryPointer := mload(0x40) // Write the abi-encoded calldata into memory, beginning with the function selector. mstore(freeMemoryPointer, 0x095ea7b300000000000000000000000000000000000000000000000000000000) mstore(add(freeMemoryPointer, 4), and(to, 0xffffffffffffffffffffffffffffffffffffffff)) // Append and mask the "to" argument. mstore(add(freeMemoryPointer, 36), amount) // Append the "amount" argument. Masking not required as it's a full 32 byte type. success := and( // Set success to whether the call reverted, if not we check it either // returned exactly 1 (can't just be non-zero data), or had no return data. or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())), // We use 68 because the length of our calldata totals up like so: 4 + 32 * 2. // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space. // Counterintuitively, this call must be positioned second to the or() call in the // surrounding and() call or else returndatasize() will be zero during the computation. call(gas(), token, 0, freeMemoryPointer, 68, 0, 32) ) } require(success, 'APPROVE_FAILED'); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; library SignedSafeMath { int256 private constant _INT256_MIN = -2 ** 255; /** * @dev Returns the multiplication of two signed integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(int256 a, int256 b) internal pure returns (int256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } require(!(a == -1 && b == _INT256_MIN), 'SignedSafeMath: multiplication overflow'); int256 c = a * b; require(c / a == b, 'SignedSafeMath: multiplication overflow'); return c; } /** * @dev Returns the integer division of two signed integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(int256 a, int256 b) internal pure returns (int256) { require(b != 0, 'SignedSafeMath: division by zero'); require(!(b == -1 && a == _INT256_MIN), 'SignedSafeMath: division overflow'); int256 c = a / b; return c; } /** * @dev Returns the subtraction of two signed integers, reverting on * overflow. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(int256 a, int256 b) internal pure returns (int256) { int256 c = a - b; require((b >= 0 && c <= a) || (b < 0 && c > a), 'SignedSafeMath: subtraction overflow'); return c; } /** * @dev Returns the addition of two signed integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(int256 a, int256 b) internal pure returns (int256) { int256 c = a + b; require((b >= 0 && c >= a) || (b < 0 && c < a), 'SignedSafeMath: addition overflow'); return c; } function toUInt256(int256 a) internal pure returns (uint256) { require(a >= 0, 'Integer < 0'); return uint256(a); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; library SignerLib { /** *************************** Internal Function *************************** */ /** * @notice Verify signature */ function verifyAddressSigner(address signer, bytes32 message, bytes memory sig) internal pure returns (bool) { return signer == recoverSignerFromSignature(message, sig); } //function to get the public address of the signer function recoverSignerFromSignature(bytes32 message, bytes memory sig) internal pure returns (address) { require(sig.length == 65); uint8 v; bytes32 r; bytes32 s; assembly { // first 32 bytes, after the length prefix r := mload(add(sig, 32)) // second 32 bytes s := mload(add(sig, 64)) // final byte (first byte of the next 32 bytes) v := byte(0, mload(add(sig, 96))) } return ecrecover(message, v, r, s); } // Builds a prefixed hash to mimic the behavior of eth_sign. function prefixed(bytes32 _hashedMessage) internal pure returns (bytes32) { bytes memory prefix = '\x19Ethereum Signed Message:\n32'; bytes32 prefixedHashMessage = keccak256(abi.encodePacked(prefix, _hashedMessage)); return prefixedHashMessage; } }
{ "evmVersion": "paris", "optimizer": { "enabled": false, "runs": 200 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"address","name":"_defaultAdmin","type":"address"},{"internalType":"address","name":"_adminAddress","type":"address"},{"internalType":"address","name":"_workerAddress","type":"address"},{"internalType":"address","name":"_signerAddress","type":"address"},{"internalType":"address","name":"_gangsterAddress","type":"address"},{"internalType":"address payable","name":"_fiatAddress","type":"address"},{"internalType":"address","name":"_pointsOperator","type":"address"},{"internalType":"address","name":"_blastPointAddr","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AccessControlBadConfirmation","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes32","name":"neededRole","type":"bytes32"}],"name":"AccessControlUnauthorizedAccount","type":"error"},{"inputs":[],"name":"ReentrancyGuardReentrantCall","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"","type":"address"},{"indexed":false,"internalType":"uint256","name":"","type":"uint256"}],"name":"AddReward","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address[]","name":"to","type":"address[]"},{"indexed":false,"internalType":"uint256[]","name":"tokenId","type":"uint256[]"},{"indexed":false,"internalType":"uint256[]","name":"amount","type":"uint256[]"}],"name":"Burn","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address[]","name":"to","type":"address[]"},{"indexed":false,"internalType":"uint256[]","name":"amount","type":"uint256[]"}],"name":"BurnGoon","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"nonce","type":"uint256"}],"name":"BuyGangster","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"nonce","type":"uint256"}],"name":"BuyGoon","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"nonce","type":"uint256"}],"name":"BuySafeHouse","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"spinType","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"nonce","type":"uint256"}],"name":"DailySpin","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Deposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"_nonce","type":"uint256"}],"name":"JoinCrew","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"","type":"address"},{"indexed":false,"internalType":"uint256","name":"","type":"uint256"}],"name":"Received","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"reward","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"nonce","type":"uint256"}],"name":"Retire","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address[]","name":"addr","type":"address[]"},{"indexed":false,"internalType":"uint256[]","name":"_lGang","type":"uint256[]"}],"name":"WarResult","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Withdraw","type":"event"},{"stateMutability":"payable","type":"fallback"},{"inputs":[],"name":"ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"BLAST","outputs":[{"internalType":"contract IBlast","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_PER_BATCH","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"WORKER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_dev","type":"uint256"},{"internalType":"uint256","name":"_reputationPrize_","type":"uint256"},{"internalType":"uint256","name":"_rankPrize_","type":"uint256"}],"name":"addReward","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"addTokenReward","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"burnRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_typeA","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"uint256","name":"_value","type":"uint256"},{"internalType":"uint256","name":"_lastB","type":"uint256"},{"internalType":"uint256","name":"_sTime","type":"uint256"},{"internalType":"uint256","name":"_nonce","type":"uint256"},{"internalType":"bytes","name":"_sig","type":"bytes"}],"name":"buyAsset","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"claimAllYield","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_maxOnly","type":"bool"}],"name":"claimGas","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"communityRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"communityTreasury_","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"depositNFT","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"devAddr_","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"emegencyWithdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"ethPrize","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ethRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"_addr","type":"address[]"},{"internalType":"uint256[]","name":"_lGang","type":"uint256[]"}],"name":"finalWarResult","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"gameClosed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"gangster","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"gangsterBought","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"gasFeeOperator_","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"greedToken","outputs":[{"internalType":"contract GREED","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"lastB","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lockNFT","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nft","outputs":[{"internalType":"contract Gangster","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"address","name":"from","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"onERC1155Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_value","type":"uint256"},{"internalType":"uint256","name":"_sTime","type":"uint256"},{"internalType":"uint256","name":"_nonce","type":"uint256"},{"internalType":"bytes","name":"_sig","type":"bytes"}],"name":"pickCrew","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"pointsOperator_","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"prizeRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"callerConfirmation","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_devAddr","type":"address"},{"internalType":"address","name":"_gasFeeOperator","type":"address"},{"internalType":"address","name":"_communityTreasury","type":"address"},{"internalType":"address","name":"_spinPool","type":"address"},{"internalType":"address","name":"_uniswapV2Router","type":"address"}],"name":"setGameAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_value","type":"bool"}],"name":"setGameClosed","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_vtd","type":"uint256"},{"internalType":"uint256","name":"_tokenSwapLimit","type":"uint256"},{"internalType":"uint256","name":"_burnRate","type":"uint256"},{"internalType":"uint256","name":"_communityRate","type":"uint256"},{"internalType":"uint256","name":"_prizeRate","type":"uint256"}],"name":"setGameConfig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_lock","type":"bool"}],"name":"setLockNFT","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_to","type":"address[]"},{"internalType":"uint256[]","name":"_ethReward","type":"uint256[]"},{"internalType":"uint256[]","name":"_tokenReward","type":"uint256[]"}],"name":"setWinner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_spinType","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"uint256","name":"_value","type":"uint256"},{"internalType":"uint256","name":"_sTime","type":"uint256"},{"internalType":"uint256","name":"_nonce","type":"uint256"},{"internalType":"bytes","name":"_sig","type":"bytes"}],"name":"spin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"spinPoolAddr_","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountOutMin","type":"uint256"}],"name":"swapTokensForEth","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"tokenForLP","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tokenId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tokenPrize","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tokenSwapLimit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"uniswapV2Router","outputs":[{"internalType":"contract IUniswapV2Router02","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"vtd","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdrawNFT","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]
Contract Creation Code
6101006040526101f460035569010f0cf064dd592000006004556107d06005556107d0600655610bb8600755610bb8600855603c6009553480156200004357600080fd5b5060405162006504380380620065048339818101604052810190620000699190620005c0565b600180819055508373ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff16815250508273ffffffffffffffffffffffffffffffffffffffff1660a08173ffffffffffffffffffffffffffffffffffffffff16815250508473ffffffffffffffffffffffffffffffffffffffff1660c08173ffffffffffffffffffffffffffffffffffffffff16815250508173ffffffffffffffffffffffffffffffffffffffff1660e08173ffffffffffffffffffffffffffffffffffffffff168152505087600f60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550620001966000801b896200039c60201b60201c565b50620001c97fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c21775886200039c60201b60201c565b50620001fc7ff1b411d6abb365480ac902cc153c45e9ded5847a2265ce6d01945d253edb6bc7876200039c60201b60201c565b50600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16146200038e578073ffffffffffffffffffffffffffffffffffffffff166336b91f2b836040518263ffffffff1660e01b81526004016200026d91906200069a565b600060405180830381600087803b1580156200028857600080fd5b505af11580156200029d573d6000803e3d6000fd5b5050505073430000000000000000000000000000000000000273ffffffffffffffffffffffffffffffffffffffff16634e606c476040518163ffffffff1660e01b8152600401600060405180830381600087803b158015620002fe57600080fd5b505af115801562000313573d6000803e3d6000fd5b5050505073430000000000000000000000000000000000000273ffffffffffffffffffffffffffffffffffffffff1663f098767a6040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156200037457600080fd5b505af115801562000389573d6000803e3d6000fd5b505050505b5050505050505050620006b7565b6000620003b083836200049f60201b60201c565b6200049457600160008085815260200190815260200160002060000160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550620004306200050960201b60201c565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16847f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a46001905062000499565b600090505b92915050565b600080600084815260200190815260200160002060000160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b600033905090565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000620005438262000516565b9050919050565b620005558162000536565b81146200056157600080fd5b50565b60008151905062000575816200054a565b92915050565b6000620005888262000516565b9050919050565b6200059a816200057b565b8114620005a657600080fd5b50565b600081519050620005ba816200058f565b92915050565b600080600080600080600080610100898b031215620005e457620005e362000511565b5b6000620005f48b828c0162000564565b9850506020620006078b828c0162000564565b97505060406200061a8b828c0162000564565b96505060606200062d8b828c0162000564565b9550506080620006408b828c0162000564565b94505060a0620006538b828c01620005a9565b93505060c0620006668b828c0162000564565b92505060e0620006798b828c0162000564565b9150509295985092959890939650565b620006948162000536565b82525050565b6000602082019050620006b1600083018462000689565b92915050565b60805160a05160c05160e051615d8e62000776600039600061285a015260008181611859015281816126640152613021015260008181610d6f015281816115a6015281816119db01528181611ab701528181611b4c0152818161212901528181612332015281816124450152818161271501528181612e06015281816130d20152818161323d01528181613392015261374a015260008181611267015281816114d601528181611e6f01528181612aa50152613c390152615d8e6000f3fe6080604052600436106103035760003560e01c806391d1485411610190578063bed99850116100dc578063d547741f11610095578063f23a6e611161006f578063f23a6e6114610bd3578063f72fc7cb14610c10578063fcd2117d14610c3b578063fdbefb5914610c665761035c565b8063d547741f14610b42578063e84f331114610b6b578063ede6ec5d14610b965761035c565b8063bed9985014610a40578063bee2660914610a6b578063c020b08c14610a96578063c0be0c0b14610ac1578063c45df0e414610aec578063d2d93f9014610b175761035c565b8063a217fddf11610149578063ad85e3bd11610123578063ad85e3bd14610998578063b28805f4146109c3578063b943cbbb146109ec578063bc90c27314610a155761035c565b8063a217fddf1461091b578063aa837e7114610946578063ad01a5d01461096f5761035c565b806391d148541461081f57806397d757761461085c57806398795ee6146108875780639b5b9b181461089e5780639f872950146108c75780639fc0db56146108f25761035c565b80634c57207d1161024f5780636d99ef461161020857806375b238fc116101e257806375b238fc146107635780638af02ab11461078e5780638b899b46146107b757806390824c5b146107f45761035c565b80636d99ef46146106e45780636e3e40d91461070f57806373a582231461073a5761035c565b80634c57207d146105ea5780635b262a7714610613578063601746931461063c5780636088e93a1461066757806362af569314610690578063634252dc146106b95761035c565b80632f2ff15d116102bc578063409a33ce11610296578063409a33ce1461056157806341a21bcf1461057857806346816290146105a357806347ccca02146105bf5761035c565b80632f2ff15d146104e657806336568abe1461050f578063368b28bd146105385761035c565b806301ffc9a7146103b05780631694505e146103ed57806317d70f7c14610418578063248a9ca3146104435780632614160e146104805780632841a143146104bd5761035c565b3661035c5734600a600082825461031a9190613e32565b925050819055507f88a5966d370b9919b20f3e2c13ff65706f196a4e32cc2c12bf57088f885258743334604051610352929190613eb6565b60405180910390a1005b34600a600082825461036e9190613e32565b925050819055507f88a5966d370b9919b20f3e2c13ff65706f196a4e32cc2c12bf57088f8852587433346040516103a6929190613eb6565b60405180910390a1005b3480156103bc57600080fd5b506103d760048036038101906103d29190613f4b565b610c91565b6040516103e49190613f93565b60405180910390f35b3480156103f957600080fd5b50610402610d0b565b60405161040f919061400d565b60405180910390f35b34801561042457600080fd5b5061042d610d31565b60405161043a9190614028565b60405180910390f35b34801561044f57600080fd5b5061046a60048036038101906104659190614079565b610d36565b60405161047791906140b5565b60405180910390f35b34801561048c57600080fd5b506104a760048036038101906104a291906140fc565b610d55565b6040516104b49190614028565b60405180910390f35b3480156104c957600080fd5b506104e460048036038101906104df9190614155565b610d6d565b005b3480156104f257600080fd5b5061050d60048036038101906105089190614182565b610e2a565b005b34801561051b57600080fd5b5061053660048036038101906105319190614182565b610e4c565b005b34801561054457600080fd5b5061055f600480360381019061055a91906141ee565b610ec7565b005b34801561056d57600080fd5b50610576610f0f565b005b34801561058457600080fd5b5061058d610ff1565b60405161059a9190614028565b60405180910390f35b6105bd60048036038101906105b8919061421b565b610ff7565b005b3480156105cb57600080fd5b506105d4611265565b6040516105e1919061428f565b60405180910390f35b3480156105f657600080fd5b50610611600480360381019061060c91906144c6565b611289565b005b34801561061f57600080fd5b5061063a600480360381019061063591906145f3565b6115a3565b005b34801561064857600080fd5b50610651611d3f565b60405161065e9190614028565b60405180910390f35b34801561067357600080fd5b5061068e600480360381019061068991906146b1565b611d45565b005b34801561069c57600080fd5b506106b760048036038101906106b291906141ee565b611f54565b005b3480156106c557600080fd5b506106ce611f9c565b6040516106db91906140b5565b60405180910390f35b3480156106f057600080fd5b506106f9611fc0565b6040516107069190613f93565b60405180910390f35b34801561071b57600080fd5b50610724611fd3565b6040516107319190614028565b60405180910390f35b34801561074657600080fd5b50610761600480360381019061075c91906146f1565b611fd9565b005b34801561076f57600080fd5b5061077861241e565b60405161078591906140b5565b60405180910390f35b34801561079a57600080fd5b506107b560048036038101906107b09190614798565b612442565b005b3480156107c357600080fd5b506107de60048036038101906107d991906146b1565b612833565b6040516107eb9190614028565b60405180910390f35b34801561080057600080fd5b50610809612858565b6040516108169190614841565b60405180910390f35b34801561082b57600080fd5b5061084660048036038101906108419190614182565b61287c565b6040516108539190613f93565b60405180910390f35b34801561086857600080fd5b506108716128e6565b60405161087e919061487d565b60405180910390f35b34801561089357600080fd5b5061089c6128fe565b005b3480156108aa57600080fd5b506108c560048036038101906108c091906146b1565b612a53565b005b3480156108d357600080fd5b506108dc612be0565b6040516108e99190614841565b60405180910390f35b3480156108fe57600080fd5b5061091960048036038101906109149190614898565b612c06565b005b34801561092757600080fd5b50610930612d7d565b60405161093d91906140b5565b60405180910390f35b34801561095257600080fd5b5061096d60048036038101906109689190614913565b612d84565b005b34801561097b57600080fd5b506109966004803603810190610991919061498e565b612e03565b005b3480156109a457600080fd5b506109ad61319d565b6040516109ba9190614841565b60405180910390f35b3480156109cf57600080fd5b506109ea60048036038101906109e59190614155565b6131c3565b005b3480156109f857600080fd5b50610a136004803603810190610a0e91906141ee565b6134f4565b005b348015610a2157600080fd5b50610a2a613729565b604051610a379190614028565b60405180910390f35b348015610a4c57600080fd5b50610a5561372f565b604051610a629190614028565b60405180910390f35b348015610a7757600080fd5b50610a80613735565b604051610a8d9190613f93565b60405180910390f35b348015610aa257600080fd5b50610aab613748565b604051610ab89190614a44565b60405180910390f35b348015610acd57600080fd5b50610ad661376c565b604051610ae39190614028565b60405180910390f35b348015610af857600080fd5b50610b01613772565b604051610b0e9190614028565b60405180910390f35b348015610b2357600080fd5b50610b2c613778565b604051610b399190614028565b60405180910390f35b348015610b4e57600080fd5b50610b696004803603810190610b649190614182565b61377e565b005b348015610b7757600080fd5b50610b806137a0565b604051610b8d9190614841565b60405180910390f35b348015610ba257600080fd5b50610bbd6004803603810190610bb891906140fc565b6137c6565b604051610bca9190614028565b60405180910390f35b348015610bdf57600080fd5b50610bfa6004803603810190610bf59190614aba565b6137de565b604051610c079190614b63565b60405180910390f35b348015610c1c57600080fd5b50610c2561380d565b604051610c329190614028565b60405180910390f35b348015610c4757600080fd5b50610c50613813565b604051610c5d9190614841565b60405180910390f35b348015610c7257600080fd5b50610c7b613839565b604051610c889190614028565b60405180910390f35b60007f7965db0b000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480610d045750610d038261383f565b5b9050919050565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600181565b6000806000838152602001908152602001600020600101549050919050565b60126020528060005260406000206000915090505481565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166323b872dd3330846040518463ffffffff1660e01b8152600401610dca93929190614b7e565b6020604051808303816000875af1158015610de9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e0d9190614bca565b5080600b6000828254610e209190613e32565b9250508190555050565b610e3382610d36565b610e3c816138a9565b610e4683836138bd565b50505050565b610e546139ae565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610eb8576040517f6697b23200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610ec282826139b6565b505050565b7ff1b411d6abb365480ac902cc153c45e9ded5847a2265ce6d01945d253edb6bc7610ef1816138a9565b81601060146101000a81548160ff0219169083151502179055505050565b7fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c21775610f39816138a9565b73430000000000000000000000000000000000000273ffffffffffffffffffffffffffffffffffffffff1663860043b630600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040518363ffffffff1660e01b8152600401610faa929190614bf7565b6020604051808303816000875af1158015610fc9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fed9190614c35565b5050565b60095481565b60008183856110069190613e32565b6110109190613e32565b905080341015611055576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161104c90614cbf565b60405180910390fd5b82826110619190613e32565b600a60008282546110729190613e32565b925050819055506000841115611158576000600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905060008173ffffffffffffffffffffffffffffffffffffffff16866040516110cf90614d10565b60006040518083038185875af1925050503d806000811461110c576040519150601f19603f3d011682016040523d82523d6000602084013e611111565b606091505b5050905080611155576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161114c90614d71565b60405180910390fd5b50505b600081346111669190614d91565b9050600081111561122557600033905060008173ffffffffffffffffffffffffffffffffffffffff168360405161119c90614d10565b60006040518083038185875af1925050503d80600081146111d9576040519150601f19603f3d011682016040523d82523d6000602084013e6111de565b606091505b5050905080611222576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161121990614d71565b60405180910390fd5b50505b7f9f15a78649bd76613c4a49ca8a67ae948862a0eee791ca3d0380853f9afa624f3383604051611256929190613eb6565b60405180910390a15050505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b7ff1b411d6abb365480ac902cc153c45e9ded5847a2265ce6d01945d253edb6bc76112b3816138a9565b601060149054906101000a900460ff1615611303576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112fa90614e11565b60405180910390fd5b8151835114611347576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161133e90614e7d565b60405180910390fd5b60005b835181101561141c5782818151811061136657611365614e9d565b5b60200260200101516014600086848151811061138557611384614e9d565b5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015611409576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161140090614f18565b60405180910390fd5b808061141490614f38565b91505061134a565b50600061142883613aa8565b905060005b84518110156114d35783818151811061144957611448614e9d565b5b60200260200101516014600087848151811061146857611467614e9d565b5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546114b99190614d91565b9250508190555080806114cb90614f38565b91505061142d565b507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663f5298aca306001846040518463ffffffff1660e01b815260040161153293929190614f80565b600060405180830381600087803b15801561154c57600080fd5b505af1158015611560573d6000803e3d6000fd5b505050507f5ba5896aa4cc7b0ad558b01a8632c8d8a65dd5dee5394b2c2b78c3ddc5f326538484604051611595929190615133565b60405180910390a150505050565b847f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663dd62ed3e33306040518363ffffffff1660e01b81526004016115ff929190614bf7565b602060405180830381865afa15801561161c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116409190614c35565b1015611681576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611678906151b6565b60405180910390fd5b601060149054906101000a900460ff16156116d1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116c890614e11565b60405180910390fd5b83601160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008981526020019081526020016000205414611763576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161175a90615222565b60405180910390fd5b600954836117719190613e32565b42106117b2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016117a99061528e565b60405180910390fd5b6013600083815260200190815260200160002060009054906101000a900460ff1615611813576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161180a906152fa565b60405180910390fd5b6000611850338989898989896040516020016118359796959493929190615383565b60405160208183030381529060405280519060200120613afa565b905061189d81837f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16613b6c9092919063ffffffff16565b6118dc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118d390615450565b60405180910390fd5b60016013600085815260200190815260200160002060006101000a81548160ff02191690831515021790555042601160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a8152602001908152602001600020819055506000612710600554886119709190615470565b61197a91906154e1565b905060006127106006548961198f9190615470565b61199991906154e1565b905060006127106008548a6119ae9190615470565b6119b891906154e1565b905060006127106007548b6119cd9190615470565b6119d791906154e1565b90507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166323b872dd33308d6040518463ffffffff1660e01b8152600401611a3693929190614b7e565b6020604051808303816000875af1158015611a55573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a799190614bca565b5081600c6000828254611a8c9190613e32565b9250508190555080600b6000828254611aa59190613e32565b925050819055506000841115611b41577f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166342966c68856040518263ffffffff1660e01b8152600401611b0e9190614028565b600060405180830381600087803b158015611b2857600080fd5b505af1158015611b3c573d6000803e3d6000fd5b505050505b6000831115611c0c577f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663a9059cbb600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16856040518363ffffffff1660e01b8152600401611bc7929190613eb6565b6020604051808303816000875af1158015611be6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c0a9190614bca565b505b60008c148015611c1c575060008b115b15611c7f57611c2b338c613baf565b3373ffffffffffffffffffffffffffffffffffffffff167fcf1d432606e0ee6a23fc32ce701ac36c9897204278c35ac9d65112344b20991760018d8a604051611c7693929190615512565b60405180910390a25b60018c03611cd8573373ffffffffffffffffffffffffffffffffffffffff167f759647c6e0ef64ba58a247443390ca1ca127a0e56c0ca73b8e7adb81cdea686f8c89604051611ccf929190615549565b60405180910390a25b60028c03611d31573373ffffffffffffffffffffffffffffffffffffffff167f064c6c90fdf69cdb269f2989d2db58656f9f0975deb0a85bc6c3e85ce03849368c89604051611d28929190615549565b60405180910390a25b505050505050505050505050565b600c5481565b601060159054906101000a900460ff1615611d95576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d8c906155be565b60405180910390fd5b80601460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015611e17576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e0e9061562a565b60405180910390fd5b80601460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611e669190614d91565b925050819055507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663f242432a30846001856040518563ffffffff1660e01b8152600401611ecd949392919061567e565b600060405180830381600087803b158015611ee757600080fd5b505af1158015611efb573d6000803e3d6000fd5b505050503373ffffffffffffffffffffffffffffffffffffffff167ff279e6a1f5e320cca91135676d9cb6e44ca8a08c0b88342bcdb1144f6511b568600183604051611f48929190615549565b60405180910390a25050565b7ff1b411d6abb365480ac902cc153c45e9ded5847a2265ce6d01945d253edb6bc7611f7e816138a9565b81601060156101000a81548160ff0219169083151502179055505050565b7ff1b411d6abb365480ac902cc153c45e9ded5847a2265ce6d01945d253edb6bc781565b601060149054906101000a900460ff1681565b600a5481565b7ff1b411d6abb365480ac902cc153c45e9ded5847a2265ce6d01945d253edb6bc7612003816138a9565b601060149054906101000a900460ff16612052576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161204990615722565b60405180910390fd5b82518451148015612064575081518351145b6120a3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161209a9061578e565b60405180910390fd5b60005b8451811015612417578381815181106120c2576120c1614e9d565b5b602002602001015147101561210c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612103906157fa565b60405180910390fd5b82818151811061211f5761211e614e9d565b5b60200260200101517f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016121809190614841565b602060405180830381865afa15801561219d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121c19190614c35565b1015612202576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016121f990615866565b60405180910390fd5b600084828151811061221757612216614e9d565b5b6020026020010151111561230d57600085828151811061223a57612239614e9d565b5b6020026020010151905060008173ffffffffffffffffffffffffffffffffffffffff168684815181106122705761226f614e9d565b5b602002602001015160405161228490614d10565b60006040518083038185875af1925050503d80600081146122c1576040519150601f19603f3d011682016040523d82523d6000602084013e6122c6565b606091505b505090508061230a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161230190614d71565b60405180910390fd5b50505b600083828151811061232257612321614e9d565b5b60200260200101511115612404577f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663a9059cbb86838151811061237f5761237e614e9d565b5b602002602001015185848151811061239a57612399614e9d565b5b60200260200101516040518363ffffffff1660e01b81526004016123bf929190613eb6565b6020604051808303816000875af11580156123de573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124029190614bca565b505b808061240f90614f38565b9150506120a6565b5050505050565b7fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c2177581565b837f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663dd62ed3e33306040518363ffffffff1660e01b815260040161249e929190614bf7565b602060405180830381865afa1580156124bb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124df9190614c35565b1015612520576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612517906151b6565b60405180910390fd5b601060149054906101000a900460ff1615612570576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161256790614e11565b60405180910390fd5b6009548361257e9190613e32565b42106125bf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016125b69061528e565b60405180910390fd5b6013600083815260200190815260200160002060009054906101000a900460ff1615612620576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612617906152fa565b60405180910390fd5b600061265b33888888888860405160200161264096959493929190615886565b60405160208183030381529060405280519060200120613afa565b90506126a881837f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16613b6c9092919063ffffffff16565b6126e7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016126de90615450565b60405180910390fd5b60016013600085815260200190815260200160002060006101000a81548160ff0219169083151502179055507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166323b872dd33601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16886040518463ffffffff1660e01b815260040161279293929190614b7e565b6020604051808303816000875af11580156127b1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127d59190614bca565b503373ffffffffffffffffffffffffffffffffffffffff167f13f135658b67258df1952b1efe89331bc59bde07499073b16d5f4908012dce5b8888888760405161282294939291906158f6565b60405180910390a250505050505050565b6011602052816000526040600020602052806000526040600020600091509150505481565b7f000000000000000000000000000000000000000000000000000000000000000081565b600080600084815260200190815260200160002060000160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b73430000000000000000000000000000000000000281565b6000801b61290b816138a9565b601060149054906101000a900460ff1661295a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161295190615722565b60405180910390fd5b6000471161299d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161299490615987565b60405180910390fd5b600033905060008173ffffffffffffffffffffffffffffffffffffffff16476040516129c890614d10565b60006040518083038185875af1925050503d8060008114612a05576040519150601f19603f3d011682016040523d82523d6000602084013e612a0a565b606091505b5050905080612a4e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612a4590614d71565b60405180910390fd5b505050565b601060149054906101000a900460ff1615612aa3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612a9a90614e11565b60405180910390fd5b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663f242432a33306001856040518563ffffffff1660e01b8152600401612b03949392919061567e565b600060405180830381600087803b158015612b1d57600080fd5b505af1158015612b31573d6000803e3d6000fd5b5050505080601460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254612b849190613e32565b925050819055508173ffffffffffffffffffffffffffffffffffffffff167f90890809c654f11d6e72a28fa60149770a0d11ec6c92319d6ceb2bb0a4ea1a15600183604051612bd4929190615549565b60405180910390a25050565b601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b7fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c21775612c30816138a9565b85600d60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555084600e60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555083600f60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555082601060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555081600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550505050505050565b6000801b81565b7fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c21775612dae816138a9565b8560098190555084600481905550836005819055508260068190555081600781905550818385612710612de19190614d91565b612deb9190614d91565b612df59190614d91565b600881905550505050505050565b837f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663dd62ed3e33306040518363ffffffff1660e01b8152600401612e5f929190614bf7565b602060405180830381865afa158015612e7c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ea09190614c35565b1015612ee1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612ed8906151b6565b60405180910390fd5b601060149054906101000a900460ff1615612f31576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612f2890614e11565b60405180910390fd5b60095483612f3f9190613e32565b4210612f80576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612f779061528e565b60405180910390fd5b6013600083815260200190815260200160002060009054906101000a900460ff1615612fe1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612fd8906152fa565b60405180910390fd5b600061301833868686604051602001612ffd94939291906159a7565b60405160208183030381529060405280519060200120613afa565b905061306581837f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16613b6c9092919063ffffffff16565b6130a4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161309b90615450565b60405180910390fd5b60016013600085815260200190815260200160002060006101000a81548160ff0219169083151502179055507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166379cc679033876040518363ffffffff1660e01b815260040161312b929190613eb6565b600060405180830381600087803b15801561314557600080fd5b505af1158015613159573d6000803e3d6000fd5b505050507f87408b749fe68cfca13b466a5ff4b8f019fbbebe8cbb3b62ee9055ae415318ae338460405161318e929190613eb6565b60405180910390a15050505050565b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b7ff1b411d6abb365480ac902cc153c45e9ded5847a2265ce6d01945d253edb6bc76131ed816138a9565b6000600267ffffffffffffffff81111561320a576132096142c0565b5b6040519080825280602002602001820160405280156132385781602001602082028036833780820191505090505b5090507f0000000000000000000000000000000000000000000000000000000000000000816000815181106132705761326f614e9d565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa158015613317573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061333b9190615a0a565b8160018151811061334f5761334e614e9d565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250506000600c5490507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663095ea7b3600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836040518363ffffffff1660e01b815260040161340d929190613eb6565b6020604051808303816000875af115801561342c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134509190614bca565b506000600c81905550600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663791ac94782868530426040518663ffffffff1660e01b81526004016134bc959493929190615a37565b600060405180830381600087803b1580156134d657600080fd5b505af11580156134ea573d6000803e3d6000fd5b5050505050505050565b7fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c2177561351e816138a9565b600073ffffffffffffffffffffffffffffffffffffffff16600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16036135af576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016135a690615add565b60405180910390fd5b811561366f5773430000000000000000000000000000000000000273ffffffffffffffffffffffffffffffffffffffff1663662aa11d30600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040518363ffffffff1660e01b8152600401613626929190614bf7565b6020604051808303816000875af1158015613645573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136699190614c35565b50613725565b73430000000000000000000000000000000000000273ffffffffffffffffffffffffffffffffffffffff1663954fa5ee30600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040518363ffffffff1660e01b81526004016136e0929190614bf7565b6020604051808303816000875af11580156136ff573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906137239190614c35565b505b5050565b60075481565b60055481565b601060159054906101000a900460ff1681565b7f000000000000000000000000000000000000000000000000000000000000000081565b600b5481565b60065481565b60085481565b61378782610d36565b613790816138a9565b61379a83836139b6565b50505050565b600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60146020528060005260406000206000915090505481565b60007ff23a6e612e1ff4830e658fe43f4e3cb4a5f8170bd5d9e69fb5d7a7fa9e4fdf9790509695505050505050565b60035481565b600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60045481565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b6138ba816138b56139ae565b613d21565b50565b60006138c9838361287c565b6139a357600160008085815260200190815260200160002060000160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506139406139ae565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16847f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a4600190506139a8565b600090505b92915050565b600033905090565b60006139c2838361287c565b15613a9d57600080600085815260200190815260200160002060000160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550613a3a6139ae565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16847ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a460019050613aa2565b600090505b92915050565b600080600090505b8251811015613af457828181518110613acc57613acb614e9d565b5b602002602001015182613adf9190613e32565b91508080613aec90614f38565b915050613ab0565b50919050565b6000806040518060400160405280601c81526020017f19457468657265756d205369676e6564204d6573736167653a0a333200000000815250905060008184604051602001613b4a929190615b84565b6040516020818303038152906040528051906020012090508092505050919050565b6000613b788383613d72565b73ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161490509392505050565b60008103613bf2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401613be990615bf8565b60405180910390fd5b600354811115613c37576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401613c2e90615c64565b60405180910390fd5b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663731133e9306001846040518463ffffffff1660e01b8152600401613c9593929190615c84565b600060405180830381600087803b158015613caf57600080fd5b505af1158015613cc3573d6000803e3d6000fd5b5050505080601460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254613d169190613e32565b925050819055505050565b613d2b828261287c565b613d6e5780826040517fe2517d3f000000000000000000000000000000000000000000000000000000008152600401613d65929190615cce565b60405180910390fd5b5050565b60006041825114613d8257600080fd5b60008060006020850151915060408501519050606085015160001a925060018684848460405160008152602001604052604051613dc29493929190615d13565b6020604051602081039080840390855afa158015613de4573d6000803e3d6000fd5b50505060206040510351935050505092915050565b6000819050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000613e3d82613df9565b9150613e4883613df9565b9250828201905080821115613e6057613e5f613e03565b5b92915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000613e9182613e66565b9050919050565b613ea181613e86565b82525050565b613eb081613df9565b82525050565b6000604082019050613ecb6000830185613e98565b613ed86020830184613ea7565b9392505050565b6000604051905090565b600080fd5b600080fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b613f2881613ef3565b8114613f3357600080fd5b50565b600081359050613f4581613f1f565b92915050565b600060208284031215613f6157613f60613ee9565b5b6000613f6f84828501613f36565b91505092915050565b60008115159050919050565b613f8d81613f78565b82525050565b6000602082019050613fa86000830184613f84565b92915050565b6000819050919050565b6000613fd3613fce613fc984613e66565b613fae565b613e66565b9050919050565b6000613fe582613fb8565b9050919050565b6000613ff782613fda565b9050919050565b61400781613fec565b82525050565b60006020820190506140226000830184613ffe565b92915050565b600060208201905061403d6000830184613ea7565b92915050565b6000819050919050565b61405681614043565b811461406157600080fd5b50565b6000813590506140738161404d565b92915050565b60006020828403121561408f5761408e613ee9565b5b600061409d84828501614064565b91505092915050565b6140af81614043565b82525050565b60006020820190506140ca60008301846140a6565b92915050565b6140d981613e86565b81146140e457600080fd5b50565b6000813590506140f6816140d0565b92915050565b60006020828403121561411257614111613ee9565b5b6000614120848285016140e7565b91505092915050565b61413281613df9565b811461413d57600080fd5b50565b60008135905061414f81614129565b92915050565b60006020828403121561416b5761416a613ee9565b5b600061417984828501614140565b91505092915050565b6000806040838503121561419957614198613ee9565b5b60006141a785828601614064565b92505060206141b8858286016140e7565b9150509250929050565b6141cb81613f78565b81146141d657600080fd5b50565b6000813590506141e8816141c2565b92915050565b60006020828403121561420457614203613ee9565b5b6000614212848285016141d9565b91505092915050565b60008060006060848603121561423457614233613ee9565b5b600061424286828701614140565b935050602061425386828701614140565b925050604061426486828701614140565b9150509250925092565b600061427982613fda565b9050919050565b6142898161426e565b82525050565b60006020820190506142a46000830184614280565b92915050565b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6142f8826142af565b810181811067ffffffffffffffff82111715614317576143166142c0565b5b80604052505050565b600061432a613edf565b905061433682826142ef565b919050565b600067ffffffffffffffff821115614356576143556142c0565b5b602082029050602081019050919050565b600080fd5b600061437f61437a8461433b565b614320565b905080838252602082019050602084028301858111156143a2576143a1614367565b5b835b818110156143cb57806143b788826140e7565b8452602084019350506020810190506143a4565b5050509392505050565b600082601f8301126143ea576143e96142aa565b5b81356143fa84826020860161436c565b91505092915050565b600067ffffffffffffffff82111561441e5761441d6142c0565b5b602082029050602081019050919050565b600061444261443d84614403565b614320565b9050808382526020820190506020840283018581111561446557614464614367565b5b835b8181101561448e578061447a8882614140565b845260208401935050602081019050614467565b5050509392505050565b600082601f8301126144ad576144ac6142aa565b5b81356144bd84826020860161442f565b91505092915050565b600080604083850312156144dd576144dc613ee9565b5b600083013567ffffffffffffffff8111156144fb576144fa613eee565b5b614507858286016143d5565b925050602083013567ffffffffffffffff81111561452857614527613eee565b5b61453485828601614498565b9150509250929050565b600080fd5b600067ffffffffffffffff82111561455e5761455d6142c0565b5b614567826142af565b9050602081019050919050565b82818337600083830152505050565b600061459661459184614543565b614320565b9050828152602081018484840111156145b2576145b161453e565b5b6145bd848285614574565b509392505050565b600082601f8301126145da576145d96142aa565b5b81356145ea848260208601614583565b91505092915050565b600080600080600080600060e0888a03121561461257614611613ee9565b5b60006146208a828b01614140565b97505060206146318a828b01614140565b96505060406146428a828b01614140565b95505060606146538a828b01614140565b94505060806146648a828b01614140565b93505060a06146758a828b01614140565b92505060c088013567ffffffffffffffff81111561469657614695613eee565b5b6146a28a828b016145c5565b91505092959891949750929550565b600080604083850312156146c8576146c7613ee9565b5b60006146d6858286016140e7565b92505060206146e785828601614140565b9150509250929050565b60008060006060848603121561470a57614709613ee9565b5b600084013567ffffffffffffffff81111561472857614727613eee565b5b614734868287016143d5565b935050602084013567ffffffffffffffff81111561475557614754613eee565b5b61476186828701614498565b925050604084013567ffffffffffffffff81111561478257614781613eee565b5b61478e86828701614498565b9150509250925092565b60008060008060008060c087890312156147b5576147b4613ee9565b5b60006147c389828a01614140565b96505060206147d489828a01614140565b95505060406147e589828a01614140565b94505060606147f689828a01614140565b935050608061480789828a01614140565b92505060a087013567ffffffffffffffff81111561482857614827613eee565b5b61483489828a016145c5565b9150509295509295509295565b60006020820190506148566000830184613e98565b92915050565b600061486782613fda565b9050919050565b6148778161485c565b82525050565b6000602082019050614892600083018461486e565b92915050565b600080600080600060a086880312156148b4576148b3613ee9565b5b60006148c2888289016140e7565b95505060206148d3888289016140e7565b94505060406148e4888289016140e7565b93505060606148f5888289016140e7565b9250506080614906888289016140e7565b9150509295509295909350565b600080600080600060a0868803121561492f5761492e613ee9565b5b600061493d88828901614140565b955050602061494e88828901614140565b945050604061495f88828901614140565b935050606061497088828901614140565b925050608061498188828901614140565b9150509295509295909350565b600080600080608085870312156149a8576149a7613ee9565b5b60006149b687828801614140565b94505060206149c787828801614140565b93505060406149d887828801614140565b925050606085013567ffffffffffffffff8111156149f9576149f8613eee565b5b614a05878288016145c5565b91505092959194509250565b6000614a1c82613fb8565b9050919050565b6000614a2e82614a11565b9050919050565b614a3e81614a23565b82525050565b6000602082019050614a596000830184614a35565b92915050565b600080fd5b60008083601f840112614a7a57614a796142aa565b5b8235905067ffffffffffffffff811115614a9757614a96614a5f565b5b602083019150836001820283011115614ab357614ab2614367565b5b9250929050565b60008060008060008060a08789031215614ad757614ad6613ee9565b5b6000614ae589828a016140e7565b9650506020614af689828a016140e7565b9550506040614b0789828a01614140565b9450506060614b1889828a01614140565b935050608087013567ffffffffffffffff811115614b3957614b38613eee565b5b614b4589828a01614a64565b92509250509295509295509295565b614b5d81613ef3565b82525050565b6000602082019050614b786000830184614b54565b92915050565b6000606082019050614b936000830186613e98565b614ba06020830185613e98565b614bad6040830184613ea7565b949350505050565b600081519050614bc4816141c2565b92915050565b600060208284031215614be057614bdf613ee9565b5b6000614bee84828501614bb5565b91505092915050565b6000604082019050614c0c6000830185613e98565b614c196020830184613e98565b9392505050565b600081519050614c2f81614129565b92915050565b600060208284031215614c4b57614c4a613ee9565b5b6000614c5984828501614c20565b91505092915050565b600082825260208201905092915050565b7f4e65656420746f2073656e64206d6f7265206574686572000000000000000000600082015250565b6000614ca9601783614c62565b9150614cb482614c73565b602082019050919050565b60006020820190508181036000830152614cd881614c9c565b9050919050565b600081905092915050565b50565b6000614cfa600083614cdf565b9150614d0582614cea565b600082019050919050565b6000614d1b82614ced565b9150819050919050565b7f4661696c656420746f2073656e64204574686572000000000000000000000000600082015250565b6000614d5b601483614c62565b9150614d6682614d25565b602082019050919050565b60006020820190508181036000830152614d8a81614d4e565b9050919050565b6000614d9c82613df9565b9150614da783613df9565b9250828203905081811115614dbf57614dbe613e03565b5b92915050565b7f47616d6520697320636c6f736564000000000000000000000000000000000000600082015250565b6000614dfb600e83614c62565b9150614e0682614dc5565b602082019050919050565b60006020820190508181036000830152614e2a81614dee565b9050919050565b7f496e707574206172726179206973206e6f74206d617463680000000000000000600082015250565b6000614e67601883614c62565b9150614e7282614e31565b602082019050919050565b60006020820190508181036000830152614e9681614e5a565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f496e76616c696420616d6f756e7420746f206275726e00000000000000000000600082015250565b6000614f02601683614c62565b9150614f0d82614ecc565b602082019050919050565b60006020820190508181036000830152614f3181614ef5565b9050919050565b6000614f4382613df9565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203614f7557614f74613e03565b5b600182019050919050565b6000606082019050614f956000830186613e98565b614fa26020830185613ea7565b614faf6040830184613ea7565b949350505050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b614fec81613e86565b82525050565b6000614ffe8383614fe3565b60208301905092915050565b6000602082019050919050565b600061502282614fb7565b61502c8185614fc2565b935061503783614fd3565b8060005b8381101561506857815161504f8882614ff2565b975061505a8361500a565b92505060018101905061503b565b5085935050505092915050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b6150aa81613df9565b82525050565b60006150bc83836150a1565b60208301905092915050565b6000602082019050919050565b60006150e082615075565b6150ea8185615080565b93506150f583615091565b8060005b8381101561512657815161510d88826150b0565b9750615118836150c8565b9250506001810190506150f9565b5085935050505092915050565b6000604082019050818103600083015261514d8185615017565b9050818103602083015261516181846150d5565b90509392505050565b7f4572726f72000000000000000000000000000000000000000000000000000000600082015250565b60006151a0600583614c62565b91506151ab8261516a565b602082019050919050565b600060208201905081810360008301526151cf81615193565b9050919050565b7f496e76616c6964206c617374206275792074696d650000000000000000000000600082015250565b600061520c601583614c62565b9150615217826151d6565b602082019050919050565b6000602082019050818103600083015261523b816151ff565b9050919050565b7f496e76616c69642074696d657374616d70000000000000000000000000000000600082015250565b6000615278601183614c62565b915061528382615242565b602082019050919050565b600060208201905081810360008301526152a78161526b565b9050919050565b7f4e6f6e6365206973207573656400000000000000000000000000000000000000600082015250565b60006152e4600d83614c62565b91506152ef826152ae565b602082019050919050565b60006020820190508181036000830152615313816152d7565b9050919050565b60008160601b9050919050565b60006153328261531a565b9050919050565b600061534482615327565b9050919050565b61535c61535782613e86565b615339565b82525050565b6000819050919050565b61537d61537882613df9565b615362565b82525050565b600061538f828a61534b565b60148201915061539f828961536c565b6020820191506153af828861536c565b6020820191506153bf828761536c565b6020820191506153cf828661536c565b6020820191506153df828561536c565b6020820191506153ef828461536c565b60208201915081905098975050505050505050565b7f496e76616c6964207369676e6174757265000000000000000000000000000000600082015250565b600061543a601183614c62565b915061544582615404565b602082019050919050565b600060208201905081810360008301526154698161542d565b9050919050565b600061547b82613df9565b915061548683613df9565b925082820261549481613df9565b915082820484148315176154ab576154aa613e03565b5b5092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b60006154ec82613df9565b91506154f783613df9565b925082615507576155066154b2565b5b828204905092915050565b60006060820190506155276000830186613ea7565b6155346020830185613ea7565b6155416040830184613ea7565b949350505050565b600060408201905061555e6000830185613ea7565b61556b6020830184613ea7565b9392505050565b7f4e4654206973206c6f636b656400000000000000000000000000000000000000600082015250565b60006155a8600d83614c62565b91506155b382615572565b602082019050919050565b600060208201905081810360008301526155d78161559b565b9050919050565b7f496e73756666696369656e742062616c616e6365000000000000000000000000600082015250565b6000615614601483614c62565b915061561f826155de565b602082019050919050565b6000602082019050818103600083015261564381615607565b9050919050565b600082825260208201905092915050565b600061566860008361564a565b915061567382614cea565b600082019050919050565b600060a0820190506156936000830187613e98565b6156a06020830186613e98565b6156ad6040830185613ea7565b6156ba6060830184613ea7565b81810360808301526156cb8161565b565b905095945050505050565b7f47616d65206973206e6f7420636c6f7365640000000000000000000000000000600082015250565b600061570c601283614c62565b9150615717826156d6565b602082019050919050565b6000602082019050818103600083015261573b816156ff565b9050919050565b7f496e76616c696420696e707574206172726179206c656e677468000000000000600082015250565b6000615778601a83614c62565b915061578382615742565b602082019050919050565b600060208201905081810360008301526157a78161576b565b9050919050565b7f4f766572206574682062616c616e636500000000000000000000000000000000600082015250565b60006157e4601083614c62565b91506157ef826157ae565b602082019050919050565b60006020820190508181036000830152615813816157d7565b9050919050565b7f4f76657220746f6b656e2062616c616e63650000000000000000000000000000600082015250565b6000615850601283614c62565b915061585b8261581a565b602082019050919050565b6000602082019050818103600083015261587f81615843565b9050919050565b6000615892828961534b565b6014820191506158a2828861536c565b6020820191506158b2828761536c565b6020820191506158c2828661536c565b6020820191506158d2828561536c565b6020820191506158e2828461536c565b602082019150819050979650505050505050565b600060808201905061590b6000830187613ea7565b6159186020830186613ea7565b6159256040830185613ea7565b6159326060830184613ea7565b95945050505050565b7f4e6f7468696e6720746f20776974686472617700000000000000000000000000600082015250565b6000615971601383614c62565b915061597c8261593b565b602082019050919050565b600060208201905081810360008301526159a081615964565b9050919050565b60006159b3828761534b565b6014820191506159c3828661536c565b6020820191506159d3828561536c565b6020820191506159e3828461536c565b60208201915081905095945050505050565b600081519050615a04816140d0565b92915050565b600060208284031215615a2057615a1f613ee9565b5b6000615a2e848285016159f5565b91505092915050565b600060a082019050615a4c6000830188613ea7565b615a596020830187613ea7565b8181036040830152615a6b8186615017565b9050615a7a6060830185613e98565b615a876080830184613ea7565b9695505050505050565b7f676173466565206973206e6f7420736574000000000000000000000000000000600082015250565b6000615ac7601183614c62565b9150615ad282615a91565b602082019050919050565b60006020820190508181036000830152615af681615aba565b9050919050565b600081519050919050565b60005b83811015615b26578082015181840152602081019050615b0b565b60008484015250505050565b6000615b3d82615afd565b615b478185614cdf565b9350615b57818560208601615b08565b80840191505092915050565b6000819050919050565b615b7e615b7982614043565b615b63565b82525050565b6000615b908285615b32565b9150615b9c8284615b6d565b6020820191508190509392505050565b7f496e76616c696420616d6f756e74000000000000000000000000000000000000600082015250565b6000615be2600e83614c62565b9150615bed82615bac565b602082019050919050565b60006020820190508181036000830152615c1181615bd5565b9050919050565b7f4d61782070657220626174636820726561636865640000000000000000000000600082015250565b6000615c4e601583614c62565b9150615c5982615c18565b602082019050919050565b60006020820190508181036000830152615c7d81615c41565b9050919050565b6000608082019050615c996000830186613e98565b615ca66020830185613ea7565b615cb36040830184613ea7565b8181036060830152615cc48161565b565b9050949350505050565b6000604082019050615ce36000830185613e98565b615cf060208301846140a6565b9392505050565b600060ff82169050919050565b615d0d81615cf7565b82525050565b6000608082019050615d2860008301876140a6565b615d356020830186615d04565b615d4260408301856140a6565b615d4f60608301846140a6565b9594505050505056fea2646970667358221220ba9369acc9f838a0bd40d5e9a55fe6587dabb2bd8af890b830cbd01dd2eec41b64736f6c63430008140033000000000000000000000000d65934f0e7d543d10b070ed1b3f62ca9b7e0c4c7000000000000000000000000d65934f0e7d543d10b070ed1b3f62ca9b7e0c4c7000000000000000000000000dc678248e99a5a7aee93342af067ea8bded520ec00000000000000000000000063a37fbd924c6d5e2c2a7fdfddbd079a0837c6750000000000000000000000007acbbdf5013b5ec148683246e65ed168ea507690000000000000000000000000e6a062fba3918376500a602c800b1e03074204570000000000000000000000009c910cb24ed6f9d248f1b3f1492ab887cdccc9730000000000000000000000002536fe9ab3f511540f2f9e2ec2a805005c3dd800
Deployed Bytecode
0x6080604052600436106103035760003560e01c806391d1485411610190578063bed99850116100dc578063d547741f11610095578063f23a6e611161006f578063f23a6e6114610bd3578063f72fc7cb14610c10578063fcd2117d14610c3b578063fdbefb5914610c665761035c565b8063d547741f14610b42578063e84f331114610b6b578063ede6ec5d14610b965761035c565b8063bed9985014610a40578063bee2660914610a6b578063c020b08c14610a96578063c0be0c0b14610ac1578063c45df0e414610aec578063d2d93f9014610b175761035c565b8063a217fddf11610149578063ad85e3bd11610123578063ad85e3bd14610998578063b28805f4146109c3578063b943cbbb146109ec578063bc90c27314610a155761035c565b8063a217fddf1461091b578063aa837e7114610946578063ad01a5d01461096f5761035c565b806391d148541461081f57806397d757761461085c57806398795ee6146108875780639b5b9b181461089e5780639f872950146108c75780639fc0db56146108f25761035c565b80634c57207d1161024f5780636d99ef461161020857806375b238fc116101e257806375b238fc146107635780638af02ab11461078e5780638b899b46146107b757806390824c5b146107f45761035c565b80636d99ef46146106e45780636e3e40d91461070f57806373a582231461073a5761035c565b80634c57207d146105ea5780635b262a7714610613578063601746931461063c5780636088e93a1461066757806362af569314610690578063634252dc146106b95761035c565b80632f2ff15d116102bc578063409a33ce11610296578063409a33ce1461056157806341a21bcf1461057857806346816290146105a357806347ccca02146105bf5761035c565b80632f2ff15d146104e657806336568abe1461050f578063368b28bd146105385761035c565b806301ffc9a7146103b05780631694505e146103ed57806317d70f7c14610418578063248a9ca3146104435780632614160e146104805780632841a143146104bd5761035c565b3661035c5734600a600082825461031a9190613e32565b925050819055507f88a5966d370b9919b20f3e2c13ff65706f196a4e32cc2c12bf57088f885258743334604051610352929190613eb6565b60405180910390a1005b34600a600082825461036e9190613e32565b925050819055507f88a5966d370b9919b20f3e2c13ff65706f196a4e32cc2c12bf57088f8852587433346040516103a6929190613eb6565b60405180910390a1005b3480156103bc57600080fd5b506103d760048036038101906103d29190613f4b565b610c91565b6040516103e49190613f93565b60405180910390f35b3480156103f957600080fd5b50610402610d0b565b60405161040f919061400d565b60405180910390f35b34801561042457600080fd5b5061042d610d31565b60405161043a9190614028565b60405180910390f35b34801561044f57600080fd5b5061046a60048036038101906104659190614079565b610d36565b60405161047791906140b5565b60405180910390f35b34801561048c57600080fd5b506104a760048036038101906104a291906140fc565b610d55565b6040516104b49190614028565b60405180910390f35b3480156104c957600080fd5b506104e460048036038101906104df9190614155565b610d6d565b005b3480156104f257600080fd5b5061050d60048036038101906105089190614182565b610e2a565b005b34801561051b57600080fd5b5061053660048036038101906105319190614182565b610e4c565b005b34801561054457600080fd5b5061055f600480360381019061055a91906141ee565b610ec7565b005b34801561056d57600080fd5b50610576610f0f565b005b34801561058457600080fd5b5061058d610ff1565b60405161059a9190614028565b60405180910390f35b6105bd60048036038101906105b8919061421b565b610ff7565b005b3480156105cb57600080fd5b506105d4611265565b6040516105e1919061428f565b60405180910390f35b3480156105f657600080fd5b50610611600480360381019061060c91906144c6565b611289565b005b34801561061f57600080fd5b5061063a600480360381019061063591906145f3565b6115a3565b005b34801561064857600080fd5b50610651611d3f565b60405161065e9190614028565b60405180910390f35b34801561067357600080fd5b5061068e600480360381019061068991906146b1565b611d45565b005b34801561069c57600080fd5b506106b760048036038101906106b291906141ee565b611f54565b005b3480156106c557600080fd5b506106ce611f9c565b6040516106db91906140b5565b60405180910390f35b3480156106f057600080fd5b506106f9611fc0565b6040516107069190613f93565b60405180910390f35b34801561071b57600080fd5b50610724611fd3565b6040516107319190614028565b60405180910390f35b34801561074657600080fd5b50610761600480360381019061075c91906146f1565b611fd9565b005b34801561076f57600080fd5b5061077861241e565b60405161078591906140b5565b60405180910390f35b34801561079a57600080fd5b506107b560048036038101906107b09190614798565b612442565b005b3480156107c357600080fd5b506107de60048036038101906107d991906146b1565b612833565b6040516107eb9190614028565b60405180910390f35b34801561080057600080fd5b50610809612858565b6040516108169190614841565b60405180910390f35b34801561082b57600080fd5b5061084660048036038101906108419190614182565b61287c565b6040516108539190613f93565b60405180910390f35b34801561086857600080fd5b506108716128e6565b60405161087e919061487d565b60405180910390f35b34801561089357600080fd5b5061089c6128fe565b005b3480156108aa57600080fd5b506108c560048036038101906108c091906146b1565b612a53565b005b3480156108d357600080fd5b506108dc612be0565b6040516108e99190614841565b60405180910390f35b3480156108fe57600080fd5b5061091960048036038101906109149190614898565b612c06565b005b34801561092757600080fd5b50610930612d7d565b60405161093d91906140b5565b60405180910390f35b34801561095257600080fd5b5061096d60048036038101906109689190614913565b612d84565b005b34801561097b57600080fd5b506109966004803603810190610991919061498e565b612e03565b005b3480156109a457600080fd5b506109ad61319d565b6040516109ba9190614841565b60405180910390f35b3480156109cf57600080fd5b506109ea60048036038101906109e59190614155565b6131c3565b005b3480156109f857600080fd5b50610a136004803603810190610a0e91906141ee565b6134f4565b005b348015610a2157600080fd5b50610a2a613729565b604051610a379190614028565b60405180910390f35b348015610a4c57600080fd5b50610a5561372f565b604051610a629190614028565b60405180910390f35b348015610a7757600080fd5b50610a80613735565b604051610a8d9190613f93565b60405180910390f35b348015610aa257600080fd5b50610aab613748565b604051610ab89190614a44565b60405180910390f35b348015610acd57600080fd5b50610ad661376c565b604051610ae39190614028565b60405180910390f35b348015610af857600080fd5b50610b01613772565b604051610b0e9190614028565b60405180910390f35b348015610b2357600080fd5b50610b2c613778565b604051610b399190614028565b60405180910390f35b348015610b4e57600080fd5b50610b696004803603810190610b649190614182565b61377e565b005b348015610b7757600080fd5b50610b806137a0565b604051610b8d9190614841565b60405180910390f35b348015610ba257600080fd5b50610bbd6004803603810190610bb891906140fc565b6137c6565b604051610bca9190614028565b60405180910390f35b348015610bdf57600080fd5b50610bfa6004803603810190610bf59190614aba565b6137de565b604051610c079190614b63565b60405180910390f35b348015610c1c57600080fd5b50610c2561380d565b604051610c329190614028565b60405180910390f35b348015610c4757600080fd5b50610c50613813565b604051610c5d9190614841565b60405180910390f35b348015610c7257600080fd5b50610c7b613839565b604051610c889190614028565b60405180910390f35b60007f7965db0b000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480610d045750610d038261383f565b5b9050919050565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600181565b6000806000838152602001908152602001600020600101549050919050565b60126020528060005260406000206000915090505481565b7f000000000000000000000000e6a062fba3918376500a602c800b1e030742045773ffffffffffffffffffffffffffffffffffffffff166323b872dd3330846040518463ffffffff1660e01b8152600401610dca93929190614b7e565b6020604051808303816000875af1158015610de9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e0d9190614bca565b5080600b6000828254610e209190613e32565b9250508190555050565b610e3382610d36565b610e3c816138a9565b610e4683836138bd565b50505050565b610e546139ae565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610eb8576040517f6697b23200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610ec282826139b6565b505050565b7ff1b411d6abb365480ac902cc153c45e9ded5847a2265ce6d01945d253edb6bc7610ef1816138a9565b81601060146101000a81548160ff0219169083151502179055505050565b7fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c21775610f39816138a9565b73430000000000000000000000000000000000000273ffffffffffffffffffffffffffffffffffffffff1663860043b630600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040518363ffffffff1660e01b8152600401610faa929190614bf7565b6020604051808303816000875af1158015610fc9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fed9190614c35565b5050565b60095481565b60008183856110069190613e32565b6110109190613e32565b905080341015611055576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161104c90614cbf565b60405180910390fd5b82826110619190613e32565b600a60008282546110729190613e32565b925050819055506000841115611158576000600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905060008173ffffffffffffffffffffffffffffffffffffffff16866040516110cf90614d10565b60006040518083038185875af1925050503d806000811461110c576040519150601f19603f3d011682016040523d82523d6000602084013e611111565b606091505b5050905080611155576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161114c90614d71565b60405180910390fd5b50505b600081346111669190614d91565b9050600081111561122557600033905060008173ffffffffffffffffffffffffffffffffffffffff168360405161119c90614d10565b60006040518083038185875af1925050503d80600081146111d9576040519150601f19603f3d011682016040523d82523d6000602084013e6111de565b606091505b5050905080611222576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161121990614d71565b60405180910390fd5b50505b7f9f15a78649bd76613c4a49ca8a67ae948862a0eee791ca3d0380853f9afa624f3383604051611256929190613eb6565b60405180910390a15050505050565b7f0000000000000000000000007acbbdf5013b5ec148683246e65ed168ea50769081565b7ff1b411d6abb365480ac902cc153c45e9ded5847a2265ce6d01945d253edb6bc76112b3816138a9565b601060149054906101000a900460ff1615611303576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112fa90614e11565b60405180910390fd5b8151835114611347576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161133e90614e7d565b60405180910390fd5b60005b835181101561141c5782818151811061136657611365614e9d565b5b60200260200101516014600086848151811061138557611384614e9d565b5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015611409576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161140090614f18565b60405180910390fd5b808061141490614f38565b91505061134a565b50600061142883613aa8565b905060005b84518110156114d35783818151811061144957611448614e9d565b5b60200260200101516014600087848151811061146857611467614e9d565b5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546114b99190614d91565b9250508190555080806114cb90614f38565b91505061142d565b507f0000000000000000000000007acbbdf5013b5ec148683246e65ed168ea50769073ffffffffffffffffffffffffffffffffffffffff1663f5298aca306001846040518463ffffffff1660e01b815260040161153293929190614f80565b600060405180830381600087803b15801561154c57600080fd5b505af1158015611560573d6000803e3d6000fd5b505050507f5ba5896aa4cc7b0ad558b01a8632c8d8a65dd5dee5394b2c2b78c3ddc5f326538484604051611595929190615133565b60405180910390a150505050565b847f000000000000000000000000e6a062fba3918376500a602c800b1e030742045773ffffffffffffffffffffffffffffffffffffffff1663dd62ed3e33306040518363ffffffff1660e01b81526004016115ff929190614bf7565b602060405180830381865afa15801561161c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116409190614c35565b1015611681576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611678906151b6565b60405180910390fd5b601060149054906101000a900460ff16156116d1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116c890614e11565b60405180910390fd5b83601160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008981526020019081526020016000205414611763576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161175a90615222565b60405180910390fd5b600954836117719190613e32565b42106117b2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016117a99061528e565b60405180910390fd5b6013600083815260200190815260200160002060009054906101000a900460ff1615611813576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161180a906152fa565b60405180910390fd5b6000611850338989898989896040516020016118359796959493929190615383565b60405160208183030381529060405280519060200120613afa565b905061189d81837f00000000000000000000000063a37fbd924c6d5e2c2a7fdfddbd079a0837c67573ffffffffffffffffffffffffffffffffffffffff16613b6c9092919063ffffffff16565b6118dc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118d390615450565b60405180910390fd5b60016013600085815260200190815260200160002060006101000a81548160ff02191690831515021790555042601160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a8152602001908152602001600020819055506000612710600554886119709190615470565b61197a91906154e1565b905060006127106006548961198f9190615470565b61199991906154e1565b905060006127106008548a6119ae9190615470565b6119b891906154e1565b905060006127106007548b6119cd9190615470565b6119d791906154e1565b90507f000000000000000000000000e6a062fba3918376500a602c800b1e030742045773ffffffffffffffffffffffffffffffffffffffff166323b872dd33308d6040518463ffffffff1660e01b8152600401611a3693929190614b7e565b6020604051808303816000875af1158015611a55573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a799190614bca565b5081600c6000828254611a8c9190613e32565b9250508190555080600b6000828254611aa59190613e32565b925050819055506000841115611b41577f000000000000000000000000e6a062fba3918376500a602c800b1e030742045773ffffffffffffffffffffffffffffffffffffffff166342966c68856040518263ffffffff1660e01b8152600401611b0e9190614028565b600060405180830381600087803b158015611b2857600080fd5b505af1158015611b3c573d6000803e3d6000fd5b505050505b6000831115611c0c577f000000000000000000000000e6a062fba3918376500a602c800b1e030742045773ffffffffffffffffffffffffffffffffffffffff1663a9059cbb600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16856040518363ffffffff1660e01b8152600401611bc7929190613eb6565b6020604051808303816000875af1158015611be6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c0a9190614bca565b505b60008c148015611c1c575060008b115b15611c7f57611c2b338c613baf565b3373ffffffffffffffffffffffffffffffffffffffff167fcf1d432606e0ee6a23fc32ce701ac36c9897204278c35ac9d65112344b20991760018d8a604051611c7693929190615512565b60405180910390a25b60018c03611cd8573373ffffffffffffffffffffffffffffffffffffffff167f759647c6e0ef64ba58a247443390ca1ca127a0e56c0ca73b8e7adb81cdea686f8c89604051611ccf929190615549565b60405180910390a25b60028c03611d31573373ffffffffffffffffffffffffffffffffffffffff167f064c6c90fdf69cdb269f2989d2db58656f9f0975deb0a85bc6c3e85ce03849368c89604051611d28929190615549565b60405180910390a25b505050505050505050505050565b600c5481565b601060159054906101000a900460ff1615611d95576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d8c906155be565b60405180910390fd5b80601460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015611e17576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e0e9061562a565b60405180910390fd5b80601460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611e669190614d91565b925050819055507f0000000000000000000000007acbbdf5013b5ec148683246e65ed168ea50769073ffffffffffffffffffffffffffffffffffffffff1663f242432a30846001856040518563ffffffff1660e01b8152600401611ecd949392919061567e565b600060405180830381600087803b158015611ee757600080fd5b505af1158015611efb573d6000803e3d6000fd5b505050503373ffffffffffffffffffffffffffffffffffffffff167ff279e6a1f5e320cca91135676d9cb6e44ca8a08c0b88342bcdb1144f6511b568600183604051611f48929190615549565b60405180910390a25050565b7ff1b411d6abb365480ac902cc153c45e9ded5847a2265ce6d01945d253edb6bc7611f7e816138a9565b81601060156101000a81548160ff0219169083151502179055505050565b7ff1b411d6abb365480ac902cc153c45e9ded5847a2265ce6d01945d253edb6bc781565b601060149054906101000a900460ff1681565b600a5481565b7ff1b411d6abb365480ac902cc153c45e9ded5847a2265ce6d01945d253edb6bc7612003816138a9565b601060149054906101000a900460ff16612052576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161204990615722565b60405180910390fd5b82518451148015612064575081518351145b6120a3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161209a9061578e565b60405180910390fd5b60005b8451811015612417578381815181106120c2576120c1614e9d565b5b602002602001015147101561210c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612103906157fa565b60405180910390fd5b82818151811061211f5761211e614e9d565b5b60200260200101517f000000000000000000000000e6a062fba3918376500a602c800b1e030742045773ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016121809190614841565b602060405180830381865afa15801561219d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121c19190614c35565b1015612202576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016121f990615866565b60405180910390fd5b600084828151811061221757612216614e9d565b5b6020026020010151111561230d57600085828151811061223a57612239614e9d565b5b6020026020010151905060008173ffffffffffffffffffffffffffffffffffffffff168684815181106122705761226f614e9d565b5b602002602001015160405161228490614d10565b60006040518083038185875af1925050503d80600081146122c1576040519150601f19603f3d011682016040523d82523d6000602084013e6122c6565b606091505b505090508061230a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161230190614d71565b60405180910390fd5b50505b600083828151811061232257612321614e9d565b5b60200260200101511115612404577f000000000000000000000000e6a062fba3918376500a602c800b1e030742045773ffffffffffffffffffffffffffffffffffffffff1663a9059cbb86838151811061237f5761237e614e9d565b5b602002602001015185848151811061239a57612399614e9d565b5b60200260200101516040518363ffffffff1660e01b81526004016123bf929190613eb6565b6020604051808303816000875af11580156123de573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124029190614bca565b505b808061240f90614f38565b9150506120a6565b5050505050565b7fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c2177581565b837f000000000000000000000000e6a062fba3918376500a602c800b1e030742045773ffffffffffffffffffffffffffffffffffffffff1663dd62ed3e33306040518363ffffffff1660e01b815260040161249e929190614bf7565b602060405180830381865afa1580156124bb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124df9190614c35565b1015612520576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612517906151b6565b60405180910390fd5b601060149054906101000a900460ff1615612570576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161256790614e11565b60405180910390fd5b6009548361257e9190613e32565b42106125bf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016125b69061528e565b60405180910390fd5b6013600083815260200190815260200160002060009054906101000a900460ff1615612620576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612617906152fa565b60405180910390fd5b600061265b33888888888860405160200161264096959493929190615886565b60405160208183030381529060405280519060200120613afa565b90506126a881837f00000000000000000000000063a37fbd924c6d5e2c2a7fdfddbd079a0837c67573ffffffffffffffffffffffffffffffffffffffff16613b6c9092919063ffffffff16565b6126e7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016126de90615450565b60405180910390fd5b60016013600085815260200190815260200160002060006101000a81548160ff0219169083151502179055507f000000000000000000000000e6a062fba3918376500a602c800b1e030742045773ffffffffffffffffffffffffffffffffffffffff166323b872dd33601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16886040518463ffffffff1660e01b815260040161279293929190614b7e565b6020604051808303816000875af11580156127b1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127d59190614bca565b503373ffffffffffffffffffffffffffffffffffffffff167f13f135658b67258df1952b1efe89331bc59bde07499073b16d5f4908012dce5b8888888760405161282294939291906158f6565b60405180910390a250505050505050565b6011602052816000526040600020602052806000526040600020600091509150505481565b7f0000000000000000000000009c910cb24ed6f9d248f1b3f1492ab887cdccc97381565b600080600084815260200190815260200160002060000160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b73430000000000000000000000000000000000000281565b6000801b61290b816138a9565b601060149054906101000a900460ff1661295a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161295190615722565b60405180910390fd5b6000471161299d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161299490615987565b60405180910390fd5b600033905060008173ffffffffffffffffffffffffffffffffffffffff16476040516129c890614d10565b60006040518083038185875af1925050503d8060008114612a05576040519150601f19603f3d011682016040523d82523d6000602084013e612a0a565b606091505b5050905080612a4e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612a4590614d71565b60405180910390fd5b505050565b601060149054906101000a900460ff1615612aa3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612a9a90614e11565b60405180910390fd5b7f0000000000000000000000007acbbdf5013b5ec148683246e65ed168ea50769073ffffffffffffffffffffffffffffffffffffffff1663f242432a33306001856040518563ffffffff1660e01b8152600401612b03949392919061567e565b600060405180830381600087803b158015612b1d57600080fd5b505af1158015612b31573d6000803e3d6000fd5b5050505080601460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254612b849190613e32565b925050819055508173ffffffffffffffffffffffffffffffffffffffff167f90890809c654f11d6e72a28fa60149770a0d11ec6c92319d6ceb2bb0a4ea1a15600183604051612bd4929190615549565b60405180910390a25050565b601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b7fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c21775612c30816138a9565b85600d60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555084600e60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555083600f60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555082601060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555081600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550505050505050565b6000801b81565b7fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c21775612dae816138a9565b8560098190555084600481905550836005819055508260068190555081600781905550818385612710612de19190614d91565b612deb9190614d91565b612df59190614d91565b600881905550505050505050565b837f000000000000000000000000e6a062fba3918376500a602c800b1e030742045773ffffffffffffffffffffffffffffffffffffffff1663dd62ed3e33306040518363ffffffff1660e01b8152600401612e5f929190614bf7565b602060405180830381865afa158015612e7c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ea09190614c35565b1015612ee1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612ed8906151b6565b60405180910390fd5b601060149054906101000a900460ff1615612f31576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612f2890614e11565b60405180910390fd5b60095483612f3f9190613e32565b4210612f80576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612f779061528e565b60405180910390fd5b6013600083815260200190815260200160002060009054906101000a900460ff1615612fe1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612fd8906152fa565b60405180910390fd5b600061301833868686604051602001612ffd94939291906159a7565b60405160208183030381529060405280519060200120613afa565b905061306581837f00000000000000000000000063a37fbd924c6d5e2c2a7fdfddbd079a0837c67573ffffffffffffffffffffffffffffffffffffffff16613b6c9092919063ffffffff16565b6130a4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161309b90615450565b60405180910390fd5b60016013600085815260200190815260200160002060006101000a81548160ff0219169083151502179055507f000000000000000000000000e6a062fba3918376500a602c800b1e030742045773ffffffffffffffffffffffffffffffffffffffff166379cc679033876040518363ffffffff1660e01b815260040161312b929190613eb6565b600060405180830381600087803b15801561314557600080fd5b505af1158015613159573d6000803e3d6000fd5b505050507f87408b749fe68cfca13b466a5ff4b8f019fbbebe8cbb3b62ee9055ae415318ae338460405161318e929190613eb6565b60405180910390a15050505050565b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b7ff1b411d6abb365480ac902cc153c45e9ded5847a2265ce6d01945d253edb6bc76131ed816138a9565b6000600267ffffffffffffffff81111561320a576132096142c0565b5b6040519080825280602002602001820160405280156132385781602001602082028036833780820191505090505b5090507f000000000000000000000000e6a062fba3918376500a602c800b1e0307420457816000815181106132705761326f614e9d565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa158015613317573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061333b9190615a0a565b8160018151811061334f5761334e614e9d565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250506000600c5490507f000000000000000000000000e6a062fba3918376500a602c800b1e030742045773ffffffffffffffffffffffffffffffffffffffff1663095ea7b3600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836040518363ffffffff1660e01b815260040161340d929190613eb6565b6020604051808303816000875af115801561342c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134509190614bca565b506000600c81905550600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663791ac94782868530426040518663ffffffff1660e01b81526004016134bc959493929190615a37565b600060405180830381600087803b1580156134d657600080fd5b505af11580156134ea573d6000803e3d6000fd5b5050505050505050565b7fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c2177561351e816138a9565b600073ffffffffffffffffffffffffffffffffffffffff16600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16036135af576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016135a690615add565b60405180910390fd5b811561366f5773430000000000000000000000000000000000000273ffffffffffffffffffffffffffffffffffffffff1663662aa11d30600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040518363ffffffff1660e01b8152600401613626929190614bf7565b6020604051808303816000875af1158015613645573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136699190614c35565b50613725565b73430000000000000000000000000000000000000273ffffffffffffffffffffffffffffffffffffffff1663954fa5ee30600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040518363ffffffff1660e01b81526004016136e0929190614bf7565b6020604051808303816000875af11580156136ff573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906137239190614c35565b505b5050565b60075481565b60055481565b601060159054906101000a900460ff1681565b7f000000000000000000000000e6a062fba3918376500a602c800b1e030742045781565b600b5481565b60065481565b60085481565b61378782610d36565b613790816138a9565b61379a83836139b6565b50505050565b600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60146020528060005260406000206000915090505481565b60007ff23a6e612e1ff4830e658fe43f4e3cb4a5f8170bd5d9e69fb5d7a7fa9e4fdf9790509695505050505050565b60035481565b600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60045481565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b6138ba816138b56139ae565b613d21565b50565b60006138c9838361287c565b6139a357600160008085815260200190815260200160002060000160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506139406139ae565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16847f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a4600190506139a8565b600090505b92915050565b600033905090565b60006139c2838361287c565b15613a9d57600080600085815260200190815260200160002060000160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550613a3a6139ae565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16847ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a460019050613aa2565b600090505b92915050565b600080600090505b8251811015613af457828181518110613acc57613acb614e9d565b5b602002602001015182613adf9190613e32565b91508080613aec90614f38565b915050613ab0565b50919050565b6000806040518060400160405280601c81526020017f19457468657265756d205369676e6564204d6573736167653a0a333200000000815250905060008184604051602001613b4a929190615b84565b6040516020818303038152906040528051906020012090508092505050919050565b6000613b788383613d72565b73ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161490509392505050565b60008103613bf2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401613be990615bf8565b60405180910390fd5b600354811115613c37576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401613c2e90615c64565b60405180910390fd5b7f0000000000000000000000007acbbdf5013b5ec148683246e65ed168ea50769073ffffffffffffffffffffffffffffffffffffffff1663731133e9306001846040518463ffffffff1660e01b8152600401613c9593929190615c84565b600060405180830381600087803b158015613caf57600080fd5b505af1158015613cc3573d6000803e3d6000fd5b5050505080601460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254613d169190613e32565b925050819055505050565b613d2b828261287c565b613d6e5780826040517fe2517d3f000000000000000000000000000000000000000000000000000000008152600401613d65929190615cce565b60405180910390fd5b5050565b60006041825114613d8257600080fd5b60008060006020850151915060408501519050606085015160001a925060018684848460405160008152602001604052604051613dc29493929190615d13565b6020604051602081039080840390855afa158015613de4573d6000803e3d6000fd5b50505060206040510351935050505092915050565b6000819050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000613e3d82613df9565b9150613e4883613df9565b9250828201905080821115613e6057613e5f613e03565b5b92915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000613e9182613e66565b9050919050565b613ea181613e86565b82525050565b613eb081613df9565b82525050565b6000604082019050613ecb6000830185613e98565b613ed86020830184613ea7565b9392505050565b6000604051905090565b600080fd5b600080fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b613f2881613ef3565b8114613f3357600080fd5b50565b600081359050613f4581613f1f565b92915050565b600060208284031215613f6157613f60613ee9565b5b6000613f6f84828501613f36565b91505092915050565b60008115159050919050565b613f8d81613f78565b82525050565b6000602082019050613fa86000830184613f84565b92915050565b6000819050919050565b6000613fd3613fce613fc984613e66565b613fae565b613e66565b9050919050565b6000613fe582613fb8565b9050919050565b6000613ff782613fda565b9050919050565b61400781613fec565b82525050565b60006020820190506140226000830184613ffe565b92915050565b600060208201905061403d6000830184613ea7565b92915050565b6000819050919050565b61405681614043565b811461406157600080fd5b50565b6000813590506140738161404d565b92915050565b60006020828403121561408f5761408e613ee9565b5b600061409d84828501614064565b91505092915050565b6140af81614043565b82525050565b60006020820190506140ca60008301846140a6565b92915050565b6140d981613e86565b81146140e457600080fd5b50565b6000813590506140f6816140d0565b92915050565b60006020828403121561411257614111613ee9565b5b6000614120848285016140e7565b91505092915050565b61413281613df9565b811461413d57600080fd5b50565b60008135905061414f81614129565b92915050565b60006020828403121561416b5761416a613ee9565b5b600061417984828501614140565b91505092915050565b6000806040838503121561419957614198613ee9565b5b60006141a785828601614064565b92505060206141b8858286016140e7565b9150509250929050565b6141cb81613f78565b81146141d657600080fd5b50565b6000813590506141e8816141c2565b92915050565b60006020828403121561420457614203613ee9565b5b6000614212848285016141d9565b91505092915050565b60008060006060848603121561423457614233613ee9565b5b600061424286828701614140565b935050602061425386828701614140565b925050604061426486828701614140565b9150509250925092565b600061427982613fda565b9050919050565b6142898161426e565b82525050565b60006020820190506142a46000830184614280565b92915050565b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6142f8826142af565b810181811067ffffffffffffffff82111715614317576143166142c0565b5b80604052505050565b600061432a613edf565b905061433682826142ef565b919050565b600067ffffffffffffffff821115614356576143556142c0565b5b602082029050602081019050919050565b600080fd5b600061437f61437a8461433b565b614320565b905080838252602082019050602084028301858111156143a2576143a1614367565b5b835b818110156143cb57806143b788826140e7565b8452602084019350506020810190506143a4565b5050509392505050565b600082601f8301126143ea576143e96142aa565b5b81356143fa84826020860161436c565b91505092915050565b600067ffffffffffffffff82111561441e5761441d6142c0565b5b602082029050602081019050919050565b600061444261443d84614403565b614320565b9050808382526020820190506020840283018581111561446557614464614367565b5b835b8181101561448e578061447a8882614140565b845260208401935050602081019050614467565b5050509392505050565b600082601f8301126144ad576144ac6142aa565b5b81356144bd84826020860161442f565b91505092915050565b600080604083850312156144dd576144dc613ee9565b5b600083013567ffffffffffffffff8111156144fb576144fa613eee565b5b614507858286016143d5565b925050602083013567ffffffffffffffff81111561452857614527613eee565b5b61453485828601614498565b9150509250929050565b600080fd5b600067ffffffffffffffff82111561455e5761455d6142c0565b5b614567826142af565b9050602081019050919050565b82818337600083830152505050565b600061459661459184614543565b614320565b9050828152602081018484840111156145b2576145b161453e565b5b6145bd848285614574565b509392505050565b600082601f8301126145da576145d96142aa565b5b81356145ea848260208601614583565b91505092915050565b600080600080600080600060e0888a03121561461257614611613ee9565b5b60006146208a828b01614140565b97505060206146318a828b01614140565b96505060406146428a828b01614140565b95505060606146538a828b01614140565b94505060806146648a828b01614140565b93505060a06146758a828b01614140565b92505060c088013567ffffffffffffffff81111561469657614695613eee565b5b6146a28a828b016145c5565b91505092959891949750929550565b600080604083850312156146c8576146c7613ee9565b5b60006146d6858286016140e7565b92505060206146e785828601614140565b9150509250929050565b60008060006060848603121561470a57614709613ee9565b5b600084013567ffffffffffffffff81111561472857614727613eee565b5b614734868287016143d5565b935050602084013567ffffffffffffffff81111561475557614754613eee565b5b61476186828701614498565b925050604084013567ffffffffffffffff81111561478257614781613eee565b5b61478e86828701614498565b9150509250925092565b60008060008060008060c087890312156147b5576147b4613ee9565b5b60006147c389828a01614140565b96505060206147d489828a01614140565b95505060406147e589828a01614140565b94505060606147f689828a01614140565b935050608061480789828a01614140565b92505060a087013567ffffffffffffffff81111561482857614827613eee565b5b61483489828a016145c5565b9150509295509295509295565b60006020820190506148566000830184613e98565b92915050565b600061486782613fda565b9050919050565b6148778161485c565b82525050565b6000602082019050614892600083018461486e565b92915050565b600080600080600060a086880312156148b4576148b3613ee9565b5b60006148c2888289016140e7565b95505060206148d3888289016140e7565b94505060406148e4888289016140e7565b93505060606148f5888289016140e7565b9250506080614906888289016140e7565b9150509295509295909350565b600080600080600060a0868803121561492f5761492e613ee9565b5b600061493d88828901614140565b955050602061494e88828901614140565b945050604061495f88828901614140565b935050606061497088828901614140565b925050608061498188828901614140565b9150509295509295909350565b600080600080608085870312156149a8576149a7613ee9565b5b60006149b687828801614140565b94505060206149c787828801614140565b93505060406149d887828801614140565b925050606085013567ffffffffffffffff8111156149f9576149f8613eee565b5b614a05878288016145c5565b91505092959194509250565b6000614a1c82613fb8565b9050919050565b6000614a2e82614a11565b9050919050565b614a3e81614a23565b82525050565b6000602082019050614a596000830184614a35565b92915050565b600080fd5b60008083601f840112614a7a57614a796142aa565b5b8235905067ffffffffffffffff811115614a9757614a96614a5f565b5b602083019150836001820283011115614ab357614ab2614367565b5b9250929050565b60008060008060008060a08789031215614ad757614ad6613ee9565b5b6000614ae589828a016140e7565b9650506020614af689828a016140e7565b9550506040614b0789828a01614140565b9450506060614b1889828a01614140565b935050608087013567ffffffffffffffff811115614b3957614b38613eee565b5b614b4589828a01614a64565b92509250509295509295509295565b614b5d81613ef3565b82525050565b6000602082019050614b786000830184614b54565b92915050565b6000606082019050614b936000830186613e98565b614ba06020830185613e98565b614bad6040830184613ea7565b949350505050565b600081519050614bc4816141c2565b92915050565b600060208284031215614be057614bdf613ee9565b5b6000614bee84828501614bb5565b91505092915050565b6000604082019050614c0c6000830185613e98565b614c196020830184613e98565b9392505050565b600081519050614c2f81614129565b92915050565b600060208284031215614c4b57614c4a613ee9565b5b6000614c5984828501614c20565b91505092915050565b600082825260208201905092915050565b7f4e65656420746f2073656e64206d6f7265206574686572000000000000000000600082015250565b6000614ca9601783614c62565b9150614cb482614c73565b602082019050919050565b60006020820190508181036000830152614cd881614c9c565b9050919050565b600081905092915050565b50565b6000614cfa600083614cdf565b9150614d0582614cea565b600082019050919050565b6000614d1b82614ced565b9150819050919050565b7f4661696c656420746f2073656e64204574686572000000000000000000000000600082015250565b6000614d5b601483614c62565b9150614d6682614d25565b602082019050919050565b60006020820190508181036000830152614d8a81614d4e565b9050919050565b6000614d9c82613df9565b9150614da783613df9565b9250828203905081811115614dbf57614dbe613e03565b5b92915050565b7f47616d6520697320636c6f736564000000000000000000000000000000000000600082015250565b6000614dfb600e83614c62565b9150614e0682614dc5565b602082019050919050565b60006020820190508181036000830152614e2a81614dee565b9050919050565b7f496e707574206172726179206973206e6f74206d617463680000000000000000600082015250565b6000614e67601883614c62565b9150614e7282614e31565b602082019050919050565b60006020820190508181036000830152614e9681614e5a565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f496e76616c696420616d6f756e7420746f206275726e00000000000000000000600082015250565b6000614f02601683614c62565b9150614f0d82614ecc565b602082019050919050565b60006020820190508181036000830152614f3181614ef5565b9050919050565b6000614f4382613df9565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203614f7557614f74613e03565b5b600182019050919050565b6000606082019050614f956000830186613e98565b614fa26020830185613ea7565b614faf6040830184613ea7565b949350505050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b614fec81613e86565b82525050565b6000614ffe8383614fe3565b60208301905092915050565b6000602082019050919050565b600061502282614fb7565b61502c8185614fc2565b935061503783614fd3565b8060005b8381101561506857815161504f8882614ff2565b975061505a8361500a565b92505060018101905061503b565b5085935050505092915050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b6150aa81613df9565b82525050565b60006150bc83836150a1565b60208301905092915050565b6000602082019050919050565b60006150e082615075565b6150ea8185615080565b93506150f583615091565b8060005b8381101561512657815161510d88826150b0565b9750615118836150c8565b9250506001810190506150f9565b5085935050505092915050565b6000604082019050818103600083015261514d8185615017565b9050818103602083015261516181846150d5565b90509392505050565b7f4572726f72000000000000000000000000000000000000000000000000000000600082015250565b60006151a0600583614c62565b91506151ab8261516a565b602082019050919050565b600060208201905081810360008301526151cf81615193565b9050919050565b7f496e76616c6964206c617374206275792074696d650000000000000000000000600082015250565b600061520c601583614c62565b9150615217826151d6565b602082019050919050565b6000602082019050818103600083015261523b816151ff565b9050919050565b7f496e76616c69642074696d657374616d70000000000000000000000000000000600082015250565b6000615278601183614c62565b915061528382615242565b602082019050919050565b600060208201905081810360008301526152a78161526b565b9050919050565b7f4e6f6e6365206973207573656400000000000000000000000000000000000000600082015250565b60006152e4600d83614c62565b91506152ef826152ae565b602082019050919050565b60006020820190508181036000830152615313816152d7565b9050919050565b60008160601b9050919050565b60006153328261531a565b9050919050565b600061534482615327565b9050919050565b61535c61535782613e86565b615339565b82525050565b6000819050919050565b61537d61537882613df9565b615362565b82525050565b600061538f828a61534b565b60148201915061539f828961536c565b6020820191506153af828861536c565b6020820191506153bf828761536c565b6020820191506153cf828661536c565b6020820191506153df828561536c565b6020820191506153ef828461536c565b60208201915081905098975050505050505050565b7f496e76616c6964207369676e6174757265000000000000000000000000000000600082015250565b600061543a601183614c62565b915061544582615404565b602082019050919050565b600060208201905081810360008301526154698161542d565b9050919050565b600061547b82613df9565b915061548683613df9565b925082820261549481613df9565b915082820484148315176154ab576154aa613e03565b5b5092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b60006154ec82613df9565b91506154f783613df9565b925082615507576155066154b2565b5b828204905092915050565b60006060820190506155276000830186613ea7565b6155346020830185613ea7565b6155416040830184613ea7565b949350505050565b600060408201905061555e6000830185613ea7565b61556b6020830184613ea7565b9392505050565b7f4e4654206973206c6f636b656400000000000000000000000000000000000000600082015250565b60006155a8600d83614c62565b91506155b382615572565b602082019050919050565b600060208201905081810360008301526155d78161559b565b9050919050565b7f496e73756666696369656e742062616c616e6365000000000000000000000000600082015250565b6000615614601483614c62565b915061561f826155de565b602082019050919050565b6000602082019050818103600083015261564381615607565b9050919050565b600082825260208201905092915050565b600061566860008361564a565b915061567382614cea565b600082019050919050565b600060a0820190506156936000830187613e98565b6156a06020830186613e98565b6156ad6040830185613ea7565b6156ba6060830184613ea7565b81810360808301526156cb8161565b565b905095945050505050565b7f47616d65206973206e6f7420636c6f7365640000000000000000000000000000600082015250565b600061570c601283614c62565b9150615717826156d6565b602082019050919050565b6000602082019050818103600083015261573b816156ff565b9050919050565b7f496e76616c696420696e707574206172726179206c656e677468000000000000600082015250565b6000615778601a83614c62565b915061578382615742565b602082019050919050565b600060208201905081810360008301526157a78161576b565b9050919050565b7f4f766572206574682062616c616e636500000000000000000000000000000000600082015250565b60006157e4601083614c62565b91506157ef826157ae565b602082019050919050565b60006020820190508181036000830152615813816157d7565b9050919050565b7f4f76657220746f6b656e2062616c616e63650000000000000000000000000000600082015250565b6000615850601283614c62565b915061585b8261581a565b602082019050919050565b6000602082019050818103600083015261587f81615843565b9050919050565b6000615892828961534b565b6014820191506158a2828861536c565b6020820191506158b2828761536c565b6020820191506158c2828661536c565b6020820191506158d2828561536c565b6020820191506158e2828461536c565b602082019150819050979650505050505050565b600060808201905061590b6000830187613ea7565b6159186020830186613ea7565b6159256040830185613ea7565b6159326060830184613ea7565b95945050505050565b7f4e6f7468696e6720746f20776974686472617700000000000000000000000000600082015250565b6000615971601383614c62565b915061597c8261593b565b602082019050919050565b600060208201905081810360008301526159a081615964565b9050919050565b60006159b3828761534b565b6014820191506159c3828661536c565b6020820191506159d3828561536c565b6020820191506159e3828461536c565b60208201915081905095945050505050565b600081519050615a04816140d0565b92915050565b600060208284031215615a2057615a1f613ee9565b5b6000615a2e848285016159f5565b91505092915050565b600060a082019050615a4c6000830188613ea7565b615a596020830187613ea7565b8181036040830152615a6b8186615017565b9050615a7a6060830185613e98565b615a876080830184613ea7565b9695505050505050565b7f676173466565206973206e6f7420736574000000000000000000000000000000600082015250565b6000615ac7601183614c62565b9150615ad282615a91565b602082019050919050565b60006020820190508181036000830152615af681615aba565b9050919050565b600081519050919050565b60005b83811015615b26578082015181840152602081019050615b0b565b60008484015250505050565b6000615b3d82615afd565b615b478185614cdf565b9350615b57818560208601615b08565b80840191505092915050565b6000819050919050565b615b7e615b7982614043565b615b63565b82525050565b6000615b908285615b32565b9150615b9c8284615b6d565b6020820191508190509392505050565b7f496e76616c696420616d6f756e74000000000000000000000000000000000000600082015250565b6000615be2600e83614c62565b9150615bed82615bac565b602082019050919050565b60006020820190508181036000830152615c1181615bd5565b9050919050565b7f4d61782070657220626174636820726561636865640000000000000000000000600082015250565b6000615c4e601583614c62565b9150615c5982615c18565b602082019050919050565b60006020820190508181036000830152615c7d81615c41565b9050919050565b6000608082019050615c996000830186613e98565b615ca66020830185613ea7565b615cb36040830184613ea7565b8181036060830152615cc48161565b565b9050949350505050565b6000604082019050615ce36000830185613e98565b615cf060208301846140a6565b9392505050565b600060ff82169050919050565b615d0d81615cf7565b82525050565b6000608082019050615d2860008301876140a6565b615d356020830186615d04565b615d4260408301856140a6565b615d4f60608301846140a6565b9594505050505056fea2646970667358221220ba9369acc9f838a0bd40d5e9a55fe6587dabb2bd8af890b830cbd01dd2eec41b64736f6c63430008140033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000d65934f0e7d543d10b070ed1b3f62ca9b7e0c4c7000000000000000000000000d65934f0e7d543d10b070ed1b3f62ca9b7e0c4c7000000000000000000000000dc678248e99a5a7aee93342af067ea8bded520ec00000000000000000000000063a37fbd924c6d5e2c2a7fdfddbd079a0837c6750000000000000000000000007acbbdf5013b5ec148683246e65ed168ea507690000000000000000000000000e6a062fba3918376500a602c800b1e03074204570000000000000000000000009c910cb24ed6f9d248f1b3f1492ab887cdccc9730000000000000000000000002536fe9ab3f511540f2f9e2ec2a805005c3dd800
-----Decoded View---------------
Arg [0] : _defaultAdmin (address): 0xd65934F0e7d543D10B070eD1b3f62CA9b7E0c4c7
Arg [1] : _adminAddress (address): 0xd65934F0e7d543D10B070eD1b3f62CA9b7E0c4c7
Arg [2] : _workerAddress (address): 0xDc678248e99a5a7AeE93342aF067Ea8BdED520ec
Arg [3] : _signerAddress (address): 0x63A37FBD924C6D5e2c2a7FdfddBd079a0837c675
Arg [4] : _gangsterAddress (address): 0x7aCBBdF5013b5Ec148683246e65ed168EA507690
Arg [5] : _fiatAddress (address): 0xe6A062fba3918376500A602c800b1E0307420457
Arg [6] : _pointsOperator (address): 0x9c910cb24eD6F9d248f1B3f1492Ab887CDccC973
Arg [7] : _blastPointAddr (address): 0x2536FE9ab3F511540F2f9e2eC2A805005C3Dd800
-----Encoded View---------------
8 Constructor Arguments found :
Arg [0] : 000000000000000000000000d65934f0e7d543d10b070ed1b3f62ca9b7e0c4c7
Arg [1] : 000000000000000000000000d65934f0e7d543d10b070ed1b3f62ca9b7e0c4c7
Arg [2] : 000000000000000000000000dc678248e99a5a7aee93342af067ea8bded520ec
Arg [3] : 00000000000000000000000063a37fbd924c6d5e2c2a7fdfddbd079a0837c675
Arg [4] : 0000000000000000000000007acbbdf5013b5ec148683246e65ed168ea507690
Arg [5] : 000000000000000000000000e6a062fba3918376500a602c800b1e0307420457
Arg [6] : 0000000000000000000000009c910cb24ed6f9d248f1b3f1492ab887cdccc973
Arg [7] : 0000000000000000000000002536fe9ab3f511540f2f9e2ec2a805005c3dd800
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 35 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
[ Download: CSV Export ]
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.