Source Code
Latest 25 from a total of 8,206 transactions
| Transaction Hash |
|
Block
|
From
|
To
|
|||||
|---|---|---|---|---|---|---|---|---|---|
| Claim All Yield | 11006978 | 445 days ago | IN | 0 ETH | 0.00000026 | ||||
| Swap Tokens For ... | 11006682 | 446 days ago | IN | 0 ETH | 0.00000039 | ||||
| Emegency Withdra... | 11006637 | 446 days ago | IN | 0 ETH | 0.00000042 | ||||
| Claim All Yield | 11006613 | 446 days ago | IN | 0 ETH | 0.00000048 | ||||
| Claim All Yield | 10306141 | 462 days ago | IN | 0 ETH | 0.00000025 | ||||
| Emegency Withdra... | 10298624 | 462 days ago | IN | 0 ETH | 0.00000007 | ||||
| Claim Gas | 9870408 | 472 days ago | IN | 0 ETH | 0.00000026 | ||||
| Withdraw NFT | 9111074 | 489 days ago | IN | 0 ETH | 0.0000005 | ||||
| Withdraw NFT | 9021134 | 491 days ago | IN | 0 ETH | 0.00000045 | ||||
| Withdraw NFT | 9014659 | 492 days ago | IN | 0 ETH | 0.00000059 | ||||
| Withdraw NFT | 8975099 | 493 days ago | IN | 0 ETH | 0.00000037 | ||||
| Set Winner | 8750899 | 498 days ago | IN | 0 ETH | 0.00000111 | ||||
| Set Winner | 8750896 | 498 days ago | IN | 0 ETH | 0.00000181 | ||||
| Set Winner | 8749106 | 498 days ago | IN | 0 ETH | 0.00000066 | ||||
| Set Winner | 8749103 | 498 days ago | IN | 0 ETH | 0.00000597 | ||||
| Set Winner | 8749100 | 498 days ago | IN | 0 ETH | 0.00000596 | ||||
| Set Winner | 8749096 | 498 days ago | IN | 0 ETH | 0.00000596 | ||||
| Set Winner | 8747307 | 498 days ago | IN | 0 ETH | 0.0000009 | ||||
| Set Winner | 8747303 | 498 days ago | IN | 0 ETH | 0.00000825 | ||||
| Set Winner | 8747300 | 498 days ago | IN | 0 ETH | 0.00000824 | ||||
| Set Winner | 8747296 | 498 days ago | IN | 0 ETH | 0.00000828 | ||||
| Set Winner | 8745506 | 498 days ago | IN | 0 ETH | 0.00000101 | ||||
| Set Winner | 8745503 | 498 days ago | IN | 0 ETH | 0.00000939 | ||||
| Set Winner | 8745500 | 498 days ago | IN | 0 ETH | 0.00000912 | ||||
| Set Winner | 8745496 | 498 days ago | IN | 0 ETH | 0.0000089 |
Latest 25 internal transactions (View All)
Advanced mode:
| Parent Transaction Hash | Block | From | To | |||
|---|---|---|---|---|---|---|
| 10298624 | 462 days ago | 0.33043665 ETH | ||||
| 9124395 | 489 days ago | 0.00065056 ETH | ||||
| 9124395 | 489 days ago | 0.00130113 ETH | ||||
| 9124047 | 489 days ago | 0.00191514 ETH | ||||
| 9124047 | 489 days ago | 0.00383028 ETH | ||||
| 9107074 | 489 days ago | 0.00137249 ETH | ||||
| 9107074 | 489 days ago | 0.00274498 ETH | ||||
| 9105561 | 490 days ago | 0.0013273 ETH | ||||
| 9105561 | 490 days ago | 0.0026546 ETH | ||||
| 9105553 | 490 days ago | 0.00097124 ETH | ||||
| 9105553 | 490 days ago | 0.00194248 ETH | ||||
| 9105431 | 490 days ago | 0.00098357 ETH | ||||
| 9105431 | 490 days ago | 0.00196715 ETH | ||||
| 9105424 | 490 days ago | 0.00079917 ETH | ||||
| 9105424 | 490 days ago | 0.00159835 ETH | ||||
| 9105416 | 490 days ago | 0.00080961 ETH | ||||
| 9105416 | 490 days ago | 0.00161923 ETH | ||||
| 9105407 | 490 days ago | 0.00305859 ETH | ||||
| 9105407 | 490 days ago | 0.00611718 ETH | ||||
| 9093854 | 490 days ago | 0.00787605 ETH | ||||
| 9093854 | 490 days ago | 0.01575211 ETH | ||||
| 9069957 | 490 days ago | 0.00130033 ETH | ||||
| 9069957 | 490 days ago | 0.00260066 ETH | ||||
| 9045623 | 491 days ago | 0.00128639 ETH | ||||
| 9045623 | 491 days ago | 0.00257278 ETH |
Cross-Chain Transactions
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 = 30000 ether; //limit token for LP, swap to ether when over
uint256 public burnRate = 10_00;
uint256 public auctionRate = 30_00;
uint256 public prizeRate = 60_00;
uint256 public ethRate = 0;
uint256 public devRate = 0;
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 auctionTreasury_;
address public spinPoolAddr_;
//****************
// Game Data
//****************
bool public gameClosed; // Flag toggle when game close
bool public lockNFT; // flag when nft is locked
mapping(uint256 => uint256) public lastB; // 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;
_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)'));
}
//***************************
// 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[_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[_typeA] = block.timestamp;
uint256 burnValue = (_value * burnRate) / 100_00;
uint256 auctionValue = (_value * auctionRate) / 100_00;
uint256 lpValue = (_value * ethRate) / 100_00;
uint256 prizeValue = (_value * prizeRate) / 100_00;
uint256 devValue = (_value * devRate) / 100_00;
greedToken.transferFrom(msg.sender, address(this), _value);
tokenForLP += lpValue;
tokenPrize += prizeValue;
if (burnValue > 0) greedToken.burn(burnValue);
if (auctionValue > 0) greedToken.transfer(auctionTreasury_, auctionValue);
if (devValue > 0) greedToken.transfer(devAddr_, devValue);
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);
if (_typeA == 3) emit BuyPistol(msg.sender, _amount, _nonce);
if (_typeA == 4) emit BuyShield(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);
}
/**
* @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 _auctionRate,
uint256 _prizeRate,
uint256 _devRate
) public onlyRole(ADMIN_ROLE) {
vtd = _vtd;
tokenSwapLimit = _tokenSwapLimit;
burnRate = _burnRate;
auctionRate = _auctionRate;
prizeRate = _prizeRate;
devRate = _devRate;
ethRate = 100_00 - _burnRate - _devRate - _prizeRate - _auctionRate;
}
function setGameAddress(
address _devAddr,
address _gasFeeOperator,
address _auctionTreasury,
address _spinPool,
address _uniswapV2Router
) public onlyRole(ADMIN_ROLE) {
devAddr_ = _devAddr;
gasFeeOperator_ = _gasFeeOperator;
auctionTreasury_ = _auctionTreasury;
spinPoolAddr_ = _spinPool;
uniswapV2Router = IUniswapV2Router02(_uniswapV2Router);
}
/**
***************************
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 BuyPistol(address indexed to, uint256 amount, uint256 nonce);
event BuyShield(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":"BuyPistol","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":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"nonce","type":"uint256"}],"name":"BuyShield","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":"auctionRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"auctionTreasury_","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","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":[{"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":"devRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"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":"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":[],"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":"_auctionTreasury","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":"_auctionRate","type":"uint256"},{"internalType":"uint256","name":"_prizeRate","type":"uint256"},{"internalType":"uint256","name":"_devRate","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
6101006040526101f460035569065a4da25d3016c000006004556103e8600555610bb860065561177060075560006008556000600955603c600a553480156200004757600080fd5b50604051620061913803806200619183398181016040528101906200006d919062000583565b600180819055508373ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff16815250508273ffffffffffffffffffffffffffffffffffffffff1660a08173ffffffffffffffffffffffffffffffffffffffff16815250508473ffffffffffffffffffffffffffffffffffffffff1660c08173ffffffffffffffffffffffffffffffffffffffff16815250508173ffffffffffffffffffffffffffffffffffffffff1660e08173ffffffffffffffffffffffffffffffffffffffff1681525050620001596000801b896200035f60201b60201c565b506200018c7fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c21775886200035f60201b60201c565b50620001bf7ff1b411d6abb365480ac902cc153c45e9ded5847a2265ce6d01945d253edb6bc7876200035f60201b60201c565b50600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161462000351578073ffffffffffffffffffffffffffffffffffffffff166336b91f2b836040518263ffffffff1660e01b81526004016200023091906200065d565b600060405180830381600087803b1580156200024b57600080fd5b505af115801562000260573d6000803e3d6000fd5b5050505073430000000000000000000000000000000000000273ffffffffffffffffffffffffffffffffffffffff16634e606c476040518163ffffffff1660e01b8152600401600060405180830381600087803b158015620002c157600080fd5b505af1158015620002d6573d6000803e3d6000fd5b5050505073430000000000000000000000000000000000000273ffffffffffffffffffffffffffffffffffffffff1663f098767a6040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156200033757600080fd5b505af11580156200034c573d6000803e3d6000fd5b505050505b50505050505050506200067a565b60006200037383836200046260201b60201c565b6200045757600160008085815260200190815260200160002060000160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550620003f3620004cc60201b60201c565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16847f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a4600190506200045c565b600090505b92915050565b600080600084815260200190815260200160002060000160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b600033905090565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006200050682620004d9565b9050919050565b6200051881620004f9565b81146200052457600080fd5b50565b60008151905062000538816200050d565b92915050565b60006200054b82620004d9565b9050919050565b6200055d816200053e565b81146200056957600080fd5b50565b6000815190506200057d8162000552565b92915050565b600080600080600080600080610100898b031215620005a757620005a6620004d4565b5b6000620005b78b828c0162000527565b9850506020620005ca8b828c0162000527565b9750506040620005dd8b828c0162000527565b9650506060620005f08b828c0162000527565b9550506080620006038b828c0162000527565b94505060a0620006168b828c016200056c565b93505060c0620006298b828c0162000527565b92505060e06200063c8b828c0162000527565b9150509295985092959890939650565b6200065781620004f9565b82525050565b60006020820190506200067460008301846200064c565b92915050565b60805160a05160c05160e051615a666200072b600039600061299e01526000818161185c01526127c7015260008181610d71015281816115e6015281816119c001528181611a9c01528181611b3101528181611bfc0152818161228c01528181612495015281816125a80152818161287801528181612ffa0152818161314f0152613507015260008181611281015281816114f001528181611fd201528181612be901526139d00152615a666000f3fe6080604052600436106103035760003560e01c80638d9d548211610190578063bc90c273116100dc578063d2d93f9011610095578063f23a6e611161006f578063f23a6e6114610bd5578063f72fc7cb14610c12578063fcd2117d14610c3d578063fdbefb5914610c685761035c565b8063d2d93f9014610b44578063d547741f14610b6f578063ede6ec5d14610b985761035c565b8063bc90c27314610a42578063bed9985014610a6d578063bee2660914610a98578063c020b08c14610ac3578063c0be0c0b14610aee578063c957497514610b195761035c565b80639f87295011610149578063ad6190e111610123578063ad6190e11461099c578063ad85e3bd146109c5578063b28805f4146109f0578063b943cbbb14610a195761035c565b80639f8729501461091d5780639fc0db5614610948578063a217fddf146109715761035c565b80638d9d54821461081f57806390824c5b1461084a57806391d148541461087557806397d75776146108b257806398795ee6146108dd5780639b5b9b18146108f45761035c565b806347ccca021161024f57806362af5693116102085780636e3e40d9116101e25780636e3e40d91461077757806373a58223146107a257806375b238fc146107cb5780638af02ab1146107f65761035c565b806362af5693146106f8578063634252dc146107215780636d99ef461461074c5761035c565b806347ccca02146105fc5780634c57207d146106275780634cb8e760146106505780635b262a771461067b57806360174693146106a45780636088e93a146106cf5761035c565b80632f2ff15d116102bc578063409a33ce11610296578063409a33ce1461056157806341a21bcf1461057857806346816290146105a3578063470e3ec9146105bf5761035c565b80632f2ff15d146104e657806336568abe1461050f578063368b28bd146105385761035c565b806301ffc9a7146103b05780631694505e146103ed57806317d70f7c14610418578063248a9ca3146104435780632614160e146104805780632841a143146104bd5761035c565b3661035c5734600b600082825461031a9190613bc9565b925050819055507f88a5966d370b9919b20f3e2c13ff65706f196a4e32cc2c12bf57088f885258743334604051610352929190613c4d565b60405180910390a1005b34600b600082825461036e9190613bc9565b925050819055507f88a5966d370b9919b20f3e2c13ff65706f196a4e32cc2c12bf57088f8852587433346040516103a6929190613c4d565b60405180910390a1005b3480156103bc57600080fd5b506103d760048036038101906103d29190613ce2565b610c93565b6040516103e49190613d2a565b60405180910390f35b3480156103f957600080fd5b50610402610d0d565b60405161040f9190613da4565b60405180910390f35b34801561042457600080fd5b5061042d610d33565b60405161043a9190613dbf565b60405180910390f35b34801561044f57600080fd5b5061046a60048036038101906104659190613e10565b610d38565b6040516104779190613e4c565b60405180910390f35b34801561048c57600080fd5b506104a760048036038101906104a29190613e93565b610d57565b6040516104b49190613dbf565b60405180910390f35b3480156104c957600080fd5b506104e460048036038101906104df9190613eec565b610d6f565b005b3480156104f257600080fd5b5061050d60048036038101906105089190613f19565b610e2c565b005b34801561051b57600080fd5b5061053660048036038101906105319190613f19565b610e4e565b005b34801561054457600080fd5b5061055f600480360381019061055a9190613f85565b610ec9565b005b34801561056d57600080fd5b50610576610f11565b005b34801561058457600080fd5b5061058d610ff3565b60405161059a9190613dbf565b60405180910390f35b6105bd60048036038101906105b89190613fb2565b610ff9565b005b3480156105cb57600080fd5b506105e660048036038101906105e19190613eec565b611267565b6040516105f39190613dbf565b60405180910390f35b34801561060857600080fd5b5061061161127f565b60405161061e9190614026565b60405180910390f35b34801561063357600080fd5b5061064e6004803603810190610649919061425d565b6112a3565b005b34801561065c57600080fd5b506106656115bd565b60405161067291906142d5565b60405180910390f35b34801561068757600080fd5b506106a2600480360381019061069d91906143a5565b6115e3565b005b3480156106b057600080fd5b506106b9611ea2565b6040516106c69190613dbf565b60405180910390f35b3480156106db57600080fd5b506106f660048036038101906106f19190614463565b611ea8565b005b34801561070457600080fd5b5061071f600480360381019061071a9190613f85565b6120b7565b005b34801561072d57600080fd5b506107366120ff565b6040516107439190613e4c565b60405180910390f35b34801561075857600080fd5b50610761612123565b60405161076e9190613d2a565b60405180910390f35b34801561078357600080fd5b5061078c612136565b6040516107999190613dbf565b60405180910390f35b3480156107ae57600080fd5b506107c960048036038101906107c491906144a3565b61213c565b005b3480156107d757600080fd5b506107e0612581565b6040516107ed9190613e4c565b60405180910390f35b34801561080257600080fd5b5061081d6004803603810190610818919061454a565b6125a5565b005b34801561082b57600080fd5b50610834612996565b6040516108419190613dbf565b60405180910390f35b34801561085657600080fd5b5061085f61299c565b60405161086c91906142d5565b60405180910390f35b34801561088157600080fd5b5061089c60048036038101906108979190613f19565b6129c0565b6040516108a99190613d2a565b60405180910390f35b3480156108be57600080fd5b506108c7612a2a565b6040516108d49190614614565b60405180910390f35b3480156108e957600080fd5b506108f2612a42565b005b34801561090057600080fd5b5061091b60048036038101906109169190614463565b612b97565b005b34801561092957600080fd5b50610932612d24565b60405161093f91906142d5565b60405180910390f35b34801561095457600080fd5b5061096f600480360381019061096a919061462f565b612d4a565b005b34801561097d57600080fd5b50610986612ec1565b6040516109939190613e4c565b60405180910390f35b3480156109a857600080fd5b506109c360048036038101906109be91906146aa565b612ec8565b005b3480156109d157600080fd5b506109da612f5a565b6040516109e791906142d5565b60405180910390f35b3480156109fc57600080fd5b50610a176004803603810190610a129190613eec565b612f80565b005b348015610a2557600080fd5b50610a406004803603810190610a3b9190613f85565b6132b1565b005b348015610a4e57600080fd5b50610a576134e6565b604051610a649190613dbf565b60405180910390f35b348015610a7957600080fd5b50610a826134ec565b604051610a8f9190613dbf565b60405180910390f35b348015610aa457600080fd5b50610aad6134f2565b604051610aba9190613d2a565b60405180910390f35b348015610acf57600080fd5b50610ad8613505565b604051610ae5919061476a565b60405180910390f35b348015610afa57600080fd5b50610b03613529565b604051610b109190613dbf565b60405180910390f35b348015610b2557600080fd5b50610b2e61352f565b604051610b3b9190613dbf565b60405180910390f35b348015610b5057600080fd5b50610b59613535565b604051610b669190613dbf565b60405180910390f35b348015610b7b57600080fd5b50610b966004803603810190610b919190613f19565b61353b565b005b348015610ba457600080fd5b50610bbf6004803603810190610bba9190613e93565b61355d565b604051610bcc9190613dbf565b60405180910390f35b348015610be157600080fd5b50610bfc6004803603810190610bf791906147e0565b613575565b604051610c099190614889565b60405180910390f35b348015610c1e57600080fd5b50610c276135a4565b604051610c349190613dbf565b60405180910390f35b348015610c4957600080fd5b50610c526135aa565b604051610c5f91906142d5565b60405180910390f35b348015610c7457600080fd5b50610c7d6135d0565b604051610c8a9190613dbf565b60405180910390f35b60007f7965db0b000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480610d065750610d05826135d6565b5b9050919050565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600181565b6000806000838152602001908152602001600020600101549050919050565b60136020528060005260406000206000915090505481565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166323b872dd3330846040518463ffffffff1660e01b8152600401610dcc939291906148a4565b6020604051808303816000875af1158015610deb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e0f91906148f0565b5080600c6000828254610e229190613bc9565b9250508190555050565b610e3582610d38565b610e3e81613640565b610e488383613654565b50505050565b610e56613745565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610eba576040517f6697b23200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610ec4828261374d565b505050565b7ff1b411d6abb365480ac902cc153c45e9ded5847a2265ce6d01945d253edb6bc7610ef381613640565b81601160146101000a81548160ff0219169083151502179055505050565b7fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c21775610f3b81613640565b73430000000000000000000000000000000000000273ffffffffffffffffffffffffffffffffffffffff1663860043b630600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040518363ffffffff1660e01b8152600401610fac92919061491d565b6020604051808303816000875af1158015610fcb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fef919061495b565b5050565b600a5481565b60008183856110089190613bc9565b6110129190613bc9565b905080341015611057576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161104e906149e5565b60405180910390fd5b82826110639190613bc9565b600b60008282546110749190613bc9565b92505081905550600084111561115a576000600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905060008173ffffffffffffffffffffffffffffffffffffffff16866040516110d190614a36565b60006040518083038185875af1925050503d806000811461110e576040519150601f19603f3d011682016040523d82523d6000602084013e611113565b606091505b5050905080611157576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161114e90614a97565b60405180910390fd5b50505b600081346111689190614ab7565b9050600081111561122757600033905060008173ffffffffffffffffffffffffffffffffffffffff168360405161119e90614a36565b60006040518083038185875af1925050503d80600081146111db576040519150601f19603f3d011682016040523d82523d6000602084013e6111e0565b606091505b5050905080611224576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161121b90614a97565b60405180910390fd5b50505b7f9f15a78649bd76613c4a49ca8a67ae948862a0eee791ca3d0380853f9afa624f3383604051611258929190613c4d565b60405180910390a15050505050565b60126020528060005260406000206000915090505481565b7f000000000000000000000000000000000000000000000000000000000000000081565b7ff1b411d6abb365480ac902cc153c45e9ded5847a2265ce6d01945d253edb6bc76112cd81613640565b601160149054906101000a900460ff161561131d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161131490614b37565b60405180910390fd5b8151835114611361576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161135890614ba3565b60405180910390fd5b60005b8351811015611436578281815181106113805761137f614bc3565b5b60200260200101516015600086848151811061139f5761139e614bc3565b5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015611423576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161141a90614c3e565b60405180910390fd5b808061142e90614c5e565b915050611364565b5060006114428361383f565b905060005b84518110156114ed5783818151811061146357611462614bc3565b5b60200260200101516015600087848151811061148257611481614bc3565b5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546114d39190614ab7565b9250508190555080806114e590614c5e565b915050611447565b507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663f5298aca306001846040518463ffffffff1660e01b815260040161154c93929190614ca6565b600060405180830381600087803b15801561156657600080fd5b505af115801561157a573d6000803e3d6000fd5b505050507f5ba5896aa4cc7b0ad558b01a8632c8d8a65dd5dee5394b2c2b78c3ddc5f3265384846040516115af929190614e59565b60405180910390a150505050565b601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b847f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663dd62ed3e33306040518363ffffffff1660e01b815260040161163f92919061491d565b602060405180830381865afa15801561165c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611680919061495b565b10156116c1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116b890614edc565b60405180910390fd5b601160149054906101000a900460ff1615611711576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161170890614b37565b60405180910390fd5b83601260008981526020019081526020016000205414611766576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161175d90614f48565b60405180910390fd5b600a54836117749190613bc9565b42106117b5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016117ac90614fb4565b60405180910390fd5b6014600083815260200190815260200160002060009054906101000a900460ff1615611816576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161180d90615020565b60405180910390fd5b60006118533389898989898960405160200161183897969594939291906150a9565b60405160208183030381529060405280519060200120613891565b90506118a081837f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166139039092919063ffffffff16565b6118df576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118d690615176565b60405180910390fd5b60016014600085815260200190815260200160002060006101000a81548160ff02191690831515021790555042601260008a8152602001908152602001600020819055506000612710600554886119369190615196565b6119409190615207565b90506000612710600654896119559190615196565b61195f9190615207565b905060006127106008548a6119749190615196565b61197e9190615207565b905060006127106007548b6119939190615196565b61199d9190615207565b905060006127106009548c6119b29190615196565b6119bc9190615207565b90507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166323b872dd33308e6040518463ffffffff1660e01b8152600401611a1b939291906148a4565b6020604051808303816000875af1158015611a3a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a5e91906148f0565b5082600d6000828254611a719190613bc9565b9250508190555081600c6000828254611a8a9190613bc9565b925050819055506000851115611b26577f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166342966c68866040518263ffffffff1660e01b8152600401611af39190613dbf565b600060405180830381600087803b158015611b0d57600080fd5b505af1158015611b21573d6000803e3d6000fd5b505050505b6000841115611bf1577f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663a9059cbb601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16866040518363ffffffff1660e01b8152600401611bac929190613c4d565b6020604051808303816000875af1158015611bcb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bef91906148f0565b505b6000811115611cbc577f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663a9059cbb600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836040518363ffffffff1660e01b8152600401611c77929190613c4d565b6020604051808303816000875af1158015611c96573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cba91906148f0565b505b60008d148015611ccc575060008c115b15611d2f57611cdb338d613946565b3373ffffffffffffffffffffffffffffffffffffffff167fcf1d432606e0ee6a23fc32ce701ac36c9897204278c35ac9d65112344b20991760018e8b604051611d2693929190615238565b60405180910390a25b60018d03611d88573373ffffffffffffffffffffffffffffffffffffffff167f759647c6e0ef64ba58a247443390ca1ca127a0e56c0ca73b8e7adb81cdea686f8d8a604051611d7f92919061526f565b60405180910390a25b60028d03611de1573373ffffffffffffffffffffffffffffffffffffffff167f064c6c90fdf69cdb269f2989d2db58656f9f0975deb0a85bc6c3e85ce03849368d8a604051611dd892919061526f565b60405180910390a25b60038d03611e3a573373ffffffffffffffffffffffffffffffffffffffff167f9841530569e3c231047b6033deea4a0cdaa8030ad02d8995de67995def9af0388d8a604051611e3192919061526f565b60405180910390a25b60048d03611e93573373ffffffffffffffffffffffffffffffffffffffff167fc41f685bb934317e998f0d450848c2a5c23e6e7d12b456808ffd9ddbc094e9ed8d8a604051611e8a92919061526f565b60405180910390a25b50505050505050505050505050565b600d5481565b601160159054906101000a900460ff1615611ef8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611eef906152e4565b60405180910390fd5b80601560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015611f7a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611f7190615350565b60405180910390fd5b80601560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611fc99190614ab7565b925050819055507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663f242432a30846001856040518563ffffffff1660e01b815260040161203094939291906153a4565b600060405180830381600087803b15801561204a57600080fd5b505af115801561205e573d6000803e3d6000fd5b505050503373ffffffffffffffffffffffffffffffffffffffff167ff279e6a1f5e320cca91135676d9cb6e44ca8a08c0b88342bcdb1144f6511b5686001836040516120ab92919061526f565b60405180910390a25050565b7ff1b411d6abb365480ac902cc153c45e9ded5847a2265ce6d01945d253edb6bc76120e181613640565b81601160156101000a81548160ff0219169083151502179055505050565b7ff1b411d6abb365480ac902cc153c45e9ded5847a2265ce6d01945d253edb6bc781565b601160149054906101000a900460ff1681565b600b5481565b7ff1b411d6abb365480ac902cc153c45e9ded5847a2265ce6d01945d253edb6bc761216681613640565b601160149054906101000a900460ff166121b5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016121ac90615448565b60405180910390fd5b825184511480156121c7575081518351145b612206576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016121fd906154b4565b60405180910390fd5b60005b845181101561257a5783818151811061222557612224614bc3565b5b602002602001015147101561226f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161226690615520565b60405180910390fd5b82818151811061228257612281614bc3565b5b60200260200101517f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016122e391906142d5565b602060405180830381865afa158015612300573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612324919061495b565b1015612365576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161235c9061558c565b60405180910390fd5b600084828151811061237a57612379614bc3565b5b6020026020010151111561247057600085828151811061239d5761239c614bc3565b5b6020026020010151905060008173ffffffffffffffffffffffffffffffffffffffff168684815181106123d3576123d2614bc3565b5b60200260200101516040516123e790614a36565b60006040518083038185875af1925050503d8060008114612424576040519150601f19603f3d011682016040523d82523d6000602084013e612429565b606091505b505090508061246d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161246490614a97565b60405180910390fd5b50505b600083828151811061248557612484614bc3565b5b60200260200101511115612567577f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663a9059cbb8683815181106124e2576124e1614bc3565b5b60200260200101518584815181106124fd576124fc614bc3565b5b60200260200101516040518363ffffffff1660e01b8152600401612522929190613c4d565b6020604051808303816000875af1158015612541573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061256591906148f0565b505b808061257290614c5e565b915050612209565b5050505050565b7fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c2177581565b837f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663dd62ed3e33306040518363ffffffff1660e01b815260040161260192919061491d565b602060405180830381865afa15801561261e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612642919061495b565b1015612683576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161267a90614edc565b60405180910390fd5b601160149054906101000a900460ff16156126d3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016126ca90614b37565b60405180910390fd5b600a54836126e19190613bc9565b4210612722576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161271990614fb4565b60405180910390fd5b6014600083815260200190815260200160002060009054906101000a900460ff1615612783576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161277a90615020565b60405180910390fd5b60006127be3388888888886040516020016127a3969594939291906155ac565b60405160208183030381529060405280519060200120613891565b905061280b81837f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166139039092919063ffffffff16565b61284a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161284190615176565b60405180910390fd5b60016014600085815260200190815260200160002060006101000a81548160ff0219169083151502179055507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166323b872dd33601160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16886040518463ffffffff1660e01b81526004016128f5939291906148a4565b6020604051808303816000875af1158015612914573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061293891906148f0565b503373ffffffffffffffffffffffffffffffffffffffff167f13f135658b67258df1952b1efe89331bc59bde07499073b16d5f4908012dce5b88888887604051612985949392919061561c565b60405180910390a250505050505050565b60065481565b7f000000000000000000000000000000000000000000000000000000000000000081565b600080600084815260200190815260200160002060000160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b73430000000000000000000000000000000000000281565b6000801b612a4f81613640565b601160149054906101000a900460ff16612a9e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612a9590615448565b60405180910390fd5b60004711612ae1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612ad8906156ad565b60405180910390fd5b600033905060008173ffffffffffffffffffffffffffffffffffffffff1647604051612b0c90614a36565b60006040518083038185875af1925050503d8060008114612b49576040519150601f19603f3d011682016040523d82523d6000602084013e612b4e565b606091505b5050905080612b92576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612b8990614a97565b60405180910390fd5b505050565b601160149054906101000a900460ff1615612be7576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612bde90614b37565b60405180910390fd5b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663f242432a33306001856040518563ffffffff1660e01b8152600401612c4794939291906153a4565b600060405180830381600087803b158015612c6157600080fd5b505af1158015612c75573d6000803e3d6000fd5b5050505080601560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254612cc89190613bc9565b925050819055508173ffffffffffffffffffffffffffffffffffffffff167f90890809c654f11d6e72a28fa60149770a0d11ec6c92319d6ceb2bb0a4ea1a15600183604051612d1892919061526f565b60405180910390a25050565b601160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b7fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c21775612d7481613640565b85600e60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555084600f60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555083601060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555082601160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555081600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550505050505050565b6000801b81565b7fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c21775612ef281613640565b86600a81905550856004819055508460058190555083600681905550826007819055508160098190555083838387612710612f2d9190614ab7565b612f379190614ab7565b612f419190614ab7565b612f4b9190614ab7565b60088190555050505050505050565b600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b7ff1b411d6abb365480ac902cc153c45e9ded5847a2265ce6d01945d253edb6bc7612faa81613640565b6000600267ffffffffffffffff811115612fc757612fc6614057565b5b604051908082528060200260200182016040528015612ff55781602001602082028036833780820191505090505b5090507f00000000000000000000000000000000000000000000000000000000000000008160008151811061302d5761302c614bc3565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa1580156130d4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130f891906156e2565b8160018151811061310c5761310b614bc3565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250506000600d5490507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663095ea7b3600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836040518363ffffffff1660e01b81526004016131ca929190613c4d565b6020604051808303816000875af11580156131e9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061320d91906148f0565b506000600d81905550600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663791ac94782868530426040518663ffffffff1660e01b815260040161327995949392919061570f565b600060405180830381600087803b15801561329357600080fd5b505af11580156132a7573d6000803e3d6000fd5b5050505050505050565b7fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c217756132db81613640565b600073ffffffffffffffffffffffffffffffffffffffff16600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff160361336c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401613363906157b5565b60405180910390fd5b811561342c5773430000000000000000000000000000000000000273ffffffffffffffffffffffffffffffffffffffff1663662aa11d30600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040518363ffffffff1660e01b81526004016133e392919061491d565b6020604051808303816000875af1158015613402573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613426919061495b565b506134e2565b73430000000000000000000000000000000000000273ffffffffffffffffffffffffffffffffffffffff1663954fa5ee30600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040518363ffffffff1660e01b815260040161349d92919061491d565b6020604051808303816000875af11580156134bc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134e0919061495b565b505b5050565b60075481565b60055481565b601160159054906101000a900460ff1681565b7f000000000000000000000000000000000000000000000000000000000000000081565b600c5481565b60095481565b60085481565b61354482610d38565b61354d81613640565b613557838361374d565b50505050565b60156020528060005260406000206000915090505481565b60007ff23a6e612e1ff4830e658fe43f4e3cb4a5f8170bd5d9e69fb5d7a7fa9e4fdf9790509695505050505050565b60035481565b600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60045481565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b6136518161364c613745565b613ab8565b50565b600061366083836129c0565b61373a57600160008085815260200190815260200160002060000160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506136d7613745565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16847f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a46001905061373f565b600090505b92915050565b600033905090565b600061375983836129c0565b1561383457600080600085815260200190815260200160002060000160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506137d1613745565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16847ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a460019050613839565b600090505b92915050565b600080600090505b825181101561388b5782818151811061386357613862614bc3565b5b6020026020010151826138769190613bc9565b9150808061388390614c5e565b915050613847565b50919050565b6000806040518060400160405280601c81526020017f19457468657265756d205369676e6564204d6573736167653a0a3332000000008152509050600081846040516020016138e192919061585c565b6040516020818303038152906040528051906020012090508092505050919050565b600061390f8383613b09565b73ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161490509392505050565b60008103613989576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401613980906158d0565b60405180910390fd5b6003548111156139ce576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016139c59061593c565b60405180910390fd5b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663731133e9306001846040518463ffffffff1660e01b8152600401613a2c9392919061595c565b600060405180830381600087803b158015613a4657600080fd5b505af1158015613a5a573d6000803e3d6000fd5b5050505080601560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254613aad9190613bc9565b925050819055505050565b613ac282826129c0565b613b055780826040517fe2517d3f000000000000000000000000000000000000000000000000000000008152600401613afc9291906159a6565b60405180910390fd5b5050565b60006041825114613b1957600080fd5b60008060006020850151915060408501519050606085015160001a925060018684848460405160008152602001604052604051613b5994939291906159eb565b6020604051602081039080840390855afa158015613b7b573d6000803e3d6000fd5b50505060206040510351935050505092915050565b6000819050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000613bd482613b90565b9150613bdf83613b90565b9250828201905080821115613bf757613bf6613b9a565b5b92915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000613c2882613bfd565b9050919050565b613c3881613c1d565b82525050565b613c4781613b90565b82525050565b6000604082019050613c626000830185613c2f565b613c6f6020830184613c3e565b9392505050565b6000604051905090565b600080fd5b600080fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b613cbf81613c8a565b8114613cca57600080fd5b50565b600081359050613cdc81613cb6565b92915050565b600060208284031215613cf857613cf7613c80565b5b6000613d0684828501613ccd565b91505092915050565b60008115159050919050565b613d2481613d0f565b82525050565b6000602082019050613d3f6000830184613d1b565b92915050565b6000819050919050565b6000613d6a613d65613d6084613bfd565b613d45565b613bfd565b9050919050565b6000613d7c82613d4f565b9050919050565b6000613d8e82613d71565b9050919050565b613d9e81613d83565b82525050565b6000602082019050613db96000830184613d95565b92915050565b6000602082019050613dd46000830184613c3e565b92915050565b6000819050919050565b613ded81613dda565b8114613df857600080fd5b50565b600081359050613e0a81613de4565b92915050565b600060208284031215613e2657613e25613c80565b5b6000613e3484828501613dfb565b91505092915050565b613e4681613dda565b82525050565b6000602082019050613e616000830184613e3d565b92915050565b613e7081613c1d565b8114613e7b57600080fd5b50565b600081359050613e8d81613e67565b92915050565b600060208284031215613ea957613ea8613c80565b5b6000613eb784828501613e7e565b91505092915050565b613ec981613b90565b8114613ed457600080fd5b50565b600081359050613ee681613ec0565b92915050565b600060208284031215613f0257613f01613c80565b5b6000613f1084828501613ed7565b91505092915050565b60008060408385031215613f3057613f2f613c80565b5b6000613f3e85828601613dfb565b9250506020613f4f85828601613e7e565b9150509250929050565b613f6281613d0f565b8114613f6d57600080fd5b50565b600081359050613f7f81613f59565b92915050565b600060208284031215613f9b57613f9a613c80565b5b6000613fa984828501613f70565b91505092915050565b600080600060608486031215613fcb57613fca613c80565b5b6000613fd986828701613ed7565b9350506020613fea86828701613ed7565b9250506040613ffb86828701613ed7565b9150509250925092565b600061401082613d71565b9050919050565b61402081614005565b82525050565b600060208201905061403b6000830184614017565b92915050565b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b61408f82614046565b810181811067ffffffffffffffff821117156140ae576140ad614057565b5b80604052505050565b60006140c1613c76565b90506140cd8282614086565b919050565b600067ffffffffffffffff8211156140ed576140ec614057565b5b602082029050602081019050919050565b600080fd5b6000614116614111846140d2565b6140b7565b90508083825260208201905060208402830185811115614139576141386140fe565b5b835b81811015614162578061414e8882613e7e565b84526020840193505060208101905061413b565b5050509392505050565b600082601f83011261418157614180614041565b5b8135614191848260208601614103565b91505092915050565b600067ffffffffffffffff8211156141b5576141b4614057565b5b602082029050602081019050919050565b60006141d96141d48461419a565b6140b7565b905080838252602082019050602084028301858111156141fc576141fb6140fe565b5b835b8181101561422557806142118882613ed7565b8452602084019350506020810190506141fe565b5050509392505050565b600082601f83011261424457614243614041565b5b81356142548482602086016141c6565b91505092915050565b6000806040838503121561427457614273613c80565b5b600083013567ffffffffffffffff81111561429257614291613c85565b5b61429e8582860161416c565b925050602083013567ffffffffffffffff8111156142bf576142be613c85565b5b6142cb8582860161422f565b9150509250929050565b60006020820190506142ea6000830184613c2f565b92915050565b600080fd5b600067ffffffffffffffff8211156143105761430f614057565b5b61431982614046565b9050602081019050919050565b82818337600083830152505050565b6000614348614343846142f5565b6140b7565b905082815260208101848484011115614364576143636142f0565b5b61436f848285614326565b509392505050565b600082601f83011261438c5761438b614041565b5b813561439c848260208601614335565b91505092915050565b600080600080600080600060e0888a0312156143c4576143c3613c80565b5b60006143d28a828b01613ed7565b97505060206143e38a828b01613ed7565b96505060406143f48a828b01613ed7565b95505060606144058a828b01613ed7565b94505060806144168a828b01613ed7565b93505060a06144278a828b01613ed7565b92505060c088013567ffffffffffffffff81111561444857614447613c85565b5b6144548a828b01614377565b91505092959891949750929550565b6000806040838503121561447a57614479613c80565b5b600061448885828601613e7e565b925050602061449985828601613ed7565b9150509250929050565b6000806000606084860312156144bc576144bb613c80565b5b600084013567ffffffffffffffff8111156144da576144d9613c85565b5b6144e68682870161416c565b935050602084013567ffffffffffffffff81111561450757614506613c85565b5b6145138682870161422f565b925050604084013567ffffffffffffffff81111561453457614533613c85565b5b6145408682870161422f565b9150509250925092565b60008060008060008060c0878903121561456757614566613c80565b5b600061457589828a01613ed7565b965050602061458689828a01613ed7565b955050604061459789828a01613ed7565b94505060606145a889828a01613ed7565b93505060806145b989828a01613ed7565b92505060a087013567ffffffffffffffff8111156145da576145d9613c85565b5b6145e689828a01614377565b9150509295509295509295565b60006145fe82613d71565b9050919050565b61460e816145f3565b82525050565b60006020820190506146296000830184614605565b92915050565b600080600080600060a0868803121561464b5761464a613c80565b5b600061465988828901613e7e565b955050602061466a88828901613e7e565b945050604061467b88828901613e7e565b935050606061468c88828901613e7e565b925050608061469d88828901613e7e565b9150509295509295909350565b60008060008060008060c087890312156146c7576146c6613c80565b5b60006146d589828a01613ed7565b96505060206146e689828a01613ed7565b95505060406146f789828a01613ed7565b945050606061470889828a01613ed7565b935050608061471989828a01613ed7565b92505060a061472a89828a01613ed7565b9150509295509295509295565b600061474282613d4f565b9050919050565b600061475482614737565b9050919050565b61476481614749565b82525050565b600060208201905061477f600083018461475b565b92915050565b600080fd5b60008083601f8401126147a05761479f614041565b5b8235905067ffffffffffffffff8111156147bd576147bc614785565b5b6020830191508360018202830111156147d9576147d86140fe565b5b9250929050565b60008060008060008060a087890312156147fd576147fc613c80565b5b600061480b89828a01613e7e565b965050602061481c89828a01613e7e565b955050604061482d89828a01613ed7565b945050606061483e89828a01613ed7565b935050608087013567ffffffffffffffff81111561485f5761485e613c85565b5b61486b89828a0161478a565b92509250509295509295509295565b61488381613c8a565b82525050565b600060208201905061489e600083018461487a565b92915050565b60006060820190506148b96000830186613c2f565b6148c66020830185613c2f565b6148d36040830184613c3e565b949350505050565b6000815190506148ea81613f59565b92915050565b60006020828403121561490657614905613c80565b5b6000614914848285016148db565b91505092915050565b60006040820190506149326000830185613c2f565b61493f6020830184613c2f565b9392505050565b60008151905061495581613ec0565b92915050565b60006020828403121561497157614970613c80565b5b600061497f84828501614946565b91505092915050565b600082825260208201905092915050565b7f4e65656420746f2073656e64206d6f7265206574686572000000000000000000600082015250565b60006149cf601783614988565b91506149da82614999565b602082019050919050565b600060208201905081810360008301526149fe816149c2565b9050919050565b600081905092915050565b50565b6000614a20600083614a05565b9150614a2b82614a10565b600082019050919050565b6000614a4182614a13565b9150819050919050565b7f4661696c656420746f2073656e64204574686572000000000000000000000000600082015250565b6000614a81601483614988565b9150614a8c82614a4b565b602082019050919050565b60006020820190508181036000830152614ab081614a74565b9050919050565b6000614ac282613b90565b9150614acd83613b90565b9250828203905081811115614ae557614ae4613b9a565b5b92915050565b7f47616d6520697320636c6f736564000000000000000000000000000000000000600082015250565b6000614b21600e83614988565b9150614b2c82614aeb565b602082019050919050565b60006020820190508181036000830152614b5081614b14565b9050919050565b7f496e707574206172726179206973206e6f74206d617463680000000000000000600082015250565b6000614b8d601883614988565b9150614b9882614b57565b602082019050919050565b60006020820190508181036000830152614bbc81614b80565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f496e76616c696420616d6f756e7420746f206275726e00000000000000000000600082015250565b6000614c28601683614988565b9150614c3382614bf2565b602082019050919050565b60006020820190508181036000830152614c5781614c1b565b9050919050565b6000614c6982613b90565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203614c9b57614c9a613b9a565b5b600182019050919050565b6000606082019050614cbb6000830186613c2f565b614cc86020830185613c3e565b614cd56040830184613c3e565b949350505050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b614d1281613c1d565b82525050565b6000614d248383614d09565b60208301905092915050565b6000602082019050919050565b6000614d4882614cdd565b614d528185614ce8565b9350614d5d83614cf9565b8060005b83811015614d8e578151614d758882614d18565b9750614d8083614d30565b925050600181019050614d61565b5085935050505092915050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b614dd081613b90565b82525050565b6000614de28383614dc7565b60208301905092915050565b6000602082019050919050565b6000614e0682614d9b565b614e108185614da6565b9350614e1b83614db7565b8060005b83811015614e4c578151614e338882614dd6565b9750614e3e83614dee565b925050600181019050614e1f565b5085935050505092915050565b60006040820190508181036000830152614e738185614d3d565b90508181036020830152614e878184614dfb565b90509392505050565b7f4572726f72000000000000000000000000000000000000000000000000000000600082015250565b6000614ec6600583614988565b9150614ed182614e90565b602082019050919050565b60006020820190508181036000830152614ef581614eb9565b9050919050565b7f496e76616c6964206c617374206275792074696d650000000000000000000000600082015250565b6000614f32601583614988565b9150614f3d82614efc565b602082019050919050565b60006020820190508181036000830152614f6181614f25565b9050919050565b7f496e76616c69642074696d657374616d70000000000000000000000000000000600082015250565b6000614f9e601183614988565b9150614fa982614f68565b602082019050919050565b60006020820190508181036000830152614fcd81614f91565b9050919050565b7f4e6f6e6365206973207573656400000000000000000000000000000000000000600082015250565b600061500a600d83614988565b915061501582614fd4565b602082019050919050565b6000602082019050818103600083015261503981614ffd565b9050919050565b60008160601b9050919050565b600061505882615040565b9050919050565b600061506a8261504d565b9050919050565b61508261507d82613c1d565b61505f565b82525050565b6000819050919050565b6150a361509e82613b90565b615088565b82525050565b60006150b5828a615071565b6014820191506150c58289615092565b6020820191506150d58288615092565b6020820191506150e58287615092565b6020820191506150f58286615092565b6020820191506151058285615092565b6020820191506151158284615092565b60208201915081905098975050505050505050565b7f496e76616c6964207369676e6174757265000000000000000000000000000000600082015250565b6000615160601183614988565b915061516b8261512a565b602082019050919050565b6000602082019050818103600083015261518f81615153565b9050919050565b60006151a182613b90565b91506151ac83613b90565b92508282026151ba81613b90565b915082820484148315176151d1576151d0613b9a565b5b5092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b600061521282613b90565b915061521d83613b90565b92508261522d5761522c6151d8565b5b828204905092915050565b600060608201905061524d6000830186613c3e565b61525a6020830185613c3e565b6152676040830184613c3e565b949350505050565b60006040820190506152846000830185613c3e565b6152916020830184613c3e565b9392505050565b7f4e4654206973206c6f636b656400000000000000000000000000000000000000600082015250565b60006152ce600d83614988565b91506152d982615298565b602082019050919050565b600060208201905081810360008301526152fd816152c1565b9050919050565b7f496e73756666696369656e742062616c616e6365000000000000000000000000600082015250565b600061533a601483614988565b915061534582615304565b602082019050919050565b600060208201905081810360008301526153698161532d565b9050919050565b600082825260208201905092915050565b600061538e600083615370565b915061539982614a10565b600082019050919050565b600060a0820190506153b96000830187613c2f565b6153c66020830186613c2f565b6153d36040830185613c3e565b6153e06060830184613c3e565b81810360808301526153f181615381565b905095945050505050565b7f47616d65206973206e6f7420636c6f7365640000000000000000000000000000600082015250565b6000615432601283614988565b915061543d826153fc565b602082019050919050565b6000602082019050818103600083015261546181615425565b9050919050565b7f496e76616c696420696e707574206172726179206c656e677468000000000000600082015250565b600061549e601a83614988565b91506154a982615468565b602082019050919050565b600060208201905081810360008301526154cd81615491565b9050919050565b7f4f766572206574682062616c616e636500000000000000000000000000000000600082015250565b600061550a601083614988565b9150615515826154d4565b602082019050919050565b60006020820190508181036000830152615539816154fd565b9050919050565b7f4f76657220746f6b656e2062616c616e63650000000000000000000000000000600082015250565b6000615576601283614988565b915061558182615540565b602082019050919050565b600060208201905081810360008301526155a581615569565b9050919050565b60006155b88289615071565b6014820191506155c88288615092565b6020820191506155d88287615092565b6020820191506155e88286615092565b6020820191506155f88285615092565b6020820191506156088284615092565b602082019150819050979650505050505050565b60006080820190506156316000830187613c3e565b61563e6020830186613c3e565b61564b6040830185613c3e565b6156586060830184613c3e565b95945050505050565b7f4e6f7468696e6720746f20776974686472617700000000000000000000000000600082015250565b6000615697601383614988565b91506156a282615661565b602082019050919050565b600060208201905081810360008301526156c68161568a565b9050919050565b6000815190506156dc81613e67565b92915050565b6000602082840312156156f8576156f7613c80565b5b6000615706848285016156cd565b91505092915050565b600060a0820190506157246000830188613c3e565b6157316020830187613c3e565b81810360408301526157438186614d3d565b90506157526060830185613c2f565b61575f6080830184613c3e565b9695505050505050565b7f676173466565206973206e6f7420736574000000000000000000000000000000600082015250565b600061579f601183614988565b91506157aa82615769565b602082019050919050565b600060208201905081810360008301526157ce81615792565b9050919050565b600081519050919050565b60005b838110156157fe5780820151818401526020810190506157e3565b60008484015250505050565b6000615815826157d5565b61581f8185614a05565b935061582f8185602086016157e0565b80840191505092915050565b6000819050919050565b61585661585182613dda565b61583b565b82525050565b6000615868828561580a565b91506158748284615845565b6020820191508190509392505050565b7f496e76616c696420616d6f756e74000000000000000000000000000000000000600082015250565b60006158ba600e83614988565b91506158c582615884565b602082019050919050565b600060208201905081810360008301526158e9816158ad565b9050919050565b7f4d61782070657220626174636820726561636865640000000000000000000000600082015250565b6000615926601583614988565b9150615931826158f0565b602082019050919050565b6000602082019050818103600083015261595581615919565b9050919050565b60006080820190506159716000830186613c2f565b61597e6020830185613c3e565b61598b6040830184613c3e565b818103606083015261599c81615381565b9050949350505050565b60006040820190506159bb6000830185613c2f565b6159c86020830184613e3d565b9392505050565b600060ff82169050919050565b6159e5816159cf565b82525050565b6000608082019050615a006000830187613e3d565b615a0d60208301866159dc565b615a1a6040830185613e3d565b615a276060830184613e3d565b9594505050505056fea2646970667358221220f34f4cf73b00cee009fbfe4f8dd02cc352b4ebe021aa38ef651bd6b9c67be9d364736f6c63430008140033000000000000000000000000d65934f0e7d543d10b070ed1b3f62ca9b7e0c4c7000000000000000000000000d65934f0e7d543d10b070ed1b3f62ca9b7e0c4c7000000000000000000000000dc678248e99a5a7aee93342af067ea8bded520ec00000000000000000000000063a37fbd924c6d5e2c2a7fdfddbd079a0837c675000000000000000000000000f11afd83cd6b42d31961284498ad6a44ca0c0ae8000000000000000000000000e6a062fba3918376500a602c800b1e03074204570000000000000000000000009c910cb24ed6f9d248f1b3f1492ab887cdccc9730000000000000000000000002536fe9ab3f511540f2f9e2ec2a805005c3dd800
Deployed Bytecode
0x6080604052600436106103035760003560e01c80638d9d548211610190578063bc90c273116100dc578063d2d93f9011610095578063f23a6e611161006f578063f23a6e6114610bd5578063f72fc7cb14610c12578063fcd2117d14610c3d578063fdbefb5914610c685761035c565b8063d2d93f9014610b44578063d547741f14610b6f578063ede6ec5d14610b985761035c565b8063bc90c27314610a42578063bed9985014610a6d578063bee2660914610a98578063c020b08c14610ac3578063c0be0c0b14610aee578063c957497514610b195761035c565b80639f87295011610149578063ad6190e111610123578063ad6190e11461099c578063ad85e3bd146109c5578063b28805f4146109f0578063b943cbbb14610a195761035c565b80639f8729501461091d5780639fc0db5614610948578063a217fddf146109715761035c565b80638d9d54821461081f57806390824c5b1461084a57806391d148541461087557806397d75776146108b257806398795ee6146108dd5780639b5b9b18146108f45761035c565b806347ccca021161024f57806362af5693116102085780636e3e40d9116101e25780636e3e40d91461077757806373a58223146107a257806375b238fc146107cb5780638af02ab1146107f65761035c565b806362af5693146106f8578063634252dc146107215780636d99ef461461074c5761035c565b806347ccca02146105fc5780634c57207d146106275780634cb8e760146106505780635b262a771461067b57806360174693146106a45780636088e93a146106cf5761035c565b80632f2ff15d116102bc578063409a33ce11610296578063409a33ce1461056157806341a21bcf1461057857806346816290146105a3578063470e3ec9146105bf5761035c565b80632f2ff15d146104e657806336568abe1461050f578063368b28bd146105385761035c565b806301ffc9a7146103b05780631694505e146103ed57806317d70f7c14610418578063248a9ca3146104435780632614160e146104805780632841a143146104bd5761035c565b3661035c5734600b600082825461031a9190613bc9565b925050819055507f88a5966d370b9919b20f3e2c13ff65706f196a4e32cc2c12bf57088f885258743334604051610352929190613c4d565b60405180910390a1005b34600b600082825461036e9190613bc9565b925050819055507f88a5966d370b9919b20f3e2c13ff65706f196a4e32cc2c12bf57088f8852587433346040516103a6929190613c4d565b60405180910390a1005b3480156103bc57600080fd5b506103d760048036038101906103d29190613ce2565b610c93565b6040516103e49190613d2a565b60405180910390f35b3480156103f957600080fd5b50610402610d0d565b60405161040f9190613da4565b60405180910390f35b34801561042457600080fd5b5061042d610d33565b60405161043a9190613dbf565b60405180910390f35b34801561044f57600080fd5b5061046a60048036038101906104659190613e10565b610d38565b6040516104779190613e4c565b60405180910390f35b34801561048c57600080fd5b506104a760048036038101906104a29190613e93565b610d57565b6040516104b49190613dbf565b60405180910390f35b3480156104c957600080fd5b506104e460048036038101906104df9190613eec565b610d6f565b005b3480156104f257600080fd5b5061050d60048036038101906105089190613f19565b610e2c565b005b34801561051b57600080fd5b5061053660048036038101906105319190613f19565b610e4e565b005b34801561054457600080fd5b5061055f600480360381019061055a9190613f85565b610ec9565b005b34801561056d57600080fd5b50610576610f11565b005b34801561058457600080fd5b5061058d610ff3565b60405161059a9190613dbf565b60405180910390f35b6105bd60048036038101906105b89190613fb2565b610ff9565b005b3480156105cb57600080fd5b506105e660048036038101906105e19190613eec565b611267565b6040516105f39190613dbf565b60405180910390f35b34801561060857600080fd5b5061061161127f565b60405161061e9190614026565b60405180910390f35b34801561063357600080fd5b5061064e6004803603810190610649919061425d565b6112a3565b005b34801561065c57600080fd5b506106656115bd565b60405161067291906142d5565b60405180910390f35b34801561068757600080fd5b506106a2600480360381019061069d91906143a5565b6115e3565b005b3480156106b057600080fd5b506106b9611ea2565b6040516106c69190613dbf565b60405180910390f35b3480156106db57600080fd5b506106f660048036038101906106f19190614463565b611ea8565b005b34801561070457600080fd5b5061071f600480360381019061071a9190613f85565b6120b7565b005b34801561072d57600080fd5b506107366120ff565b6040516107439190613e4c565b60405180910390f35b34801561075857600080fd5b50610761612123565b60405161076e9190613d2a565b60405180910390f35b34801561078357600080fd5b5061078c612136565b6040516107999190613dbf565b60405180910390f35b3480156107ae57600080fd5b506107c960048036038101906107c491906144a3565b61213c565b005b3480156107d757600080fd5b506107e0612581565b6040516107ed9190613e4c565b60405180910390f35b34801561080257600080fd5b5061081d6004803603810190610818919061454a565b6125a5565b005b34801561082b57600080fd5b50610834612996565b6040516108419190613dbf565b60405180910390f35b34801561085657600080fd5b5061085f61299c565b60405161086c91906142d5565b60405180910390f35b34801561088157600080fd5b5061089c60048036038101906108979190613f19565b6129c0565b6040516108a99190613d2a565b60405180910390f35b3480156108be57600080fd5b506108c7612a2a565b6040516108d49190614614565b60405180910390f35b3480156108e957600080fd5b506108f2612a42565b005b34801561090057600080fd5b5061091b60048036038101906109169190614463565b612b97565b005b34801561092957600080fd5b50610932612d24565b60405161093f91906142d5565b60405180910390f35b34801561095457600080fd5b5061096f600480360381019061096a919061462f565b612d4a565b005b34801561097d57600080fd5b50610986612ec1565b6040516109939190613e4c565b60405180910390f35b3480156109a857600080fd5b506109c360048036038101906109be91906146aa565b612ec8565b005b3480156109d157600080fd5b506109da612f5a565b6040516109e791906142d5565b60405180910390f35b3480156109fc57600080fd5b50610a176004803603810190610a129190613eec565b612f80565b005b348015610a2557600080fd5b50610a406004803603810190610a3b9190613f85565b6132b1565b005b348015610a4e57600080fd5b50610a576134e6565b604051610a649190613dbf565b60405180910390f35b348015610a7957600080fd5b50610a826134ec565b604051610a8f9190613dbf565b60405180910390f35b348015610aa457600080fd5b50610aad6134f2565b604051610aba9190613d2a565b60405180910390f35b348015610acf57600080fd5b50610ad8613505565b604051610ae5919061476a565b60405180910390f35b348015610afa57600080fd5b50610b03613529565b604051610b109190613dbf565b60405180910390f35b348015610b2557600080fd5b50610b2e61352f565b604051610b3b9190613dbf565b60405180910390f35b348015610b5057600080fd5b50610b59613535565b604051610b669190613dbf565b60405180910390f35b348015610b7b57600080fd5b50610b966004803603810190610b919190613f19565b61353b565b005b348015610ba457600080fd5b50610bbf6004803603810190610bba9190613e93565b61355d565b604051610bcc9190613dbf565b60405180910390f35b348015610be157600080fd5b50610bfc6004803603810190610bf791906147e0565b613575565b604051610c099190614889565b60405180910390f35b348015610c1e57600080fd5b50610c276135a4565b604051610c349190613dbf565b60405180910390f35b348015610c4957600080fd5b50610c526135aa565b604051610c5f91906142d5565b60405180910390f35b348015610c7457600080fd5b50610c7d6135d0565b604051610c8a9190613dbf565b60405180910390f35b60007f7965db0b000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480610d065750610d05826135d6565b5b9050919050565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600181565b6000806000838152602001908152602001600020600101549050919050565b60136020528060005260406000206000915090505481565b7f000000000000000000000000e6a062fba3918376500a602c800b1e030742045773ffffffffffffffffffffffffffffffffffffffff166323b872dd3330846040518463ffffffff1660e01b8152600401610dcc939291906148a4565b6020604051808303816000875af1158015610deb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e0f91906148f0565b5080600c6000828254610e229190613bc9565b9250508190555050565b610e3582610d38565b610e3e81613640565b610e488383613654565b50505050565b610e56613745565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610eba576040517f6697b23200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610ec4828261374d565b505050565b7ff1b411d6abb365480ac902cc153c45e9ded5847a2265ce6d01945d253edb6bc7610ef381613640565b81601160146101000a81548160ff0219169083151502179055505050565b7fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c21775610f3b81613640565b73430000000000000000000000000000000000000273ffffffffffffffffffffffffffffffffffffffff1663860043b630600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040518363ffffffff1660e01b8152600401610fac92919061491d565b6020604051808303816000875af1158015610fcb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fef919061495b565b5050565b600a5481565b60008183856110089190613bc9565b6110129190613bc9565b905080341015611057576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161104e906149e5565b60405180910390fd5b82826110639190613bc9565b600b60008282546110749190613bc9565b92505081905550600084111561115a576000600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905060008173ffffffffffffffffffffffffffffffffffffffff16866040516110d190614a36565b60006040518083038185875af1925050503d806000811461110e576040519150601f19603f3d011682016040523d82523d6000602084013e611113565b606091505b5050905080611157576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161114e90614a97565b60405180910390fd5b50505b600081346111689190614ab7565b9050600081111561122757600033905060008173ffffffffffffffffffffffffffffffffffffffff168360405161119e90614a36565b60006040518083038185875af1925050503d80600081146111db576040519150601f19603f3d011682016040523d82523d6000602084013e6111e0565b606091505b5050905080611224576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161121b90614a97565b60405180910390fd5b50505b7f9f15a78649bd76613c4a49ca8a67ae948862a0eee791ca3d0380853f9afa624f3383604051611258929190613c4d565b60405180910390a15050505050565b60126020528060005260406000206000915090505481565b7f000000000000000000000000f11afd83cd6b42d31961284498ad6a44ca0c0ae881565b7ff1b411d6abb365480ac902cc153c45e9ded5847a2265ce6d01945d253edb6bc76112cd81613640565b601160149054906101000a900460ff161561131d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161131490614b37565b60405180910390fd5b8151835114611361576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161135890614ba3565b60405180910390fd5b60005b8351811015611436578281815181106113805761137f614bc3565b5b60200260200101516015600086848151811061139f5761139e614bc3565b5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015611423576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161141a90614c3e565b60405180910390fd5b808061142e90614c5e565b915050611364565b5060006114428361383f565b905060005b84518110156114ed5783818151811061146357611462614bc3565b5b60200260200101516015600087848151811061148257611481614bc3565b5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546114d39190614ab7565b9250508190555080806114e590614c5e565b915050611447565b507f000000000000000000000000f11afd83cd6b42d31961284498ad6a44ca0c0ae873ffffffffffffffffffffffffffffffffffffffff1663f5298aca306001846040518463ffffffff1660e01b815260040161154c93929190614ca6565b600060405180830381600087803b15801561156657600080fd5b505af115801561157a573d6000803e3d6000fd5b505050507f5ba5896aa4cc7b0ad558b01a8632c8d8a65dd5dee5394b2c2b78c3ddc5f3265384846040516115af929190614e59565b60405180910390a150505050565b601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b847f000000000000000000000000e6a062fba3918376500a602c800b1e030742045773ffffffffffffffffffffffffffffffffffffffff1663dd62ed3e33306040518363ffffffff1660e01b815260040161163f92919061491d565b602060405180830381865afa15801561165c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611680919061495b565b10156116c1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116b890614edc565b60405180910390fd5b601160149054906101000a900460ff1615611711576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161170890614b37565b60405180910390fd5b83601260008981526020019081526020016000205414611766576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161175d90614f48565b60405180910390fd5b600a54836117749190613bc9565b42106117b5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016117ac90614fb4565b60405180910390fd5b6014600083815260200190815260200160002060009054906101000a900460ff1615611816576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161180d90615020565b60405180910390fd5b60006118533389898989898960405160200161183897969594939291906150a9565b60405160208183030381529060405280519060200120613891565b90506118a081837f00000000000000000000000063a37fbd924c6d5e2c2a7fdfddbd079a0837c67573ffffffffffffffffffffffffffffffffffffffff166139039092919063ffffffff16565b6118df576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118d690615176565b60405180910390fd5b60016014600085815260200190815260200160002060006101000a81548160ff02191690831515021790555042601260008a8152602001908152602001600020819055506000612710600554886119369190615196565b6119409190615207565b90506000612710600654896119559190615196565b61195f9190615207565b905060006127106008548a6119749190615196565b61197e9190615207565b905060006127106007548b6119939190615196565b61199d9190615207565b905060006127106009548c6119b29190615196565b6119bc9190615207565b90507f000000000000000000000000e6a062fba3918376500a602c800b1e030742045773ffffffffffffffffffffffffffffffffffffffff166323b872dd33308e6040518463ffffffff1660e01b8152600401611a1b939291906148a4565b6020604051808303816000875af1158015611a3a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a5e91906148f0565b5082600d6000828254611a719190613bc9565b9250508190555081600c6000828254611a8a9190613bc9565b925050819055506000851115611b26577f000000000000000000000000e6a062fba3918376500a602c800b1e030742045773ffffffffffffffffffffffffffffffffffffffff166342966c68866040518263ffffffff1660e01b8152600401611af39190613dbf565b600060405180830381600087803b158015611b0d57600080fd5b505af1158015611b21573d6000803e3d6000fd5b505050505b6000841115611bf1577f000000000000000000000000e6a062fba3918376500a602c800b1e030742045773ffffffffffffffffffffffffffffffffffffffff1663a9059cbb601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16866040518363ffffffff1660e01b8152600401611bac929190613c4d565b6020604051808303816000875af1158015611bcb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bef91906148f0565b505b6000811115611cbc577f000000000000000000000000e6a062fba3918376500a602c800b1e030742045773ffffffffffffffffffffffffffffffffffffffff1663a9059cbb600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836040518363ffffffff1660e01b8152600401611c77929190613c4d565b6020604051808303816000875af1158015611c96573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cba91906148f0565b505b60008d148015611ccc575060008c115b15611d2f57611cdb338d613946565b3373ffffffffffffffffffffffffffffffffffffffff167fcf1d432606e0ee6a23fc32ce701ac36c9897204278c35ac9d65112344b20991760018e8b604051611d2693929190615238565b60405180910390a25b60018d03611d88573373ffffffffffffffffffffffffffffffffffffffff167f759647c6e0ef64ba58a247443390ca1ca127a0e56c0ca73b8e7adb81cdea686f8d8a604051611d7f92919061526f565b60405180910390a25b60028d03611de1573373ffffffffffffffffffffffffffffffffffffffff167f064c6c90fdf69cdb269f2989d2db58656f9f0975deb0a85bc6c3e85ce03849368d8a604051611dd892919061526f565b60405180910390a25b60038d03611e3a573373ffffffffffffffffffffffffffffffffffffffff167f9841530569e3c231047b6033deea4a0cdaa8030ad02d8995de67995def9af0388d8a604051611e3192919061526f565b60405180910390a25b60048d03611e93573373ffffffffffffffffffffffffffffffffffffffff167fc41f685bb934317e998f0d450848c2a5c23e6e7d12b456808ffd9ddbc094e9ed8d8a604051611e8a92919061526f565b60405180910390a25b50505050505050505050505050565b600d5481565b601160159054906101000a900460ff1615611ef8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611eef906152e4565b60405180910390fd5b80601560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015611f7a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611f7190615350565b60405180910390fd5b80601560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611fc99190614ab7565b925050819055507f000000000000000000000000f11afd83cd6b42d31961284498ad6a44ca0c0ae873ffffffffffffffffffffffffffffffffffffffff1663f242432a30846001856040518563ffffffff1660e01b815260040161203094939291906153a4565b600060405180830381600087803b15801561204a57600080fd5b505af115801561205e573d6000803e3d6000fd5b505050503373ffffffffffffffffffffffffffffffffffffffff167ff279e6a1f5e320cca91135676d9cb6e44ca8a08c0b88342bcdb1144f6511b5686001836040516120ab92919061526f565b60405180910390a25050565b7ff1b411d6abb365480ac902cc153c45e9ded5847a2265ce6d01945d253edb6bc76120e181613640565b81601160156101000a81548160ff0219169083151502179055505050565b7ff1b411d6abb365480ac902cc153c45e9ded5847a2265ce6d01945d253edb6bc781565b601160149054906101000a900460ff1681565b600b5481565b7ff1b411d6abb365480ac902cc153c45e9ded5847a2265ce6d01945d253edb6bc761216681613640565b601160149054906101000a900460ff166121b5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016121ac90615448565b60405180910390fd5b825184511480156121c7575081518351145b612206576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016121fd906154b4565b60405180910390fd5b60005b845181101561257a5783818151811061222557612224614bc3565b5b602002602001015147101561226f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161226690615520565b60405180910390fd5b82818151811061228257612281614bc3565b5b60200260200101517f000000000000000000000000e6a062fba3918376500a602c800b1e030742045773ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016122e391906142d5565b602060405180830381865afa158015612300573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612324919061495b565b1015612365576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161235c9061558c565b60405180910390fd5b600084828151811061237a57612379614bc3565b5b6020026020010151111561247057600085828151811061239d5761239c614bc3565b5b6020026020010151905060008173ffffffffffffffffffffffffffffffffffffffff168684815181106123d3576123d2614bc3565b5b60200260200101516040516123e790614a36565b60006040518083038185875af1925050503d8060008114612424576040519150601f19603f3d011682016040523d82523d6000602084013e612429565b606091505b505090508061246d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161246490614a97565b60405180910390fd5b50505b600083828151811061248557612484614bc3565b5b60200260200101511115612567577f000000000000000000000000e6a062fba3918376500a602c800b1e030742045773ffffffffffffffffffffffffffffffffffffffff1663a9059cbb8683815181106124e2576124e1614bc3565b5b60200260200101518584815181106124fd576124fc614bc3565b5b60200260200101516040518363ffffffff1660e01b8152600401612522929190613c4d565b6020604051808303816000875af1158015612541573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061256591906148f0565b505b808061257290614c5e565b915050612209565b5050505050565b7fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c2177581565b837f000000000000000000000000e6a062fba3918376500a602c800b1e030742045773ffffffffffffffffffffffffffffffffffffffff1663dd62ed3e33306040518363ffffffff1660e01b815260040161260192919061491d565b602060405180830381865afa15801561261e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612642919061495b565b1015612683576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161267a90614edc565b60405180910390fd5b601160149054906101000a900460ff16156126d3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016126ca90614b37565b60405180910390fd5b600a54836126e19190613bc9565b4210612722576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161271990614fb4565b60405180910390fd5b6014600083815260200190815260200160002060009054906101000a900460ff1615612783576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161277a90615020565b60405180910390fd5b60006127be3388888888886040516020016127a3969594939291906155ac565b60405160208183030381529060405280519060200120613891565b905061280b81837f00000000000000000000000063a37fbd924c6d5e2c2a7fdfddbd079a0837c67573ffffffffffffffffffffffffffffffffffffffff166139039092919063ffffffff16565b61284a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161284190615176565b60405180910390fd5b60016014600085815260200190815260200160002060006101000a81548160ff0219169083151502179055507f000000000000000000000000e6a062fba3918376500a602c800b1e030742045773ffffffffffffffffffffffffffffffffffffffff166323b872dd33601160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16886040518463ffffffff1660e01b81526004016128f5939291906148a4565b6020604051808303816000875af1158015612914573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061293891906148f0565b503373ffffffffffffffffffffffffffffffffffffffff167f13f135658b67258df1952b1efe89331bc59bde07499073b16d5f4908012dce5b88888887604051612985949392919061561c565b60405180910390a250505050505050565b60065481565b7f0000000000000000000000009c910cb24ed6f9d248f1b3f1492ab887cdccc97381565b600080600084815260200190815260200160002060000160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b73430000000000000000000000000000000000000281565b6000801b612a4f81613640565b601160149054906101000a900460ff16612a9e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612a9590615448565b60405180910390fd5b60004711612ae1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612ad8906156ad565b60405180910390fd5b600033905060008173ffffffffffffffffffffffffffffffffffffffff1647604051612b0c90614a36565b60006040518083038185875af1925050503d8060008114612b49576040519150601f19603f3d011682016040523d82523d6000602084013e612b4e565b606091505b5050905080612b92576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612b8990614a97565b60405180910390fd5b505050565b601160149054906101000a900460ff1615612be7576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612bde90614b37565b60405180910390fd5b7f000000000000000000000000f11afd83cd6b42d31961284498ad6a44ca0c0ae873ffffffffffffffffffffffffffffffffffffffff1663f242432a33306001856040518563ffffffff1660e01b8152600401612c4794939291906153a4565b600060405180830381600087803b158015612c6157600080fd5b505af1158015612c75573d6000803e3d6000fd5b5050505080601560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254612cc89190613bc9565b925050819055508173ffffffffffffffffffffffffffffffffffffffff167f90890809c654f11d6e72a28fa60149770a0d11ec6c92319d6ceb2bb0a4ea1a15600183604051612d1892919061526f565b60405180910390a25050565b601160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b7fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c21775612d7481613640565b85600e60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555084600f60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555083601060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555082601160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555081600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550505050505050565b6000801b81565b7fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c21775612ef281613640565b86600a81905550856004819055508460058190555083600681905550826007819055508160098190555083838387612710612f2d9190614ab7565b612f379190614ab7565b612f419190614ab7565b612f4b9190614ab7565b60088190555050505050505050565b600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b7ff1b411d6abb365480ac902cc153c45e9ded5847a2265ce6d01945d253edb6bc7612faa81613640565b6000600267ffffffffffffffff811115612fc757612fc6614057565b5b604051908082528060200260200182016040528015612ff55781602001602082028036833780820191505090505b5090507f000000000000000000000000e6a062fba3918376500a602c800b1e03074204578160008151811061302d5761302c614bc3565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa1580156130d4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130f891906156e2565b8160018151811061310c5761310b614bc3565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250506000600d5490507f000000000000000000000000e6a062fba3918376500a602c800b1e030742045773ffffffffffffffffffffffffffffffffffffffff1663095ea7b3600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836040518363ffffffff1660e01b81526004016131ca929190613c4d565b6020604051808303816000875af11580156131e9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061320d91906148f0565b506000600d81905550600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663791ac94782868530426040518663ffffffff1660e01b815260040161327995949392919061570f565b600060405180830381600087803b15801561329357600080fd5b505af11580156132a7573d6000803e3d6000fd5b5050505050505050565b7fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c217756132db81613640565b600073ffffffffffffffffffffffffffffffffffffffff16600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff160361336c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401613363906157b5565b60405180910390fd5b811561342c5773430000000000000000000000000000000000000273ffffffffffffffffffffffffffffffffffffffff1663662aa11d30600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040518363ffffffff1660e01b81526004016133e392919061491d565b6020604051808303816000875af1158015613402573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613426919061495b565b506134e2565b73430000000000000000000000000000000000000273ffffffffffffffffffffffffffffffffffffffff1663954fa5ee30600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040518363ffffffff1660e01b815260040161349d92919061491d565b6020604051808303816000875af11580156134bc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134e0919061495b565b505b5050565b60075481565b60055481565b601160159054906101000a900460ff1681565b7f000000000000000000000000e6a062fba3918376500a602c800b1e030742045781565b600c5481565b60095481565b60085481565b61354482610d38565b61354d81613640565b613557838361374d565b50505050565b60156020528060005260406000206000915090505481565b60007ff23a6e612e1ff4830e658fe43f4e3cb4a5f8170bd5d9e69fb5d7a7fa9e4fdf9790509695505050505050565b60035481565b600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60045481565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b6136518161364c613745565b613ab8565b50565b600061366083836129c0565b61373a57600160008085815260200190815260200160002060000160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506136d7613745565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16847f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a46001905061373f565b600090505b92915050565b600033905090565b600061375983836129c0565b1561383457600080600085815260200190815260200160002060000160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506137d1613745565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16847ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a460019050613839565b600090505b92915050565b600080600090505b825181101561388b5782818151811061386357613862614bc3565b5b6020026020010151826138769190613bc9565b9150808061388390614c5e565b915050613847565b50919050565b6000806040518060400160405280601c81526020017f19457468657265756d205369676e6564204d6573736167653a0a3332000000008152509050600081846040516020016138e192919061585c565b6040516020818303038152906040528051906020012090508092505050919050565b600061390f8383613b09565b73ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161490509392505050565b60008103613989576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401613980906158d0565b60405180910390fd5b6003548111156139ce576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016139c59061593c565b60405180910390fd5b7f000000000000000000000000f11afd83cd6b42d31961284498ad6a44ca0c0ae873ffffffffffffffffffffffffffffffffffffffff1663731133e9306001846040518463ffffffff1660e01b8152600401613a2c9392919061595c565b600060405180830381600087803b158015613a4657600080fd5b505af1158015613a5a573d6000803e3d6000fd5b5050505080601560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254613aad9190613bc9565b925050819055505050565b613ac282826129c0565b613b055780826040517fe2517d3f000000000000000000000000000000000000000000000000000000008152600401613afc9291906159a6565b60405180910390fd5b5050565b60006041825114613b1957600080fd5b60008060006020850151915060408501519050606085015160001a925060018684848460405160008152602001604052604051613b5994939291906159eb565b6020604051602081039080840390855afa158015613b7b573d6000803e3d6000fd5b50505060206040510351935050505092915050565b6000819050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000613bd482613b90565b9150613bdf83613b90565b9250828201905080821115613bf757613bf6613b9a565b5b92915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000613c2882613bfd565b9050919050565b613c3881613c1d565b82525050565b613c4781613b90565b82525050565b6000604082019050613c626000830185613c2f565b613c6f6020830184613c3e565b9392505050565b6000604051905090565b600080fd5b600080fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b613cbf81613c8a565b8114613cca57600080fd5b50565b600081359050613cdc81613cb6565b92915050565b600060208284031215613cf857613cf7613c80565b5b6000613d0684828501613ccd565b91505092915050565b60008115159050919050565b613d2481613d0f565b82525050565b6000602082019050613d3f6000830184613d1b565b92915050565b6000819050919050565b6000613d6a613d65613d6084613bfd565b613d45565b613bfd565b9050919050565b6000613d7c82613d4f565b9050919050565b6000613d8e82613d71565b9050919050565b613d9e81613d83565b82525050565b6000602082019050613db96000830184613d95565b92915050565b6000602082019050613dd46000830184613c3e565b92915050565b6000819050919050565b613ded81613dda565b8114613df857600080fd5b50565b600081359050613e0a81613de4565b92915050565b600060208284031215613e2657613e25613c80565b5b6000613e3484828501613dfb565b91505092915050565b613e4681613dda565b82525050565b6000602082019050613e616000830184613e3d565b92915050565b613e7081613c1d565b8114613e7b57600080fd5b50565b600081359050613e8d81613e67565b92915050565b600060208284031215613ea957613ea8613c80565b5b6000613eb784828501613e7e565b91505092915050565b613ec981613b90565b8114613ed457600080fd5b50565b600081359050613ee681613ec0565b92915050565b600060208284031215613f0257613f01613c80565b5b6000613f1084828501613ed7565b91505092915050565b60008060408385031215613f3057613f2f613c80565b5b6000613f3e85828601613dfb565b9250506020613f4f85828601613e7e565b9150509250929050565b613f6281613d0f565b8114613f6d57600080fd5b50565b600081359050613f7f81613f59565b92915050565b600060208284031215613f9b57613f9a613c80565b5b6000613fa984828501613f70565b91505092915050565b600080600060608486031215613fcb57613fca613c80565b5b6000613fd986828701613ed7565b9350506020613fea86828701613ed7565b9250506040613ffb86828701613ed7565b9150509250925092565b600061401082613d71565b9050919050565b61402081614005565b82525050565b600060208201905061403b6000830184614017565b92915050565b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b61408f82614046565b810181811067ffffffffffffffff821117156140ae576140ad614057565b5b80604052505050565b60006140c1613c76565b90506140cd8282614086565b919050565b600067ffffffffffffffff8211156140ed576140ec614057565b5b602082029050602081019050919050565b600080fd5b6000614116614111846140d2565b6140b7565b90508083825260208201905060208402830185811115614139576141386140fe565b5b835b81811015614162578061414e8882613e7e565b84526020840193505060208101905061413b565b5050509392505050565b600082601f83011261418157614180614041565b5b8135614191848260208601614103565b91505092915050565b600067ffffffffffffffff8211156141b5576141b4614057565b5b602082029050602081019050919050565b60006141d96141d48461419a565b6140b7565b905080838252602082019050602084028301858111156141fc576141fb6140fe565b5b835b8181101561422557806142118882613ed7565b8452602084019350506020810190506141fe565b5050509392505050565b600082601f83011261424457614243614041565b5b81356142548482602086016141c6565b91505092915050565b6000806040838503121561427457614273613c80565b5b600083013567ffffffffffffffff81111561429257614291613c85565b5b61429e8582860161416c565b925050602083013567ffffffffffffffff8111156142bf576142be613c85565b5b6142cb8582860161422f565b9150509250929050565b60006020820190506142ea6000830184613c2f565b92915050565b600080fd5b600067ffffffffffffffff8211156143105761430f614057565b5b61431982614046565b9050602081019050919050565b82818337600083830152505050565b6000614348614343846142f5565b6140b7565b905082815260208101848484011115614364576143636142f0565b5b61436f848285614326565b509392505050565b600082601f83011261438c5761438b614041565b5b813561439c848260208601614335565b91505092915050565b600080600080600080600060e0888a0312156143c4576143c3613c80565b5b60006143d28a828b01613ed7565b97505060206143e38a828b01613ed7565b96505060406143f48a828b01613ed7565b95505060606144058a828b01613ed7565b94505060806144168a828b01613ed7565b93505060a06144278a828b01613ed7565b92505060c088013567ffffffffffffffff81111561444857614447613c85565b5b6144548a828b01614377565b91505092959891949750929550565b6000806040838503121561447a57614479613c80565b5b600061448885828601613e7e565b925050602061449985828601613ed7565b9150509250929050565b6000806000606084860312156144bc576144bb613c80565b5b600084013567ffffffffffffffff8111156144da576144d9613c85565b5b6144e68682870161416c565b935050602084013567ffffffffffffffff81111561450757614506613c85565b5b6145138682870161422f565b925050604084013567ffffffffffffffff81111561453457614533613c85565b5b6145408682870161422f565b9150509250925092565b60008060008060008060c0878903121561456757614566613c80565b5b600061457589828a01613ed7565b965050602061458689828a01613ed7565b955050604061459789828a01613ed7565b94505060606145a889828a01613ed7565b93505060806145b989828a01613ed7565b92505060a087013567ffffffffffffffff8111156145da576145d9613c85565b5b6145e689828a01614377565b9150509295509295509295565b60006145fe82613d71565b9050919050565b61460e816145f3565b82525050565b60006020820190506146296000830184614605565b92915050565b600080600080600060a0868803121561464b5761464a613c80565b5b600061465988828901613e7e565b955050602061466a88828901613e7e565b945050604061467b88828901613e7e565b935050606061468c88828901613e7e565b925050608061469d88828901613e7e565b9150509295509295909350565b60008060008060008060c087890312156146c7576146c6613c80565b5b60006146d589828a01613ed7565b96505060206146e689828a01613ed7565b95505060406146f789828a01613ed7565b945050606061470889828a01613ed7565b935050608061471989828a01613ed7565b92505060a061472a89828a01613ed7565b9150509295509295509295565b600061474282613d4f565b9050919050565b600061475482614737565b9050919050565b61476481614749565b82525050565b600060208201905061477f600083018461475b565b92915050565b600080fd5b60008083601f8401126147a05761479f614041565b5b8235905067ffffffffffffffff8111156147bd576147bc614785565b5b6020830191508360018202830111156147d9576147d86140fe565b5b9250929050565b60008060008060008060a087890312156147fd576147fc613c80565b5b600061480b89828a01613e7e565b965050602061481c89828a01613e7e565b955050604061482d89828a01613ed7565b945050606061483e89828a01613ed7565b935050608087013567ffffffffffffffff81111561485f5761485e613c85565b5b61486b89828a0161478a565b92509250509295509295509295565b61488381613c8a565b82525050565b600060208201905061489e600083018461487a565b92915050565b60006060820190506148b96000830186613c2f565b6148c66020830185613c2f565b6148d36040830184613c3e565b949350505050565b6000815190506148ea81613f59565b92915050565b60006020828403121561490657614905613c80565b5b6000614914848285016148db565b91505092915050565b60006040820190506149326000830185613c2f565b61493f6020830184613c2f565b9392505050565b60008151905061495581613ec0565b92915050565b60006020828403121561497157614970613c80565b5b600061497f84828501614946565b91505092915050565b600082825260208201905092915050565b7f4e65656420746f2073656e64206d6f7265206574686572000000000000000000600082015250565b60006149cf601783614988565b91506149da82614999565b602082019050919050565b600060208201905081810360008301526149fe816149c2565b9050919050565b600081905092915050565b50565b6000614a20600083614a05565b9150614a2b82614a10565b600082019050919050565b6000614a4182614a13565b9150819050919050565b7f4661696c656420746f2073656e64204574686572000000000000000000000000600082015250565b6000614a81601483614988565b9150614a8c82614a4b565b602082019050919050565b60006020820190508181036000830152614ab081614a74565b9050919050565b6000614ac282613b90565b9150614acd83613b90565b9250828203905081811115614ae557614ae4613b9a565b5b92915050565b7f47616d6520697320636c6f736564000000000000000000000000000000000000600082015250565b6000614b21600e83614988565b9150614b2c82614aeb565b602082019050919050565b60006020820190508181036000830152614b5081614b14565b9050919050565b7f496e707574206172726179206973206e6f74206d617463680000000000000000600082015250565b6000614b8d601883614988565b9150614b9882614b57565b602082019050919050565b60006020820190508181036000830152614bbc81614b80565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f496e76616c696420616d6f756e7420746f206275726e00000000000000000000600082015250565b6000614c28601683614988565b9150614c3382614bf2565b602082019050919050565b60006020820190508181036000830152614c5781614c1b565b9050919050565b6000614c6982613b90565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203614c9b57614c9a613b9a565b5b600182019050919050565b6000606082019050614cbb6000830186613c2f565b614cc86020830185613c3e565b614cd56040830184613c3e565b949350505050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b614d1281613c1d565b82525050565b6000614d248383614d09565b60208301905092915050565b6000602082019050919050565b6000614d4882614cdd565b614d528185614ce8565b9350614d5d83614cf9565b8060005b83811015614d8e578151614d758882614d18565b9750614d8083614d30565b925050600181019050614d61565b5085935050505092915050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b614dd081613b90565b82525050565b6000614de28383614dc7565b60208301905092915050565b6000602082019050919050565b6000614e0682614d9b565b614e108185614da6565b9350614e1b83614db7565b8060005b83811015614e4c578151614e338882614dd6565b9750614e3e83614dee565b925050600181019050614e1f565b5085935050505092915050565b60006040820190508181036000830152614e738185614d3d565b90508181036020830152614e878184614dfb565b90509392505050565b7f4572726f72000000000000000000000000000000000000000000000000000000600082015250565b6000614ec6600583614988565b9150614ed182614e90565b602082019050919050565b60006020820190508181036000830152614ef581614eb9565b9050919050565b7f496e76616c6964206c617374206275792074696d650000000000000000000000600082015250565b6000614f32601583614988565b9150614f3d82614efc565b602082019050919050565b60006020820190508181036000830152614f6181614f25565b9050919050565b7f496e76616c69642074696d657374616d70000000000000000000000000000000600082015250565b6000614f9e601183614988565b9150614fa982614f68565b602082019050919050565b60006020820190508181036000830152614fcd81614f91565b9050919050565b7f4e6f6e6365206973207573656400000000000000000000000000000000000000600082015250565b600061500a600d83614988565b915061501582614fd4565b602082019050919050565b6000602082019050818103600083015261503981614ffd565b9050919050565b60008160601b9050919050565b600061505882615040565b9050919050565b600061506a8261504d565b9050919050565b61508261507d82613c1d565b61505f565b82525050565b6000819050919050565b6150a361509e82613b90565b615088565b82525050565b60006150b5828a615071565b6014820191506150c58289615092565b6020820191506150d58288615092565b6020820191506150e58287615092565b6020820191506150f58286615092565b6020820191506151058285615092565b6020820191506151158284615092565b60208201915081905098975050505050505050565b7f496e76616c6964207369676e6174757265000000000000000000000000000000600082015250565b6000615160601183614988565b915061516b8261512a565b602082019050919050565b6000602082019050818103600083015261518f81615153565b9050919050565b60006151a182613b90565b91506151ac83613b90565b92508282026151ba81613b90565b915082820484148315176151d1576151d0613b9a565b5b5092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b600061521282613b90565b915061521d83613b90565b92508261522d5761522c6151d8565b5b828204905092915050565b600060608201905061524d6000830186613c3e565b61525a6020830185613c3e565b6152676040830184613c3e565b949350505050565b60006040820190506152846000830185613c3e565b6152916020830184613c3e565b9392505050565b7f4e4654206973206c6f636b656400000000000000000000000000000000000000600082015250565b60006152ce600d83614988565b91506152d982615298565b602082019050919050565b600060208201905081810360008301526152fd816152c1565b9050919050565b7f496e73756666696369656e742062616c616e6365000000000000000000000000600082015250565b600061533a601483614988565b915061534582615304565b602082019050919050565b600060208201905081810360008301526153698161532d565b9050919050565b600082825260208201905092915050565b600061538e600083615370565b915061539982614a10565b600082019050919050565b600060a0820190506153b96000830187613c2f565b6153c66020830186613c2f565b6153d36040830185613c3e565b6153e06060830184613c3e565b81810360808301526153f181615381565b905095945050505050565b7f47616d65206973206e6f7420636c6f7365640000000000000000000000000000600082015250565b6000615432601283614988565b915061543d826153fc565b602082019050919050565b6000602082019050818103600083015261546181615425565b9050919050565b7f496e76616c696420696e707574206172726179206c656e677468000000000000600082015250565b600061549e601a83614988565b91506154a982615468565b602082019050919050565b600060208201905081810360008301526154cd81615491565b9050919050565b7f4f766572206574682062616c616e636500000000000000000000000000000000600082015250565b600061550a601083614988565b9150615515826154d4565b602082019050919050565b60006020820190508181036000830152615539816154fd565b9050919050565b7f4f76657220746f6b656e2062616c616e63650000000000000000000000000000600082015250565b6000615576601283614988565b915061558182615540565b602082019050919050565b600060208201905081810360008301526155a581615569565b9050919050565b60006155b88289615071565b6014820191506155c88288615092565b6020820191506155d88287615092565b6020820191506155e88286615092565b6020820191506155f88285615092565b6020820191506156088284615092565b602082019150819050979650505050505050565b60006080820190506156316000830187613c3e565b61563e6020830186613c3e565b61564b6040830185613c3e565b6156586060830184613c3e565b95945050505050565b7f4e6f7468696e6720746f20776974686472617700000000000000000000000000600082015250565b6000615697601383614988565b91506156a282615661565b602082019050919050565b600060208201905081810360008301526156c68161568a565b9050919050565b6000815190506156dc81613e67565b92915050565b6000602082840312156156f8576156f7613c80565b5b6000615706848285016156cd565b91505092915050565b600060a0820190506157246000830188613c3e565b6157316020830187613c3e565b81810360408301526157438186614d3d565b90506157526060830185613c2f565b61575f6080830184613c3e565b9695505050505050565b7f676173466565206973206e6f7420736574000000000000000000000000000000600082015250565b600061579f601183614988565b91506157aa82615769565b602082019050919050565b600060208201905081810360008301526157ce81615792565b9050919050565b600081519050919050565b60005b838110156157fe5780820151818401526020810190506157e3565b60008484015250505050565b6000615815826157d5565b61581f8185614a05565b935061582f8185602086016157e0565b80840191505092915050565b6000819050919050565b61585661585182613dda565b61583b565b82525050565b6000615868828561580a565b91506158748284615845565b6020820191508190509392505050565b7f496e76616c696420616d6f756e74000000000000000000000000000000000000600082015250565b60006158ba600e83614988565b91506158c582615884565b602082019050919050565b600060208201905081810360008301526158e9816158ad565b9050919050565b7f4d61782070657220626174636820726561636865640000000000000000000000600082015250565b6000615926601583614988565b9150615931826158f0565b602082019050919050565b6000602082019050818103600083015261595581615919565b9050919050565b60006080820190506159716000830186613c2f565b61597e6020830185613c3e565b61598b6040830184613c3e565b818103606083015261599c81615381565b9050949350505050565b60006040820190506159bb6000830185613c2f565b6159c86020830184613e3d565b9392505050565b600060ff82169050919050565b6159e5816159cf565b82525050565b6000608082019050615a006000830187613e3d565b615a0d60208301866159dc565b615a1a6040830185613e3d565b615a276060830184613e3d565b9594505050505056fea2646970667358221220f34f4cf73b00cee009fbfe4f8dd02cc352b4ebe021aa38ef651bd6b9c67be9d364736f6c63430008140033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000d65934f0e7d543d10b070ed1b3f62ca9b7e0c4c7000000000000000000000000d65934f0e7d543d10b070ed1b3f62ca9b7e0c4c7000000000000000000000000dc678248e99a5a7aee93342af067ea8bded520ec00000000000000000000000063a37fbd924c6d5e2c2a7fdfddbd079a0837c675000000000000000000000000f11afd83cd6b42d31961284498ad6a44ca0c0ae8000000000000000000000000e6a062fba3918376500a602c800b1e03074204570000000000000000000000009c910cb24ed6f9d248f1b3f1492ab887cdccc9730000000000000000000000002536fe9ab3f511540f2f9e2ec2a805005c3dd800
-----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): 0xf11AFd83Cd6B42d31961284498aD6a44ca0c0Ae8
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] : 000000000000000000000000f11afd83cd6b42d31961284498ad6a44ca0c0ae8
Arg [5] : 000000000000000000000000e6a062fba3918376500a602c800b1e0307420457
Arg [6] : 0000000000000000000000009c910cb24ed6f9d248f1b3f1492ab887cdccc973
Arg [7] : 0000000000000000000000002536fe9ab3f511540f2f9e2ec2a805005c3dd800
Loading...
Loading
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in ETH
0
Multichain Portfolio | 35 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ 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.