Overview
ETH Balance
ETH Value
$0.00Latest 25 from a total of 2,262,747 transactions
| Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
|---|---|---|---|---|---|---|---|---|---|
| Open Mystery Box | 17587754 | 8 days ago | IN | 0.00000112 ETH | 0.00000141 | ||||
| Open Mystery Box | 17587697 | 8 days ago | IN | 0.00000112 ETH | 0.00000135 | ||||
| Open Mystery Box | 17587511 | 8 days ago | IN | 0.00000112 ETH | 0.00000151 | ||||
| Open Mystery Box | 17587511 | 8 days ago | IN | 0.00000112 ETH | 0.00000151 | ||||
| Open Mystery Box | 17587511 | 8 days ago | IN | 0.00000112 ETH | 0.00000151 | ||||
| Open Mystery Box | 17587511 | 8 days ago | IN | 0.00000112 ETH | 0.00000151 | ||||
| Open Mystery Box | 17587511 | 8 days ago | IN | 0.00000112 ETH | 0.00000151 | ||||
| Open Mystery Box | 17587510 | 8 days ago | IN | 0.00000112 ETH | 0.00000151 | ||||
| Open Mystery Box | 17587510 | 8 days ago | IN | 0.00000112 ETH | 0.00000151 | ||||
| Open Mystery Box | 17587510 | 8 days ago | IN | 0.00000112 ETH | 0.00000151 | ||||
| Open Mystery Box | 17587510 | 8 days ago | IN | 0.00000112 ETH | 0.00000151 | ||||
| Open Mystery Box | 17587510 | 8 days ago | IN | 0.00000112 ETH | 0.00000151 | ||||
| Open Mystery Box | 17587509 | 8 days ago | IN | 0.00000112 ETH | 0.00000135 | ||||
| Open Mystery Box | 17587404 | 8 days ago | IN | 0.00000112 ETH | 0.00000172 | ||||
| Open Mystery Box | 17587359 | 8 days ago | IN | 0.00000112 ETH | 0.00000172 | ||||
| Open Mystery Box | 17587298 | 8 days ago | IN | 0.00000112 ETH | 0.00000142 | ||||
| Open Mystery Box | 17587273 | 8 days ago | IN | 0.00000112 ETH | 0.00000135 | ||||
| Open Mystery Box | 17586856 | 8 days ago | IN | 0.00000112 ETH | 0.00000135 | ||||
| Open Mystery Box | 17586770 | 8 days ago | IN | 0.00000112 ETH | 0.00000142 | ||||
| Open Mystery Box | 17586649 | 8 days ago | IN | 0.00000112 ETH | 0.00000135 | ||||
| Open Mystery Box | 17586576 | 8 days ago | IN | 0.00000112 ETH | 0.00000135 | ||||
| Open Mystery Box | 17586504 | 8 days ago | IN | 0.00000112 ETH | 0.00000142 | ||||
| Open Mystery Box | 17586368 | 8 days ago | IN | 0.00000112 ETH | 0.00000141 | ||||
| Open Mystery Box | 17586338 | 8 days ago | IN | 0.00000112 ETH | 0.00000141 | ||||
| Open Mystery Box | 17586239 | 8 days ago | IN | 0.00000112 ETH | 0.00000257 |
Latest 25 internal transactions (View All)
| Parent Transaction Hash | Block | From | To | |||
|---|---|---|---|---|---|---|
| 17587754 | 8 days ago | 0.00000112 ETH | ||||
| 17587697 | 8 days ago | 0.00000112 ETH | ||||
| 17587511 | 8 days ago | 0.00000112 ETH | ||||
| 17587511 | 8 days ago | 0.00000112 ETH | ||||
| 17587511 | 8 days ago | 0.00000112 ETH | ||||
| 17587511 | 8 days ago | 0.00000112 ETH | ||||
| 17587511 | 8 days ago | 0.00000112 ETH | ||||
| 17587510 | 8 days ago | 0.00000112 ETH | ||||
| 17587510 | 8 days ago | 0.00000112 ETH | ||||
| 17587510 | 8 days ago | 0.00000112 ETH | ||||
| 17587510 | 8 days ago | 0.00000112 ETH | ||||
| 17587510 | 8 days ago | 0.00000112 ETH | ||||
| 17587509 | 8 days ago | 0.00000112 ETH | ||||
| 17587404 | 8 days ago | 0.00000112 ETH | ||||
| 17587359 | 8 days ago | 0.00000112 ETH | ||||
| 17587298 | 8 days ago | 0.00000112 ETH | ||||
| 17587273 | 8 days ago | 0.00000112 ETH | ||||
| 17586856 | 8 days ago | 0.00000112 ETH | ||||
| 17586770 | 8 days ago | 0.00000112 ETH | ||||
| 17586649 | 8 days ago | 0.00000112 ETH | ||||
| 17586576 | 8 days ago | 0.00000112 ETH | ||||
| 17586504 | 8 days ago | 0.00000112 ETH | ||||
| 17586368 | 8 days ago | 0.00000112 ETH | ||||
| 17586338 | 8 days ago | 0.00000112 ETH | ||||
| 17586239 | 8 days ago | 0.00000112 ETH |
Cross-Chain Transactions
Contract Source Code Verified (Exact Match)
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT
pragma solidity 0.8.24;
import {AccessControl} from "@openzeppelin/contracts/access/AccessControl.sol";
import {ERC2771Context} from "@openzeppelin/contracts/metatx/ERC2771Context.sol";
import {EIP712} from "@openzeppelin/contracts/utils/cryptography/EIP712.sol";
import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import {Context} from "@openzeppelin/contracts/utils/Context.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {Address} from "@openzeppelin/contracts/utils/Address.sol";
import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import {ITeaFiMysteryBoxManager} from "./interfaces/ITeaFiMysteryBoxManager.sol";
import {PermitManagement} from "../permit/PermitManagement.sol";
contract TeaFiMysteryBoxManager is
ITeaFiMysteryBoxManager,
PermitManagement,
ReentrancyGuard,
AccessControl,
ERC2771Context,
EIP712
{
using SafeERC20 for IERC20;
/// @dev keccak256("OpenBoxParam(uint256 id,uint64 issuedAt,bytes rewardInfo,address recipient,address feeToken,uint256 feeAmount,uint256 nonce,uint256 deadline)")
bytes32 public constant OPEN_MYSTERY_BOX_TYPEHASH =
0xe2a460efd37a9898f0753d260c27d5120a982834718ef11e7eefae5f217a8266;
/// @dev keccak256("OPERATOR_ROLE")
bytes32 public constant OPERATOR_ROLE = 0x97667070c54ef182b0f5858b034beac1b6f3089aa2d3188bb1e8929f4fa9b929;
/// @dev Treasury used for accumulating fees
address payable public immutable treasury;
/// @dev Mapping to track signature nonces, operator's address => caller's address => signature nonce
mapping(address operator => mapping(address caller => uint256 nonce)) public operatorUserNonces;
/// @dev The last claimed day of the user
mapping(address => uint64) public lastClaimedDay;
/**
* @notice The constructor of the TeaFiMysteryBoxManager
* @param owner The owner of the contract.
* @param trustedForwarder_ The address of the ERC2771 trusted forwarder for supporting meta-transactions.
* @param operator The operator of the contract used for signing mbox data.
* @param treasury_ The address where collected fees (in native or ERC20 tokens) will be sent.
* @param permitManager_ The permit manager address.
*/
constructor(
address owner,
address trustedForwarder_,
address operator,
address treasury_,
address permitManager_
) ERC2771Context(trustedForwarder_) EIP712("TeaFiMysteryBoxManager", "1.0") PermitManagement(permitManager_) {
if (operator == address(0) || owner == address(0) || trustedForwarder_ == address(0) || treasury_ == address(0))
revert ZeroAddress();
treasury = payable(treasury_);
_grantRole(DEFAULT_ADMIN_ROLE, owner);
_grantRole(OPERATOR_ROLE, operator);
}
/// @inheritdoc ITeaFiMysteryBoxManager
function openMysteryBox(OpenBoxParam calldata param) external payable nonReentrant {
_validateInput(param);
if (param.fee.amount > 0) {
_sendFee(param.fee);
}
lastClaimedDay[_msgSender()] = uint64(block.timestamp / 1 days);
emit BoxOpened(
param.box.id,
_msgSender(),
param.fee.token,
param.fee.amount,
param.box.issuedAt,
param.box.rewardInfo
);
}
/**
* @notice Computes the EIP-712 compliant hash for the given struct data.
* @dev This function uses the `_hashTypedDataV4` function from the parent contract to generate the hash.
* It is used for EIP-712 signature validation.
* @param structHash The hash of the struct data to be typed.
* @return The EIP-712 compliant hash of the given struct data.
*/
function hashTypedDataV4(bytes32 structHash) external view returns (bytes32) {
return super._hashTypedDataV4(structHash);
}
function _validateInput(OpenBoxParam calldata param) private {
if (param.box.issuedAt == 0) {
revert InvalidBox("IssuedAt is 0");
}
if (param.box.issuedAt > block.timestamp) {
revert InvalidBox("Box not issued yet");
}
if (lastClaimedDay[_msgSender()] == block.timestamp / 1 days) {
revert InvalidBox("Already claimed today");
}
bytes memory encodedData = abi.encode(
OPEN_MYSTERY_BOX_TYPEHASH,
param.box.id,
param.box.issuedAt,
param.box.rewardInfo,
_msgSender(),
param.fee.token,
param.fee.amount,
param.nonce,
param.deadline
);
(bool success, string memory errorReason) = _verifySignature(
encodedData,
_msgSender(),
param.operator,
param.nonce,
param.deadline,
param.v,
param.r,
param.s
);
if (!success) {
revert InvalidSignature(errorReason);
}
}
function _verifySignature(
bytes memory encodedData,
address from,
address operator,
uint256 nonce,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) private returns (bool result, string memory errorReason) {
if (!hasRole(OPERATOR_ROLE, operator) || operator == address(0)) {
return (false, "INVALID_OPERATOR");
}
if (deadline < block.timestamp) {
return (false, "SIGNATURE_EXPIRED");
}
if (nonce != operatorUserNonces[operator][from]++) {
return (false, "MISMATCHING_NONCES");
}
bytes32 digest = _hashTypedDataV4(keccak256(encodedData));
address recoveredAddress = ECDSA.recover(digest, v, r, s);
if (recoveredAddress != operator) {
return (false, "INVALID_SIGNATURE");
}
return (true, "");
}
function _sendFee(Fee calldata fee) private {
if (fee.token == address(0)) {
if (msg.value < fee.amount) revert InvalidValue();
// Forward the native token to the treasury
Address.sendValue(treasury, fee.amount);
// Refund the sender any excess ETH sent
if (msg.value > fee.amount) {
Address.sendValue(payable(_msgSender()), msg.value - fee.amount);
}
} else {
if (msg.value > 0) revert NotNativeTransfer();
_receivePayment(fee.token, treasury, fee.amount, fee.tokenData, fee.permit2Data);
}
}
function _msgSender() internal view virtual override(Context, ERC2771Context) returns (address) {
return super._msgSender();
}
function _msgData() internal view virtual override(Context, ERC2771Context) returns (bytes calldata) {
return super._msgData();
}
function _contextSuffixLength() internal view virtual override(Context, ERC2771Context) returns (uint256) {
return super._contextSuffixLength();
}
}// 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/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.1) (metatx/ERC2771Context.sol)
pragma solidity ^0.8.20;
import {Context} from "../utils/Context.sol";
/**
* @dev Context variant with ERC2771 support.
*
* WARNING: Avoid using this pattern in contracts that rely in a specific calldata length as they'll
* be affected by any forwarder whose `msg.data` is suffixed with the `from` address according to the ERC2771
* specification adding the address size in bytes (20) to the calldata size. An example of an unexpected
* behavior could be an unintended fallback (or another function) invocation while trying to invoke the `receive`
* function only accessible if `msg.data.length == 0`.
*
* WARNING: The usage of `delegatecall` in this contract is dangerous and may result in context corruption.
* Any forwarded request to this contract triggering a `delegatecall` to itself will result in an invalid {_msgSender}
* recovery.
*/
abstract contract ERC2771Context is Context {
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
address private immutable _trustedForwarder;
/**
* @dev Initializes the contract with a trusted forwarder, which will be able to
* invoke functions on this contract on behalf of other accounts.
*
* NOTE: The trusted forwarder can be replaced by overriding {trustedForwarder}.
*/
/// @custom:oz-upgrades-unsafe-allow constructor
constructor(address trustedForwarder_) {
_trustedForwarder = trustedForwarder_;
}
/**
* @dev Returns the address of the trusted forwarder.
*/
function trustedForwarder() public view virtual returns (address) {
return _trustedForwarder;
}
/**
* @dev Indicates whether any particular address is the trusted forwarder.
*/
function isTrustedForwarder(address forwarder) public view virtual returns (bool) {
return forwarder == trustedForwarder();
}
/**
* @dev Override for `msg.sender`. Defaults to the original `msg.sender` whenever
* a call is not performed by the trusted forwarder or the calldata length is less than
* 20 bytes (an address length).
*/
function _msgSender() internal view virtual override returns (address) {
uint256 calldataLength = msg.data.length;
uint256 contextSuffixLength = _contextSuffixLength();
if (isTrustedForwarder(msg.sender) && calldataLength >= contextSuffixLength) {
return address(bytes20(msg.data[calldataLength - contextSuffixLength:]));
} else {
return super._msgSender();
}
}
/**
* @dev Override for `msg.data`. Defaults to the original `msg.data` whenever
* a call is not performed by the trusted forwarder or the calldata length is less than
* 20 bytes (an address length).
*/
function _msgData() internal view virtual override returns (bytes calldata) {
uint256 calldataLength = msg.data.length;
uint256 contextSuffixLength = _contextSuffixLength();
if (isTrustedForwarder(msg.sender) && calldataLength >= contextSuffixLength) {
return msg.data[:calldataLength - contextSuffixLength];
} else {
return super._msgData();
}
}
/**
* @dev ERC-2771 specifies the context as being a single address (20 bytes).
*/
function _contextSuffixLength() internal view virtual override returns (uint256) {
return 20;
}
}// 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) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
import {IERC20Permit} from "../extensions/IERC20Permit.sol";
import {Address} from "../../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
/**
* @dev An operation with an ERC20 token failed.
*/
error SafeERC20FailedOperation(address token);
/**
* @dev Indicates a failed `decreaseAllowance` request.
*/
error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);
/**
* @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
}
/**
* @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
* calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
*/
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
}
/**
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
forceApprove(token, spender, oldAllowance + value);
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
* value, non-reverting calls are assumed to be successful.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
unchecked {
uint256 currentAllowance = token.allowance(address(this), spender);
if (currentAllowance < requestedDecrease) {
revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
}
forceApprove(token, spender, currentAllowance - requestedDecrease);
}
}
/**
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
* to be set to zero before setting it to a non-zero value, such as USDT.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data);
if (returndata.length != 0 && !abi.decode(returndata, (bool))) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
// and not revert is the subcall reverts.
(bool success, bytes memory returndata) = address(token).call(data);
return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && address(token).code.length > 0;
}
}// 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.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/EIP712.sol)
pragma solidity ^0.8.20;
import {MessageHashUtils} from "./MessageHashUtils.sol";
import {ShortStrings, ShortString} from "../ShortStrings.sol";
import {IERC5267} from "../../interfaces/IERC5267.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.
*
* @custom:oz-upgrades-unsafe-allow state-variable-immutable
*/
abstract contract EIP712 is IERC5267 {
using ShortStrings for *;
bytes32 private constant TYPE_HASH =
keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)");
// Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to
// invalidate the cached domain separator if the chain id changes.
bytes32 private immutable _cachedDomainSeparator;
uint256 private immutable _cachedChainId;
address private immutable _cachedThis;
bytes32 private immutable _hashedName;
bytes32 private immutable _hashedVersion;
ShortString private immutable _name;
ShortString private immutable _version;
string private _nameFallback;
string private _versionFallback;
/**
* @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].
*/
constructor(string memory name, string memory version) {
_name = name.toShortStringWithFallback(_nameFallback);
_version = version.toShortStringWithFallback(_versionFallback);
_hashedName = keccak256(bytes(name));
_hashedVersion = keccak256(bytes(version));
_cachedChainId = block.chainid;
_cachedDomainSeparator = _buildDomainSeparator();
_cachedThis = address(this);
}
/**
* @dev Returns the domain separator for the current chain.
*/
function _domainSeparatorV4() internal view returns (bytes32) {
if (address(this) == _cachedThis && block.chainid == _cachedChainId) {
return _cachedDomainSeparator;
} else {
return _buildDomainSeparator();
}
}
function _buildDomainSeparator() private view returns (bytes32) {
return keccak256(abi.encode(TYPE_HASH, _hashedName, _hashedVersion, 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
)
{
return (
hex"0f", // 01111
_EIP712Name(),
_EIP712Version(),
block.chainid,
address(this),
bytes32(0),
new uint256[](0)
);
}
/**
* @dev The name parameter for the EIP712 domain.
*
* NOTE: By default this function reads _name which is an immutable value.
* It only reads from storage if necessary (in case the value is too large to fit in a ShortString).
*/
// solhint-disable-next-line func-name-mixedcase
function _EIP712Name() internal view returns (string memory) {
return _name.toStringWithFallback(_nameFallback);
}
/**
* @dev The version parameter for the EIP712 domain.
*
* NOTE: By default this function reads _version which is an immutable value.
* It only reads from storage if necessary (in case the value is too large to fit in a ShortString).
*/
// solhint-disable-next-line func-name-mixedcase
function _EIP712Version() internal view returns (string memory) {
return _version.toStringWithFallback(_versionFallback);
}
}// 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/ShortStrings.sol)
pragma solidity ^0.8.20;
import {StorageSlot} from "./StorageSlot.sol";
// | string | 0xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
// | length | 0x BB |
type ShortString is bytes32;
/**
* @dev This library provides functions to convert short memory strings
* into a `ShortString` type that can be used as an immutable variable.
*
* Strings of arbitrary length can be optimized using this library if
* they are short enough (up to 31 bytes) by packing them with their
* length (1 byte) in a single EVM word (32 bytes). Additionally, a
* fallback mechanism can be used for every other case.
*
* Usage example:
*
* ```solidity
* contract Named {
* using ShortStrings for *;
*
* ShortString private immutable _name;
* string private _nameFallback;
*
* constructor(string memory contractName) {
* _name = contractName.toShortStringWithFallback(_nameFallback);
* }
*
* function name() external view returns (string memory) {
* return _name.toStringWithFallback(_nameFallback);
* }
* }
* ```
*/
library ShortStrings {
// Used as an identifier for strings longer than 31 bytes.
bytes32 private constant FALLBACK_SENTINEL = 0x00000000000000000000000000000000000000000000000000000000000000FF;
error StringTooLong(string str);
error InvalidShortString();
/**
* @dev Encode a string of at most 31 chars into a `ShortString`.
*
* This will trigger a `StringTooLong` error is the input string is too long.
*/
function toShortString(string memory str) internal pure returns (ShortString) {
bytes memory bstr = bytes(str);
if (bstr.length > 31) {
revert StringTooLong(str);
}
return ShortString.wrap(bytes32(uint256(bytes32(bstr)) | bstr.length));
}
/**
* @dev Decode a `ShortString` back to a "normal" string.
*/
function toString(ShortString sstr) internal pure returns (string memory) {
uint256 len = byteLength(sstr);
// using `new string(len)` would work locally but is not memory safe.
string memory str = new string(32);
/// @solidity memory-safe-assembly
assembly {
mstore(str, len)
mstore(add(str, 0x20), sstr)
}
return str;
}
/**
* @dev Return the length of a `ShortString`.
*/
function byteLength(ShortString sstr) internal pure returns (uint256) {
uint256 result = uint256(ShortString.unwrap(sstr)) & 0xFF;
if (result > 31) {
revert InvalidShortString();
}
return result;
}
/**
* @dev Encode a string into a `ShortString`, or write it to storage if it is too long.
*/
function toShortStringWithFallback(string memory value, string storage store) internal returns (ShortString) {
if (bytes(value).length < 32) {
return toShortString(value);
} else {
StorageSlot.getStringSlot(store).value = value;
return ShortString.wrap(FALLBACK_SENTINEL);
}
}
/**
* @dev Decode a string that was encoded to `ShortString` or written to storage using {setWithFallback}.
*/
function toStringWithFallback(ShortString value, string storage store) internal pure returns (string memory) {
if (ShortString.unwrap(value) != FALLBACK_SENTINEL) {
return toString(value);
} else {
return store;
}
}
/**
* @dev Return the length of a string that was encoded to `ShortString` or written to storage using
* {setWithFallback}.
*
* WARNING: This will return the "byte length" of the string. This may not reflect the actual length in terms of
* actual characters as the UTF-8 encoding of a single character can span over multiple bytes.
*/
function byteLengthWithFallback(ShortString value, string storage store) internal view returns (uint256) {
if (ShortString.unwrap(value) != FALLBACK_SENTINEL) {
return byteLength(value);
} else {
return bytes(store).length;
}
}
}// 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.24;
interface ZeroAddressError {
/// @notice Error thrown when the address is zero
error ZeroAddress();
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.24;
interface ITeaFiMysteryBoxManager {
/**
* @notice Represents a mystery box issued to a user.
* @param id Unique identifier of the box.
* @param issuedAt Timestamp (in seconds) when the box was issued.
* @param rewardInfo Encoded reward data associated with the box.
*/
struct Box {
uint256 id;
uint64 issuedAt;
bytes rewardInfo;
}
/**
* @notice Represents a fee payment (either native or ERC20) required to open a box.
* @param token Address of the token used for payment (zero address for native currency).
* @param amount Amount to be paid.
* @param tokenData The token permit signature.
* @param permit2Data The permit2 signature.
*/
struct Fee {
address token;
uint256 amount;
bytes tokenData;
bytes permit2Data;
}
/**
* @notice Parameters required to open a mystery box, including box info, payment, and user signature.
* @param box The mystery box being opened.
* @param fee Payment details (token, amount, optional permit data).
* @param operator The address of the operator that signed `OpenBoxParam` payload.
* @param nonce Unique nonce used to prevent replay of the user's signature.
* @param deadline Expiration timestamp for the signature.
* @param v Component of the user's signature.
* @param r Component of the user's signature.
* @param s Component of the user's signature.
*/
struct OpenBoxParam {
Box box;
Fee fee;
address operator;
uint256 nonce;
uint256 deadline;
uint8 v;
bytes32 r;
bytes32 s;
}
/**
* @notice Emitted when a mystery box is successfully opened.
* @param id Unique identifier of the opened box.
* @param receiver Address of the user receiving the reward.
* @param feeToken Token used to pay the fee (zero address for native currency).
* @param feeAmount Amount of fee paid.
* @param issuedAt Timestamp when the box was issued.
* @param rewardInfo Encoded reward data revealed upon opening.
*/
event BoxOpened(
uint256 indexed id,
address indexed receiver,
address indexed feeToken,
uint256 feeAmount,
uint64 issuedAt,
bytes rewardInfo
);
/**
* @notice Reverts when the provided signature is invalid or has been tampered with.
* @param errorReason Human-readable explanation for signature validation failure.
*/
error InvalidSignature(string errorReason);
/**
* @notice Reverts when the provided box data is malformed or does not meet expected constraints.
* @param errorReason Human-readable explanation for box validation failure.
*/
error InvalidBox(string errorReason);
/// @notice Reverts when provided ETH or token value is insufficient or incorrect.
error InvalidValue();
/// @notice Reverts when a native currency transfer is attempted for a non-native token.
error NotNativeTransfer();
/**
* @notice Opens a mystery box and distributes its associated reward to the caller.
* @dev Requires a valid user signature and may involve native or ERC20 fee payments.
* @param param All required parameters including box details, fee payment, and signature.
*/
function openMysteryBox(OpenBoxParam calldata param) external payable;
}// SPDX-License-Identifier: UNLICENSED
pragma solidity =0.8.24;
import {ZeroAddressError} from "../../interfaces/ZeroAddressError.sol";
interface IPermitManager is ZeroAddressError {
/**
* @notice Parameters structure for permit transfers
* @dev Contains all necessary data for executing transfers with permits
* @param token The token address to be transferred
* @param owner The address that owns the tokens
* @param recipient The address that will receive the tokens
* @param amount The amount of tokens to transfer
* @param tokenData The data for EIP-2612 permit if used
* @param permit2Data The data for Permit2 if used
*/
struct PermitTransferParams {
address token;
address owner;
address recipient;
uint256 amount;
bytes tokenData;
bytes permit2Data;
}
/**
* @notice Executes multiple permit transfers in one transaction
* @dev Restricted to addresses with SPENDER_ROLE
* @param params Array of parameters for each transfer
*/
function executePermitTransferBatch(PermitTransferParams[] calldata params) external;
/**
* @notice Executes a single permit transfer
* @dev Restricted to addresses with SPENDER_ROLE
* @param params The parameters for the transfer
*/
function executePermitTransfer(PermitTransferParams calldata params) external;
/**
* @notice Adds multiple addresses to the list of authorized spenders
* @dev Restricted to addresses with DEFAULT_ADMIN_ROLE
* @param spenders Array of addresses to add as authorized spenders
*/
function addSpenders(address[] calldata spenders) external;
/**
* @notice Removes multiple addresses from the list of authorized spenders
* @dev Restricted to addresses with DEFAULT_ADMIN_ROLE
* @param spenders Array of addresses to remove from authorized spenders
*/
function removeSpenders(address[] calldata spenders) external;
}// SPDX-License-Identifier: UNLICENSED
pragma solidity =0.8.24;
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {Context} from "@openzeppelin/contracts/utils/Context.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {IPermitManager} from "./interfaces/IPermitManager.sol";
import {ZeroAddressError} from "../interfaces/ZeroAddressError.sol";
abstract contract PermitManagement is ZeroAddressError, Context {
using SafeERC20 for IERC20;
/// @notice The permit manager address that handles the permit transfer
IPermitManager public immutable permitManager;
/**
* @dev Constructor
* @param permitManager_ The address of the PermitManager contract
*/
constructor(address permitManager_) {
if (permitManager_ == address(0)) revert ZeroAddress();
permitManager = IPermitManager(permitManager_);
}
/**
* @dev _receivePayment execute the permit transfer to receive payment from the user
* @param token The token address
* @param recipient The address that will receive the tokens
* @param amount The amount of the payment
* @param tokenPermitSignature The token permit signature (EIP-2612 or DAI)
* @param permitSingleSignature The permit single signature (Permit2)
*/
function _receivePayment(
address token,
address recipient,
uint256 amount,
bytes memory tokenPermitSignature,
bytes memory permitSingleSignature
) internal virtual {
address owner = _msgSender();
// in case if the classic token allowance is used
if (IERC20(token).allowance(owner, address(this)) >= amount) {
IERC20(token).safeTransferFrom(owner, recipient, amount);
return;
}
IPermitManager.PermitTransferParams memory params = IPermitManager.PermitTransferParams({
token: token,
owner: owner,
recipient: recipient,
amount: amount,
tokenData: tokenPermitSignature,
permit2Data: permitSingleSignature
});
permitManager.executePermitTransfer(params);
}
}{
"optimizer": {
"enabled": true,
"runs": 200
},
"viaIR": true,
"evmVersion": "paris",
"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":"owner","type":"address"},{"internalType":"address","name":"trustedForwarder_","type":"address"},{"internalType":"address","name":"operator","type":"address"},{"internalType":"address","name":"treasury_","type":"address"},{"internalType":"address","name":"permitManager_","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":[{"internalType":"address","name":"target","type":"address"}],"name":"AddressEmptyCode","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"AddressInsufficientBalance","type":"error"},{"inputs":[],"name":"ECDSAInvalidSignature","type":"error"},{"inputs":[{"internalType":"uint256","name":"length","type":"uint256"}],"name":"ECDSAInvalidSignatureLength","type":"error"},{"inputs":[{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"ECDSAInvalidSignatureS","type":"error"},{"inputs":[],"name":"FailedInnerCall","type":"error"},{"inputs":[{"internalType":"string","name":"errorReason","type":"string"}],"name":"InvalidBox","type":"error"},{"inputs":[],"name":"InvalidShortString","type":"error"},{"inputs":[{"internalType":"string","name":"errorReason","type":"string"}],"name":"InvalidSignature","type":"error"},{"inputs":[],"name":"InvalidValue","type":"error"},{"inputs":[],"name":"NotNativeTransfer","type":"error"},{"inputs":[],"name":"ReentrancyGuardReentrantCall","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"inputs":[{"internalType":"string","name":"str","type":"string"}],"name":"StringTooLong","type":"error"},{"inputs":[],"name":"ZeroAddress","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":true,"internalType":"address","name":"feeToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"feeAmount","type":"uint256"},{"indexed":false,"internalType":"uint64","name":"issuedAt","type":"uint64"},{"indexed":false,"internalType":"bytes","name":"rewardInfo","type":"bytes"}],"name":"BoxOpened","type":"event"},{"anonymous":false,"inputs":[],"name":"EIP712DomainChanged","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"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"OPEN_MYSTERY_BOX_TYPEHASH","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"OPERATOR_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"eip712Domain","outputs":[{"internalType":"bytes1","name":"fields","type":"bytes1"},{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"version","type":"string"},{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"address","name":"verifyingContract","type":"address"},{"internalType":"bytes32","name":"salt","type":"bytes32"},{"internalType":"uint256[]","name":"extensions","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"structHash","type":"bytes32"}],"name":"hashTypedDataV4","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"forwarder","type":"address"}],"name":"isTrustedForwarder","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"lastClaimedDay","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"components":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint64","name":"issuedAt","type":"uint64"},{"internalType":"bytes","name":"rewardInfo","type":"bytes"}],"internalType":"struct ITeaFiMysteryBoxManager.Box","name":"box","type":"tuple"},{"components":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"tokenData","type":"bytes"},{"internalType":"bytes","name":"permit2Data","type":"bytes"}],"internalType":"struct ITeaFiMysteryBoxManager.Fee","name":"fee","type":"tuple"},{"internalType":"address","name":"operator","type":"address"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct ITeaFiMysteryBoxManager.OpenBoxParam","name":"param","type":"tuple"}],"name":"openMysteryBox","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"address","name":"caller","type":"address"}],"name":"operatorUserNonces","outputs":[{"internalType":"uint256","name":"nonce","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"permitManager","outputs":[{"internalType":"contract IPermitManager","name":"","type":"address"}],"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":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"treasury","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"trustedForwarder","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}]Contract Creation Code
6101c034620002ca576001600160401b0390601f620020dd38819003918201601f1916830192919084841183851017620002a3578160a09284926040968752833981010312620002ca576200005481620002eb565b926200006360208301620002eb565b9362000071848401620002eb565b916200008e60806200008660608701620002eb565b9501620002eb565b948051936200009d85620002cf565b6016855260208501937f54656146694d797374657279426f784d616e61676572000000000000000000008552825197620000d789620002cf565b60038952620312e360ec1b60208a01908152946001600160a01b039182168015620002b95760805260016000558a60a05262000113886200043e565b96610160978852620001258b6200061b565b98610180998a52519020956101209a878c5251902095610140968088524660e05286519060208201927f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f84528883015260608201524660808201523060a082015260a0815260c081019281841090841117620002a35782875251902060c0526101009a308c52828086161591821562000297575b82156200028b575b5050801562000280575b620002715750620001f09291620001e9916101a09916895262000300565b506200038e565b505194611897968762000826883960805187818161013a0152611287015260a0518781816103a6015281816109980152610e9e015260c05187610f43015260e0518761100e01525186610f0d01525185610f9201525184610fb8015251836102650152518261028f015251818181610728015281816107fb01526109480152f35b63d92e233d60e01b8152600490fd5b5081891615620001cb565b161590508238620001c1565b858216159250620001b9565b634e487b7160e01b600052604160045260246000fd5b855163d92e233d60e01b8152600490fd5b600080fd5b604081019081106001600160401b03821117620002a357604052565b51906001600160a01b0382168203620002ca57565b6001600160a01b0390811660008181527fa6eef7e35abe7026729641147f7915573c7e97b47efa546f5f6e3230263bcb49602052604081205490929060ff16620003895782805260016020526040832082845260205260408320600160ff198254161790556200036f620007d0565b1691600080516020620020bd8339815191528180a4600190565b505090565b6001600160a01b0390811660008181527f31c1e66639f421f1853aeefe8ad6b62a3b96f3287efe23106923cd924aa025c2602052604081205490927f97667070c54ef182b0f5858b034beac1b6f3089aa2d3188bb1e8929f4fa9b9299160ff166200043857600080516020620020bd8339815191529082855260016020526040852084865260205260408520600160ff198254161790556200042f620007d0565b169380a4600190565b50505090565b805160209081811015620004db5750601f8251116200047a57808251920151908083106200046b57501790565b82600019910360031b1b161790565b90604051809263305a27a960e01b82528060048301528251908160248401526000935b828510620004c1575050604492506000838284010152601f80199101168101030190fd5b84810182015186860160440152938101938593506200049d565b906001600160401b038211620002a357600254926001938481811c9116801562000610575b83821014620005fa57601f8111620005c0575b5081601f841160011462000554575092829391839260009462000548575b50501b916000199060031b1c19161760025560ff90565b01519250388062000531565b919083601f198116600260005284600020946000905b88838310620005a557505050106200058b575b505050811b0160025560ff90565b015160001960f88460031b161c191690553880806200057d565b8587015188559096019594850194879350908101906200056a565b600260005284601f84600020920160051c820191601f860160051c015b828110620005ed57505062000513565b60008155018590620005dd565b634e487b7160e01b600052602260045260246000fd5b90607f169062000500565b80516020919082811015620006ab575090601f8251116200064a57808251920151908083106200046b57501790565b90604051809263305a27a960e01b82528060048301528251908160248401526000935b82851062000691575050604492506000838284010152601f80199101168101030190fd5b84810182015186860160440152938101938593506200066d565b6001600160401b038111620002a3576003928354926001938481811c91168015620007c5575b83821014620005fa57601f81116200078c575b5081601f841160011462000723575092829391839260009462000717575b50501b9160001990841b1c191617905560ff90565b01519250388062000702565b919083601f1981168760005284600020946000905b8883831062000771575050501062000758575b505050811b01905560ff90565b015160001983861b60f8161c191690553880806200074b565b85870151885590960195948501948793509081019062000738565b8560005284601f84600020920160051c820191601f860160051c015b828110620007b8575050620006e4565b60008155018590620007a8565b90607f1690620006d1565b60a0516001600160a01b031633148062000819575b1562000815576013193601368111620007ff573560601c90565b634e487b7160e01b600052601160045260246000fd5b3390565b506014361015620007e556fe608080604052600436101561001357600080fd5b600090813560e01c90816301ffc9a714610b1257508063248a9ca314610ae657806329e6d68114610aa35780632f2ff15d14610a6557806336568abe14610a135780634980f288146109cc578063572b6c051461097757806361d027b3146109325780637d5597ad146103d55780637da0a87714610390578063841ec13a1461034557806384b0196e1461024b57806389010d701461021057806391d14854146101c7578063a217fddf146101ab578063d547741f14610169578063df890592146101245763f5b541a6146100e757600080fd5b3461012157806003193601126101215760206040517f97667070c54ef182b0f5858b034beac1b6f3089aa2d3188bb1e8929f4fa9b9298152f35b80fd5b50346101215780600319360112610121576040517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b5034610121576040366003190112610121576101a7600435610189610b86565b9080845260016020526101a26001604086200154610cee565b610dd0565b5080f35b5034610121578060031936011261012157602090604051908152f35b50346101215760403660031901126101215760ff60406020926101e8610b86565b6004358252600185528282206001600160a01b03909116825284522054604051911615158152f35b503461012157806003193601126101215760206040517fe2a460efd37a9898f0753d260c27d5120a982834718ef11e7eefae5f217a82668152f35b50346101215780600319360112610121576102e8906102897f00000000000000000000000000000000000000000000000000000000000000006114f7565b906102b37f0000000000000000000000000000000000000000000000000000000000000000611623565b90604051916102c183610c81565b8183526102f6602091604051968796600f60f81b885260e0602089015260e0880190610b9c565b908682036040880152610b9c565b904660608601523060808601528260a086015284820360c0860152602080855193848152019401925b82811061032e57505050500390f35b83518552869550938101939281019260010161031f565b5034610121576040366003190112610121576040602091610364610b6b565b61036c610b86565b6001600160a01b039182168352600485528383209116825283522054604051908152f35b50346101215780600319360112610121576040517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b5060031960203682011261092e576001600160401b036004351161092e57610100600435600401916004353603011261092e57600282541461091c57600282556001600160401b03610432602061042c8480610bf1565b01610c1a565b16156108e657610447602061042c8380610bf1565b6001600160401b03429116116108ab576001600160a01b03610467610e9b565b16825260056020526001600160401b036040832054166201518042041461086d576104928180610bf1565b356105886104a5602061042c8580610bf1565b916104bd6104b38580610bf1565b6040810190610c2e565b6104c5610e9b565b916104dd6104d860246004350189610bdc565b610c06565b61054860206104f16024600435018b610bdc565b0135926001600160401b03604051998a987fe2a460efd37a9898f0753d260c27d5120a982834718ef11e7eefae5f217a826660208b015260408a015216606088015261012094856080890152610140880191610c60565b6001600160a01b0394851660a0870152931660c085015260e08401526004356064810135610100850152608401359083015203601f198101835282610ccd565b610590610e9b565b9061059f604460043501610c06565b60a4600435013560ff81168103610869576105d99360e460043501359360c460043501359360846004350135926064600435013592611034565b9015610840575060206105f160246004350183610bdc565b01356106f2575b6001600160a01b03610608610e9b565b168252600560205260408220805467ffffffffffffffff19166201518042046001600160401b031617905561063d8180610bf1565b3590610647610e9b565b917faaac0bdbdab9f1aab57f2d6e7ddaeb94c80e78f00f2017ead22b21c5e7989c3e61067b6104d860246004350185610bdc565b92602061068d60246004350183610bdc565b01356106e86106ae6104b36106a7602061042c8780610bf1565b9480610bf1565b966001600160401b0360405195869586521660208501526060604085015260018060a01b03169760018060a01b0316966060840191610c60565b0390a46001815580f35b61070160246004350182610bdc565b6001600160a01b0361071282610c06565b166107ac576020013580341061079a5761074c817f00000000000000000000000000000000000000000000000000000000000000006114a2565b80341161075a575b506105f8565b6001600160a01b0361076a610e9b565b16903403903482116107865790610780916114a2565b38610754565b634e487b7160e01b84526011600452602484fd5b604051632a9ffab760e21b8152600490fd5b3461082e57806107f56107c161082993610c06565b60206107d06040850185610c2e565b6107ed6107e36060889794970188610c2e565b9690923691610e64565b943691610e64565b930135907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906111e5565b6105f8565b604051630cb04f0f60e21b8152600490fd5b60405163151a7bff60e11b815260206004820152908190610865906024830190610b9c565b0390fd5b8580fd5b604051634df0d66160e11b8152602060048201526015602482015274416c726561647920636c61696d656420746f64617960581b6044820152606490fd5b604051634df0d66160e11b8152602060048201526012602482015271109bde081b9bdd081a5cdcdd5959081e595d60721b6044820152606490fd5b604051634df0d66160e11b815260206004820152600d60248201526c04973737565644174206973203609c1b6044820152606490fd5b604051633ee5aeb560e01b8152600490fd5b5080fd5b50346101215780600319360112610121576040517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b5034610121576020366003190112610121576020610993610b6b565b6040517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b039081169216919091148152f35b5034610121576020366003190112610121576020610a0b6004356109ee610f0a565b6042916040519161190160f01b8352600283015260228201522090565b604051908152f35b503461012157604036600319011261012157610a2d610b86565b6001600160a01b0380610a3e610e9b565b1690821603610a53576101a790600435610dd0565b60405163334bd91960e11b8152600490fd5b5034610121576040366003190112610121576101a7600435610a85610b86565b908084526001602052610a9e6001604086200154610cee565b610d46565b5034610121576020366003190112610121576020906001600160401b03906040906001600160a01b03610ad4610b6b565b16815260058452205416604051908152f35b503461012157602036600319011261012157600160406020926004358152828452200154604051908152f35b90503461092e57602036600319011261092e5760043563ffffffff60e01b8116809103610b675760209250637965db0b60e01b8114908115610b56575b5015158152f35b6301ffc9a760e01b14905038610b4f565b8280fd5b600435906001600160a01b0382168203610b8157565b600080fd5b602435906001600160a01b0382168203610b8157565b919082519283825260005b848110610bc8575050826000602080949584010152601f8019910116010190565b602081830181015184830182015201610ba7565b903590607e1981360301821215610b81570190565b903590605e1981360301821215610b81570190565b356001600160a01b0381168103610b815790565b356001600160401b0381168103610b815790565b903590601e1981360301821215610b8157018035906001600160401b038211610b8157602001918136038313610b8157565b908060209392818452848401376000828201840152601f01601f1916010190565b602081019081106001600160401b03821117610c9c57604052565b634e487b7160e01b600052604160045260246000fd5b604081019081106001600160401b03821117610c9c57604052565b90601f801991011681019081106001600160401b03821117610c9c57604052565b610cf6610e9b565b9080600052600160205260406000209160018060a01b0316918260005260205260ff6040600020541615610d28575050565b604492506040519163e2517d3f60e01b835260048301526024820152fd5b60008181526001602090815260408083206001600160a01b039586168085529252822054919390929160ff16610dca577f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9082855260016020526040852084865260205260408520600160ff19825416179055610dc1610e9b565b169380a4600190565b50505090565b60008181526001602090815260408083206001600160a01b039586168085529252822054919390929160ff1615610dca577ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b908285526001602052604085208486526020526040852060ff198154169055610dc1610e9b565b6001600160401b038111610c9c57601f01601f191660200190565b929192610e7082610e49565b91610e7e6040519384610ccd565b829481845281830111610b81578281602093846000960137010152565b337f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03161480610eff575b15610efb576013193601368111610ee5573560601c90565b634e487b7160e01b600052601160045260246000fd5b3390565b506014361015610ecd565b307f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316148061100b575b15610f65577f000000000000000000000000000000000000000000000000000000000000000090565b60405160208101907f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f82527f000000000000000000000000000000000000000000000000000000000000000060408201527f000000000000000000000000000000000000000000000000000000000000000060608201524660808201523060a082015260a0815260c081018181106001600160401b03821117610c9c5760405251902090565b507f00000000000000000000000000000000000000000000000000000000000000004614610f3c565b6001600160a01b0392831660008181527f31c1e66639f421f1853aeefe8ad6b62a3b96f3287efe23106923cd924aa025c26020908152604080832054909c9b929a91999398969792969195939493919060ff161580156111dd575b6111a857421161117d57878a52600489528b8a209087168a5288528a8920805491906000198314611169576001830190550361113557916110ee93916110e084896110e596519101206109ee610f0a565b6116fb565b9092919261178b565b16036111085750600192519061110382610c81565b815290565b9070494e56414c49445f5349474e415455524560781b9093519161112b83610cb2565b6011835282015290565b50505050505090714d49534d41544348494e475f4e4f4e43455360701b9093519161115f83610cb2565b6012835282015290565b634e487b7160e01b8b52601160045260248bfd5b5050505050505050907014d251d3905515549157d1561412549151607a1b9093519161112b83610cb2565b505050505050505050906f24a72b20a624a22fa7a822a920aa27a960811b909351916111d383610cb2565b6010835282015290565b50881561108f565b9392906111f0610e9b565b9160018060a01b038096169260409587875192636eb1769f60e11b84521692836004840152602496308885015260209384816044818b5afa90811561146757908291600091611436575b50101561136f5788519460c08601976001600160401b03988781108a82111761135a578b5286528486019081528a8a870197168752606086019182526080860192835260a086019384528a7f00000000000000000000000000000000000000000000000000000000000000001696873b15610b81578b80928c519d8e998a996309c5399f60e11b8b5260048b015251168c89015251166044870152511660648501525160848401525160a4830160c0905260e483016112f891610b9c565b90518282036023190160c48401526113109190610b9c565b03815a6000948591f1801561134f5761132a575b50505050565b831161133b57505238808080611324565b634e487b7160e01b60009081526041600452fd5b83513d6000823e3d90fd5b8a634e487b7160e01b60005260416004526000fd5b9295979698915050859392935192858401946323b872dd60e01b86528985015216604483015260648201526064815260a081018181106001600160401b03821117611421578452516113d391600091829182885af16113cc611472565b9085611810565b8051918215159182611400575b505090506113ed57505050565b5190635274afe760e01b82526004820152fd5b809250819381010312610b81570151801590811503610b81578038806113e0565b86634e487b7160e01b60005260416004526000fd5b809250868092503d8311611460575b61144f8183610ccd565b81010312610b81578190513861123a565b503d611445565b8a513d6000823e3d90fd5b3d1561149d573d9061148382610e49565b916114916040519384610ccd565b82523d6000602084013e565b606090565b8147106114df576000918291829182916001600160a01b03165af16114c5611472565b50156114cd57565b604051630a12f52160e11b8152600490fd5b60405163cd78605960e01b8152306004820152602490fd5b60ff81146115355760ff811690601f8211611523576040519161151983610cb2565b8252602082015290565b604051632cd44ac360e21b8152600490fd5b5060405160006002549060018260011c9060018416938415611619575b602094858410811461160557838752869493929181156115e55750600114611586575b505061158392500382610ccd565b90565b9093915060026000527f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace936000915b8183106115cd57505061158393508201013880611575565b855487840185015294850194869450918301916115b5565b91505061158394925060ff191682840152151560051b8201013880611575565b634e487b7160e01b85526022600452602485fd5b91607f1691611552565b60ff81146116455760ff811690601f8211611523576040519161151983610cb2565b5060405160006003549060018260011c90600184169384156116f1575b602094858410811461160557838752869493929181156115e5575060011461169257505061158392500382610ccd565b9093915060036000527fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b936000915b8183106116d957505061158393508201013880611575565b855487840185015294850194869450918301916116c1565b91607f1691611662565b91907f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0841161177f57926020929160ff608095604051948552168484015260408301526060820152600092839182805260015afa156117735780516001600160a01b0381161561176a57918190565b50809160019190565b604051903d90823e3d90fd5b50505060009160039190565b60048110156117fa578061179d575050565b600181036117b75760405163f645eedf60e01b8152600490fd5b600281036117d85760405163fce698f760e01b815260048101839052602490fd5b6003146117e25750565b602490604051906335e2f38360e21b82526004820152fd5b634e487b7160e01b600052602160045260246000fd5b9061182557508051156114cd57805190602001fd5b81511580611858575b611836575090565b604051639996b31560e01b81526001600160a01b039091166004820152602490fd5b50803b1561182e56fea26469706673582212201fce5f0d5a2edf46cba287858900c88e134db3d55e62676ae1873432f0eac40864736f6c634300081800332f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d00000000000000000000000080445f96ee0f218f5eeebee0ba8ec504e5de9526000000000000000000000000e28542c3536f2d82df1a401c9e711b6d0baf6a4500000000000000000000000075bc1a2b308c5b5ff18e8865c3b435525e22ae0d00000000000000000000000080445f96ee0f218f5eeebee0ba8ec504e5de9526000000000000000000000000ff7ba7b0c19868d2bde40516b94cf069d277f742
Deployed Bytecode
0x608080604052600436101561001357600080fd5b600090813560e01c90816301ffc9a714610b1257508063248a9ca314610ae657806329e6d68114610aa35780632f2ff15d14610a6557806336568abe14610a135780634980f288146109cc578063572b6c051461097757806361d027b3146109325780637d5597ad146103d55780637da0a87714610390578063841ec13a1461034557806384b0196e1461024b57806389010d701461021057806391d14854146101c7578063a217fddf146101ab578063d547741f14610169578063df890592146101245763f5b541a6146100e757600080fd5b3461012157806003193601126101215760206040517f97667070c54ef182b0f5858b034beac1b6f3089aa2d3188bb1e8929f4fa9b9298152f35b80fd5b50346101215780600319360112610121576040517f000000000000000000000000ff7ba7b0c19868d2bde40516b94cf069d277f7426001600160a01b03168152602090f35b5034610121576040366003190112610121576101a7600435610189610b86565b9080845260016020526101a26001604086200154610cee565b610dd0565b5080f35b5034610121578060031936011261012157602090604051908152f35b50346101215760403660031901126101215760ff60406020926101e8610b86565b6004358252600185528282206001600160a01b03909116825284522054604051911615158152f35b503461012157806003193601126101215760206040517fe2a460efd37a9898f0753d260c27d5120a982834718ef11e7eefae5f217a82668152f35b50346101215780600319360112610121576102e8906102897f54656146694d797374657279426f784d616e61676572000000000000000000166114f7565b906102b37f312e300000000000000000000000000000000000000000000000000000000003611623565b90604051916102c183610c81565b8183526102f6602091604051968796600f60f81b885260e0602089015260e0880190610b9c565b908682036040880152610b9c565b904660608601523060808601528260a086015284820360c0860152602080855193848152019401925b82811061032e57505050500390f35b83518552869550938101939281019260010161031f565b5034610121576040366003190112610121576040602091610364610b6b565b61036c610b86565b6001600160a01b039182168352600485528383209116825283522054604051908152f35b50346101215780600319360112610121576040517f000000000000000000000000e28542c3536f2d82df1a401c9e711b6d0baf6a456001600160a01b03168152602090f35b5060031960203682011261092e576001600160401b036004351161092e57610100600435600401916004353603011261092e57600282541461091c57600282556001600160401b03610432602061042c8480610bf1565b01610c1a565b16156108e657610447602061042c8380610bf1565b6001600160401b03429116116108ab576001600160a01b03610467610e9b565b16825260056020526001600160401b036040832054166201518042041461086d576104928180610bf1565b356105886104a5602061042c8580610bf1565b916104bd6104b38580610bf1565b6040810190610c2e565b6104c5610e9b565b916104dd6104d860246004350189610bdc565b610c06565b61054860206104f16024600435018b610bdc565b0135926001600160401b03604051998a987fe2a460efd37a9898f0753d260c27d5120a982834718ef11e7eefae5f217a826660208b015260408a015216606088015261012094856080890152610140880191610c60565b6001600160a01b0394851660a0870152931660c085015260e08401526004356064810135610100850152608401359083015203601f198101835282610ccd565b610590610e9b565b9061059f604460043501610c06565b60a4600435013560ff81168103610869576105d99360e460043501359360c460043501359360846004350135926064600435013592611034565b9015610840575060206105f160246004350183610bdc565b01356106f2575b6001600160a01b03610608610e9b565b168252600560205260408220805467ffffffffffffffff19166201518042046001600160401b031617905561063d8180610bf1565b3590610647610e9b565b917faaac0bdbdab9f1aab57f2d6e7ddaeb94c80e78f00f2017ead22b21c5e7989c3e61067b6104d860246004350185610bdc565b92602061068d60246004350183610bdc565b01356106e86106ae6104b36106a7602061042c8780610bf1565b9480610bf1565b966001600160401b0360405195869586521660208501526060604085015260018060a01b03169760018060a01b0316966060840191610c60565b0390a46001815580f35b61070160246004350182610bdc565b6001600160a01b0361071282610c06565b166107ac576020013580341061079a5761074c817f00000000000000000000000080445f96ee0f218f5eeebee0ba8ec504e5de95266114a2565b80341161075a575b506105f8565b6001600160a01b0361076a610e9b565b16903403903482116107865790610780916114a2565b38610754565b634e487b7160e01b84526011600452602484fd5b604051632a9ffab760e21b8152600490fd5b3461082e57806107f56107c161082993610c06565b60206107d06040850185610c2e565b6107ed6107e36060889794970188610c2e565b9690923691610e64565b943691610e64565b930135907f00000000000000000000000080445f96ee0f218f5eeebee0ba8ec504e5de95266001600160a01b0316906111e5565b6105f8565b604051630cb04f0f60e21b8152600490fd5b60405163151a7bff60e11b815260206004820152908190610865906024830190610b9c565b0390fd5b8580fd5b604051634df0d66160e11b8152602060048201526015602482015274416c726561647920636c61696d656420746f64617960581b6044820152606490fd5b604051634df0d66160e11b8152602060048201526012602482015271109bde081b9bdd081a5cdcdd5959081e595d60721b6044820152606490fd5b604051634df0d66160e11b815260206004820152600d60248201526c04973737565644174206973203609c1b6044820152606490fd5b604051633ee5aeb560e01b8152600490fd5b5080fd5b50346101215780600319360112610121576040517f00000000000000000000000080445f96ee0f218f5eeebee0ba8ec504e5de95266001600160a01b03168152602090f35b5034610121576020366003190112610121576020610993610b6b565b6040517f000000000000000000000000e28542c3536f2d82df1a401c9e711b6d0baf6a456001600160a01b039081169216919091148152f35b5034610121576020366003190112610121576020610a0b6004356109ee610f0a565b6042916040519161190160f01b8352600283015260228201522090565b604051908152f35b503461012157604036600319011261012157610a2d610b86565b6001600160a01b0380610a3e610e9b565b1690821603610a53576101a790600435610dd0565b60405163334bd91960e11b8152600490fd5b5034610121576040366003190112610121576101a7600435610a85610b86565b908084526001602052610a9e6001604086200154610cee565b610d46565b5034610121576020366003190112610121576020906001600160401b03906040906001600160a01b03610ad4610b6b565b16815260058452205416604051908152f35b503461012157602036600319011261012157600160406020926004358152828452200154604051908152f35b90503461092e57602036600319011261092e5760043563ffffffff60e01b8116809103610b675760209250637965db0b60e01b8114908115610b56575b5015158152f35b6301ffc9a760e01b14905038610b4f565b8280fd5b600435906001600160a01b0382168203610b8157565b600080fd5b602435906001600160a01b0382168203610b8157565b919082519283825260005b848110610bc8575050826000602080949584010152601f8019910116010190565b602081830181015184830182015201610ba7565b903590607e1981360301821215610b81570190565b903590605e1981360301821215610b81570190565b356001600160a01b0381168103610b815790565b356001600160401b0381168103610b815790565b903590601e1981360301821215610b8157018035906001600160401b038211610b8157602001918136038313610b8157565b908060209392818452848401376000828201840152601f01601f1916010190565b602081019081106001600160401b03821117610c9c57604052565b634e487b7160e01b600052604160045260246000fd5b604081019081106001600160401b03821117610c9c57604052565b90601f801991011681019081106001600160401b03821117610c9c57604052565b610cf6610e9b565b9080600052600160205260406000209160018060a01b0316918260005260205260ff6040600020541615610d28575050565b604492506040519163e2517d3f60e01b835260048301526024820152fd5b60008181526001602090815260408083206001600160a01b039586168085529252822054919390929160ff16610dca577f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9082855260016020526040852084865260205260408520600160ff19825416179055610dc1610e9b565b169380a4600190565b50505090565b60008181526001602090815260408083206001600160a01b039586168085529252822054919390929160ff1615610dca577ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b908285526001602052604085208486526020526040852060ff198154169055610dc1610e9b565b6001600160401b038111610c9c57601f01601f191660200190565b929192610e7082610e49565b91610e7e6040519384610ccd565b829481845281830111610b81578281602093846000960137010152565b337f000000000000000000000000e28542c3536f2d82df1a401c9e711b6d0baf6a456001600160a01b03161480610eff575b15610efb576013193601368111610ee5573560601c90565b634e487b7160e01b600052601160045260246000fd5b3390565b506014361015610ecd565b307f00000000000000000000000093f6b676848ebbdbbe9647996f0a046c1d947a436001600160a01b0316148061100b575b15610f65577ff05f83e5083922332fbf12d80520be45c55343662d15d24b0e1862f13cdc9e9e90565b60405160208101907f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f82527f5dea60f3ee4e6b7440acae89b18f7a0ce3fec225499fc9aaa6141bd821cc5c5a60408201527fe6bbd6277e1bf288eed5e8d1780f9a50b239e86b153736bceebccf4ea79d90b360608201524660808201523060a082015260a0815260c081018181106001600160401b03821117610c9c5760405251902090565b507f00000000000000000000000000000000000000000000000000000000000b67d24614610f3c565b6001600160a01b0392831660008181527f31c1e66639f421f1853aeefe8ad6b62a3b96f3287efe23106923cd924aa025c26020908152604080832054909c9b929a91999398969792969195939493919060ff161580156111dd575b6111a857421161117d57878a52600489528b8a209087168a5288528a8920805491906000198314611169576001830190550361113557916110ee93916110e084896110e596519101206109ee610f0a565b6116fb565b9092919261178b565b16036111085750600192519061110382610c81565b815290565b9070494e56414c49445f5349474e415455524560781b9093519161112b83610cb2565b6011835282015290565b50505050505090714d49534d41544348494e475f4e4f4e43455360701b9093519161115f83610cb2565b6012835282015290565b634e487b7160e01b8b52601160045260248bfd5b5050505050505050907014d251d3905515549157d1561412549151607a1b9093519161112b83610cb2565b505050505050505050906f24a72b20a624a22fa7a822a920aa27a960811b909351916111d383610cb2565b6010835282015290565b50881561108f565b9392906111f0610e9b565b9160018060a01b038096169260409587875192636eb1769f60e11b84521692836004840152602496308885015260209384816044818b5afa90811561146757908291600091611436575b50101561136f5788519460c08601976001600160401b03988781108a82111761135a578b5286528486019081528a8a870197168752606086019182526080860192835260a086019384528a7f000000000000000000000000ff7ba7b0c19868d2bde40516b94cf069d277f7421696873b15610b81578b80928c519d8e998a996309c5399f60e11b8b5260048b015251168c89015251166044870152511660648501525160848401525160a4830160c0905260e483016112f891610b9c565b90518282036023190160c48401526113109190610b9c565b03815a6000948591f1801561134f5761132a575b50505050565b831161133b57505238808080611324565b634e487b7160e01b60009081526041600452fd5b83513d6000823e3d90fd5b8a634e487b7160e01b60005260416004526000fd5b9295979698915050859392935192858401946323b872dd60e01b86528985015216604483015260648201526064815260a081018181106001600160401b03821117611421578452516113d391600091829182885af16113cc611472565b9085611810565b8051918215159182611400575b505090506113ed57505050565b5190635274afe760e01b82526004820152fd5b809250819381010312610b81570151801590811503610b81578038806113e0565b86634e487b7160e01b60005260416004526000fd5b809250868092503d8311611460575b61144f8183610ccd565b81010312610b81578190513861123a565b503d611445565b8a513d6000823e3d90fd5b3d1561149d573d9061148382610e49565b916114916040519384610ccd565b82523d6000602084013e565b606090565b8147106114df576000918291829182916001600160a01b03165af16114c5611472565b50156114cd57565b604051630a12f52160e11b8152600490fd5b60405163cd78605960e01b8152306004820152602490fd5b60ff81146115355760ff811690601f8211611523576040519161151983610cb2565b8252602082015290565b604051632cd44ac360e21b8152600490fd5b5060405160006002549060018260011c9060018416938415611619575b602094858410811461160557838752869493929181156115e55750600114611586575b505061158392500382610ccd565b90565b9093915060026000527f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace936000915b8183106115cd57505061158393508201013880611575565b855487840185015294850194869450918301916115b5565b91505061158394925060ff191682840152151560051b8201013880611575565b634e487b7160e01b85526022600452602485fd5b91607f1691611552565b60ff81146116455760ff811690601f8211611523576040519161151983610cb2565b5060405160006003549060018260011c90600184169384156116f1575b602094858410811461160557838752869493929181156115e5575060011461169257505061158392500382610ccd565b9093915060036000527fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b936000915b8183106116d957505061158393508201013880611575565b855487840185015294850194869450918301916116c1565b91607f1691611662565b91907f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0841161177f57926020929160ff608095604051948552168484015260408301526060820152600092839182805260015afa156117735780516001600160a01b0381161561176a57918190565b50809160019190565b604051903d90823e3d90fd5b50505060009160039190565b60048110156117fa578061179d575050565b600181036117b75760405163f645eedf60e01b8152600490fd5b600281036117d85760405163fce698f760e01b815260048101839052602490fd5b6003146117e25750565b602490604051906335e2f38360e21b82526004820152fd5b634e487b7160e01b600052602160045260246000fd5b9061182557508051156114cd57805190602001fd5b81511580611858575b611836575090565b604051639996b31560e01b81526001600160a01b039091166004820152602490fd5b50803b1561182e56fea26469706673582212201fce5f0d5a2edf46cba287858900c88e134db3d55e62676ae1873432f0eac40864736f6c63430008180033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
00000000000000000000000080445f96ee0f218f5eeebee0ba8ec504e5de9526000000000000000000000000e28542c3536f2d82df1a401c9e711b6d0baf6a4500000000000000000000000075bc1a2b308c5b5ff18e8865c3b435525e22ae0d00000000000000000000000080445f96ee0f218f5eeebee0ba8ec504e5de9526000000000000000000000000ff7ba7b0c19868d2bde40516b94cf069d277f742
-----Decoded View---------------
Arg [0] : owner (address): 0x80445f96eE0f218F5EeEbEE0bA8Ec504e5dE9526
Arg [1] : trustedForwarder_ (address): 0xe28542c3536f2d82dF1a401C9E711b6d0BaF6a45
Arg [2] : operator (address): 0x75Bc1a2b308c5b5Ff18e8865C3B435525E22Ae0D
Arg [3] : treasury_ (address): 0x80445f96eE0f218F5EeEbEE0bA8Ec504e5dE9526
Arg [4] : permitManager_ (address): 0xfF7Ba7B0C19868D2BDe40516b94cF069d277f742
-----Encoded View---------------
5 Constructor Arguments found :
Arg [0] : 00000000000000000000000080445f96ee0f218f5eeebee0ba8ec504e5de9526
Arg [1] : 000000000000000000000000e28542c3536f2d82df1a401c9e711b6d0baf6a45
Arg [2] : 00000000000000000000000075bc1a2b308c5b5ff18e8865c3b435525e22ae0d
Arg [3] : 00000000000000000000000080445f96ee0f218f5eeebee0ba8ec504e5de9526
Arg [4] : 000000000000000000000000ff7ba7b0c19868d2bde40516b94cf069d277f742
Multichain Portfolio | 34 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|---|---|---|---|---|
| ETH | 91.76% | $3,045.91 | 0.00034653 | $1.06 | |
| BASE | 3.07% | $3,051.01 | 0.00001156 | $0.035258 | |
| ARB | 2.65% | $3,051.49 | 0.00001001 | $0.030539 | |
| OPBNB | 1.17% | $894.26 | 0.00001508 | $0.013489 | |
| BSC | 0.73% | $893.8 | 0.00000937 | $0.008371 | |
| LINEA | 0.62% | $3,045.91 | 0.00000234 | $0.007122 | |
| POL | <0.01% | $0.124185 | 0.00013904 | $0.000017 | |
| MANTLE | <0.01% | $1.07 | 0.000000084284 | <$0.000001 | |
| SEI | <0.01% | $0.129217 | 0.000000081263 | <$0.000001 |
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.