More Info
Private Name Tags
ContractCreator
TokenTracker
Latest 25 from a total of 70 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Execute | 20975597 | 20 days ago | IN | 0 ETH | 0.00068992 | ||||
Execute | 20918329 | 28 days ago | IN | 0 ETH | 0.00066096 | ||||
Execute | 20911151 | 29 days ago | IN | 0 ETH | 0.00045511 | ||||
Execute | 20903984 | 30 days ago | IN | 0 ETH | 0.00029102 | ||||
Execute | 20882461 | 33 days ago | IN | 0 ETH | 0.00034595 | ||||
Execute | 20868117 | 35 days ago | IN | 0 ETH | 0.00325546 | ||||
Execute | 20860937 | 36 days ago | IN | 0 ETH | 0.00049599 | ||||
Execute | 20853769 | 37 days ago | IN | 0 ETH | 0.00045682 | ||||
Execute | 20832257 | 40 days ago | IN | 0 ETH | 0.00087679 | ||||
Approve | 20796524 | 45 days ago | IN | 0 ETH | 0.000365 | ||||
Execute | 20782114 | 47 days ago | IN | 0 ETH | 0.00050158 | ||||
Execute | 20746329 | 52 days ago | IN | 0 ETH | 0.00014168 | ||||
Execute | 20739168 | 53 days ago | IN | 0 ETH | 0.0001326 | ||||
Execute | 20724846 | 55 days ago | IN | 0 ETH | 0.00018227 | ||||
Execute | 20710528 | 57 days ago | IN | 0 ETH | 0.0001729 | ||||
Execute | 20681860 | 61 days ago | IN | 0 ETH | 0.00032922 | ||||
Execute | 20674690 | 62 days ago | IN | 0 ETH | 0.00017483 | ||||
Execute | 20660357 | 64 days ago | IN | 0 ETH | 0.00009957 | ||||
Execute | 20531505 | 82 days ago | IN | 0 ETH | 0.00025963 | ||||
Execute | 20517177 | 84 days ago | IN | 0 ETH | 0.00013148 | ||||
Execute | 20510512 | 85 days ago | IN | 0 ETH | 0.00012894 | ||||
Execute | 20510008 | 85 days ago | IN | 0 ETH | 0.00015059 | ||||
Execute | 20488514 | 88 days ago | IN | 0 ETH | 0.00013922 | ||||
Execute | 20431171 | 96 days ago | IN | 0 ETH | 0.0004445 | ||||
Execute | 20424006 | 97 days ago | IN | 0 ETH | 0.00014685 |
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Contract Source Code Verified (Exact Match)
Contract Name:
SPCTPool
Compiler Version
v0.8.24+commit.e11b9ed9
Optimization Enabled:
Yes with 200 runs
Other Settings:
cancun EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity ^0.8.21; import "@openzeppelin/contracts/access/AccessControl.sol"; import "@openzeppelin/contracts/utils/Pausable.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol"; import "./utils/SafeMath.sol"; /** * @title Whitelist Private Credit ERC20-like token for Anzen protocol. */ contract SPCTPool is ERC20Permit, AccessControl, Pausable { using SafeERC20 for IERC20; using SafeMath for uint256; bytes32 public constant POOL_MANAGER_ROLE = keccak256("POOL_MANAGER_ROLE"); // Used to calculate total executed shares. uint256 public executedUSD; // Used to calculate total pooled USD. uint256 public totalPooledUSD; // Used to calculate the reserve USD in pool. uint256 public reserveUSD; // Fee Zone uint256 public constant FEE_COEFFICIENT = 1e8; // Fee should be less than 1%. uint256 public constant maxMintFeeRate = FEE_COEFFICIENT / 100; uint256 public constant maxRedeemFeeRate = FEE_COEFFICIENT / 100; uint256 public mintFeeRate; uint256 public redeemFeeRate; // Protocol treasury should be a mulsig wallet. address public treasury; // Used to mint SPCT. IERC20 public immutable usdc; /** * @dev SPCT only available for KYC Users. */ mapping(address => bool) private _permission; event Deposit(address indexed user, uint256 indexed amount); event Redeem(address indexed user, uint256 indexed amount); event Execute(uint256 indexed amount); event Repay(uint256 indexed amount); event MintFeeRateChanged(uint256 indexed newFeeRate); event RedeemFeeRateChanged(uint256 indexed newFeeRate); event TreasuryChanged(address newTreasury); constructor(address admin, IERC20 _usdc) ERC20("Secured Private Credit Token", "SPCT") ERC20Permit("SPCT") { _grantRole(DEFAULT_ADMIN_ROLE, admin); usdc = _usdc; // initialize _permission[address(0)] = true; } /** * @notice Pause the contract. Revert if already paused. */ function pause() external onlyRole(DEFAULT_ADMIN_ROLE) { _pause(); } /** * @notice Unpause the contract. Revert if already unpaused. */ function unpause() external onlyRole(DEFAULT_ADMIN_ROLE) { _unpause(); } /** * @notice Deposit USDC. * Emits a `Deposit` event. * * @param _amount the amount of USDC */ function deposit(uint256 _amount) external whenNotPaused { require(_amount > 0, "DEPOSIT_AMOUNT_IS_ZERO"); usdc.transferFrom(msg.sender, address(this), _amount); reserveUSD = reserveUSD.add(_amount); totalPooledUSD = totalPooledUSD.add(_amount); // Due to different precisions, convert it to SPCT. uint256 convertToSPCT = _amount.mul(1e12); // calculate fee with SPCT if (mintFeeRate == 0) { _mint(msg.sender, convertToSPCT); } else { uint256 feeAmount = convertToSPCT.mul(mintFeeRate).div(FEE_COEFFICIENT); uint256 amountAfterFee = convertToSPCT.sub(feeAmount); _mint(msg.sender, amountAfterFee); if (feeAmount != 0) { _mint(treasury, feeAmount); } } emit Deposit(msg.sender, _amount); } /** * @notice Deposit via fiat. * Emits a `Deposit` event. * * @param _amount the amount of USD */ function depositByFiat(address _user, uint256 _amount) external whenNotPaused onlyRole(POOL_MANAGER_ROLE) { require(_amount > 0, "DEPOSIT_AMOUNT_IS_ZERO"); _mint(_user, _amount); emit Deposit(msg.sender, _amount); } /** * @notice Redeem SPCT. * Emits a `Redeem` event. * * @param _amount the amount of SPCT. */ function redeem(uint256 _amount) external whenNotPaused { require(_amount > 0, "REDEEM_AMOUNT_IS_ZERO"); // Due to different precisions, convert it to SPCT. uint256 convertToUSDC; // calculate fee with SPCT if (redeemFeeRate == 0) { _burn(msg.sender, _amount); convertToUSDC = _amount.div(1e12); } else { uint256 feeAmount = _amount.mul(redeemFeeRate).div(FEE_COEFFICIENT); uint256 amountAfterFee = _amount.sub(feeAmount); _burn(msg.sender, amountAfterFee); convertToUSDC = amountAfterFee.div(1e12); if (feeAmount != 0) { _transfer(msg.sender, treasury, feeAmount); } } usdc.transfer(msg.sender, convertToUSDC); reserveUSD = reserveUSD.sub(convertToUSDC); totalPooledUSD = totalPooledUSD.sub(convertToUSDC); emit Redeem(msg.sender, _amount); } /** * @notice Redeem via fiat. * Emits a `Redeem` event. * * @param _amount the amount of USD */ function redeemByFiat(address _user, uint256 _amount) external whenNotPaused onlyRole(POOL_MANAGER_ROLE) { require(_amount > 0, "REDEEM_AMOUNT_IS_ZERO"); _burn(_user, _amount); emit Redeem(msg.sender, _amount); } /** * @notice Execute USDC to buy private credit. * Emits a `Execute` event. * * @param _amount the amount of USDC (6 decimals). */ function execute(uint256 _amount) external onlyRole(POOL_MANAGER_ROLE) { require(_amount > 0, "EXECUTE_AMOUNT_IS_ZERO"); executedUSD = executedUSD.add(_amount); reserveUSD = reserveUSD.sub(_amount); usdc.transfer(msg.sender, _amount); emit Execute(_amount); } /** * @notice Repay USDC from private credit. * Emits a `Repay` event. * * @param _amount the amount of USDC (6 decimals). */ function repay(uint256 _amount) external onlyRole(POOL_MANAGER_ROLE) { if (_amount > executedUSD) revert("REPAY_AMOUNT_EXCEED_EXECUTED_SHARES"); executedUSD = executedUSD.sub(_amount); reserveUSD = reserveUSD.add(_amount); usdc.transferFrom(msg.sender, address(this), _amount); emit Repay(_amount); } /** * @notice Moves `_amount` tokens from `_sender` to `_recipient`. * Emits a `Transfer` event. */ function _update(address _sender, address _recipient, uint256 _amount) internal override { require(_permission[_sender], "UNVERIFIED_SENDER"); require(_permission[_recipient], "UNVERIFIED_RECIPIENT"); super._update(_sender, _recipient, _amount); } /** * @return true if user in list. */ function isWhitelist(address _user) external view returns (bool) { return _permission[_user]; } /** * @notice Only KYC users are allow to operate. * * @param _user user's address. */ function addToWhitelist(address _user) external onlyRole(POOL_MANAGER_ROLE) { _permission[_user] = true; } /** * @notice Only KYC users are allow to operate. * * @param _users array of user addresses. */ function addBatchToWhitelist(address[] calldata _users) external onlyRole(POOL_MANAGER_ROLE) { uint256 numUsers = _users.length; for (uint256 i; i < numUsers; ++i) { _permission[_users[i]] = true; } } /** * @notice Only KYC users are allow to operate. * * @param _user user's address. */ function removeFromWhitelist(address _user) external onlyRole(POOL_MANAGER_ROLE) { _permission[_user] = false; } /** * @notice Only KYC users are allow to operate. * * @param _users array of user addresses. */ function removeBatchFromWhitelist(address[] calldata _users) external onlyRole(POOL_MANAGER_ROLE) { uint256 numUsers = _users.length; for (uint256 i; i < numUsers; ++i) { _permission[_users[i]] = false; } } /** * @notice Mint fee. * * @param newMintFeeRate new mint fee rate. */ function setMintFeeRate(uint256 newMintFeeRate) external onlyRole(POOL_MANAGER_ROLE) { require(newMintFeeRate <= maxMintFeeRate, "SHOULD_BE_LESS_THAN_OR_EQUAL_TO_1P"); mintFeeRate = newMintFeeRate; emit MintFeeRateChanged(mintFeeRate); } /** * @notice Redeem fee. * * @param newRedeemFeeRate new redeem fee rate. */ function setRedeemFeeRate(uint256 newRedeemFeeRate) external onlyRole(POOL_MANAGER_ROLE) { require(newRedeemFeeRate <= maxRedeemFeeRate, "SHOULD_BE_LESS_THAN_OR_EQUAL_TO_1P"); redeemFeeRate = newRedeemFeeRate; emit RedeemFeeRateChanged(redeemFeeRate); } /** * @notice Treasury address. * * @param newTreasury new treasury address. */ function setTreasury(address newTreasury) external onlyRole(POOL_MANAGER_ROLE) { require(newTreasury != address(0), "SET_UP_TO_ZERO_ADDR"); treasury = newTreasury; emit TreasuryChanged(treasury); } /** * @notice Rescue ERC20 tokens locked up in this contract. * @param token ERC20 token contract address. * @param to recipient address. * @param amount amount to withdraw. */ function rescueERC20(IERC20 token, address to, uint256 amount) external onlyRole(POOL_MANAGER_ROLE) { // If is USDC, check reserve usd amount first. if (address(token) == address(usdc)) { require(amount <= usdc.balanceOf(address(this)).sub(reserveUSD), "USDC_RESCUE_AMOUNT_EXCEED_DEBIT"); } token.safeTransfer(to, amount); } }
// 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) (utils/Pausable.sol) pragma solidity ^0.8.20; import {Context} from "../utils/Context.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract Pausable is Context { bool private _paused; /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); /** * @dev The operation failed because the contract is paused. */ error EnforcedPause(); /** * @dev The operation failed because the contract is not paused. */ error ExpectedPause(); /** * @dev Initializes the contract in unpaused state. */ constructor() { _paused = false; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { _requireNotPaused(); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { _requirePaused(); _; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Throws if the contract is paused. */ function _requireNotPaused() internal view virtual { if (paused()) { revert EnforcedPause(); } } /** * @dev Throws if the contract is not paused. */ function _requirePaused() internal view virtual { if (!paused()) { revert ExpectedPause(); } } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } }
// 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) (token/ERC20/extensions/ERC20Permit.sol) pragma solidity ^0.8.20; import {IERC20Permit} from "./IERC20Permit.sol"; import {ERC20} from "../ERC20.sol"; import {ECDSA} from "../../../utils/cryptography/ECDSA.sol"; import {EIP712} from "../../../utils/cryptography/EIP712.sol"; import {Nonces} from "../../../utils/Nonces.sol"; /** * @dev Implementation of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. */ abstract contract ERC20Permit is ERC20, IERC20Permit, EIP712, Nonces { bytes32 private constant PERMIT_TYPEHASH = keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"); /** * @dev Permit deadline has expired. */ error ERC2612ExpiredSignature(uint256 deadline); /** * @dev Mismatched signature. */ error ERC2612InvalidSigner(address signer, address owner); /** * @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `"1"`. * * It's a good idea to use the same `name` that is defined as the ERC20 token name. */ constructor(string memory name) EIP712(name, "1") {} /** * @inheritdoc IERC20Permit */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) public virtual { if (block.timestamp > deadline) { revert ERC2612ExpiredSignature(deadline); } bytes32 structHash = keccak256(abi.encode(PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline)); bytes32 hash = _hashTypedDataV4(structHash); address signer = ECDSA.recover(hash, v, r, s); if (signer != owner) { revert ERC2612InvalidSigner(signer, owner); } _approve(owner, spender, value); } /** * @inheritdoc IERC20Permit */ function nonces(address owner) public view virtual override(IERC20Permit, Nonces) returns (uint256) { return super.nonces(owner); } /** * @inheritdoc IERC20Permit */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view virtual returns (bytes32) { return _domainSeparatorV4(); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/math/SafeMath.sol) pragma solidity ^0.8.0; // CAUTION // This version of SafeMath should only be used with Solidity 0.8 or later, // because it relies on the compiler's built in overflow checks. /** * @dev Wrappers over Solidity's arithmetic operations. * * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler * now has built in overflow checking. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the subtraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { return a + b; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { return a * b; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b <= a, errorMessage); return a - b; } } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a / b; } } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a % b; } } }
// SPDX-License-Identifier: 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.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/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) (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/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) (utils/Address.sol) pragma solidity ^0.8.20; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev The ETH balance of the account is not enough to perform the operation. */ error AddressInsufficientBalance(address account); /** * @dev There's no code at `target` (it is not a contract). */ error AddressEmptyCode(address target); /** * @dev A call to an address target failed. The target may have reverted. */ error FailedInnerCall(); /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { if (address(this).balance < amount) { revert AddressInsufficientBalance(address(this)); } (bool success, ) = recipient.call{value: amount}(""); if (!success) { revert FailedInnerCall(); } } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason or custom error, it is bubbled * up by this function (like regular Solidity function calls). However, if * the call reverted with no returned reason, this function reverts with a * {FailedInnerCall} error. * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { if (address(this).balance < value) { revert AddressInsufficientBalance(address(this)); } (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an * unsuccessful call. */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata ) internal view returns (bytes memory) { if (!success) { _revert(returndata); } else { // only check if target is a contract if the call was successful and the return data is empty // otherwise we already know that it was a contract if (returndata.length == 0 && target.code.length == 0) { revert AddressEmptyCode(target); } return returndata; } } /** * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the * revert reason or with a default {FailedInnerCall} error. */ function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) { if (!success) { _revert(returndata); } else { return returndata; } } /** * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}. */ function _revert(bytes memory returndata) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert FailedInnerCall(); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/ERC20.sol) pragma solidity ^0.8.20; import {IERC20} from "./IERC20.sol"; import {IERC20Metadata} from "./extensions/IERC20Metadata.sol"; import {Context} from "../../utils/Context.sol"; import {IERC20Errors} from "../../interfaces/draft-IERC6093.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * * TIP: For a detailed writeup see our guide * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * The default value of {decimals} is 18. To change this, you should override * this function so it returns a different value. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. */ abstract contract ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors { mapping(address account => uint256) private _balances; mapping(address account => mapping(address spender => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the default value returned by this function, unless * it's overridden. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `to` cannot be the zero address. * - the caller must have a balance of at least `value`. */ function transfer(address to, uint256 value) public virtual returns (bool) { address owner = _msgSender(); _transfer(owner, to, value); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * NOTE: If `value` is the maximum `uint256`, the allowance is not updated on * `transferFrom`. This is semantically equivalent to an infinite approval. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 value) public virtual returns (bool) { address owner = _msgSender(); _approve(owner, spender, value); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * NOTE: Does not update the allowance if the current allowance * is the maximum `uint256`. * * Requirements: * * - `from` and `to` cannot be the zero address. * - `from` must have a balance of at least `value`. * - the caller must have allowance for ``from``'s tokens of at least * `value`. */ function transferFrom(address from, address to, uint256 value) public virtual returns (bool) { address spender = _msgSender(); _spendAllowance(from, spender, value); _transfer(from, to, value); return true; } /** * @dev Moves a `value` amount of tokens from `from` to `to`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * NOTE: This function is not virtual, {_update} should be overridden instead. */ function _transfer(address from, address to, uint256 value) internal { if (from == address(0)) { revert ERC20InvalidSender(address(0)); } if (to == address(0)) { revert ERC20InvalidReceiver(address(0)); } _update(from, to, value); } /** * @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from` * (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding * this function. * * Emits a {Transfer} event. */ function _update(address from, address to, uint256 value) internal virtual { if (from == address(0)) { // Overflow check required: The rest of the code assumes that totalSupply never overflows _totalSupply += value; } else { uint256 fromBalance = _balances[from]; if (fromBalance < value) { revert ERC20InsufficientBalance(from, fromBalance, value); } unchecked { // Overflow not possible: value <= fromBalance <= totalSupply. _balances[from] = fromBalance - value; } } if (to == address(0)) { unchecked { // Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply. _totalSupply -= value; } } else { unchecked { // Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256. _balances[to] += value; } } emit Transfer(from, to, value); } /** * @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0). * Relies on the `_update` mechanism * * Emits a {Transfer} event with `from` set to the zero address. * * NOTE: This function is not virtual, {_update} should be overridden instead. */ function _mint(address account, uint256 value) internal { if (account == address(0)) { revert ERC20InvalidReceiver(address(0)); } _update(address(0), account, value); } /** * @dev Destroys a `value` amount of tokens from `account`, lowering the total supply. * Relies on the `_update` mechanism. * * Emits a {Transfer} event with `to` set to the zero address. * * NOTE: This function is not virtual, {_update} should be overridden instead */ function _burn(address account, uint256 value) internal { if (account == address(0)) { revert ERC20InvalidSender(address(0)); } _update(account, address(0), value); } /** * @dev Sets `value` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. * * Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument. */ function _approve(address owner, address spender, uint256 value) internal { _approve(owner, spender, value, true); } /** * @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event. * * By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by * `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any * `Approval` event during `transferFrom` operations. * * Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to * true using the following override: * ``` * function _approve(address owner, address spender, uint256 value, bool) internal virtual override { * super._approve(owner, spender, value, true); * } * ``` * * Requirements are the same as {_approve}. */ function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual { if (owner == address(0)) { revert ERC20InvalidApprover(address(0)); } if (spender == address(0)) { revert ERC20InvalidSpender(address(0)); } _allowances[owner][spender] = value; if (emitEvent) { emit Approval(owner, spender, value); } } /** * @dev Updates `owner` s allowance for `spender` based on spent `value`. * * Does not update the allowance value in case of infinite allowance. * Revert if not enough allowance is available. * * Does not emit an {Approval} event. */ function _spendAllowance(address owner, address spender, uint256 value) internal virtual { uint256 currentAllowance = allowance(owner, spender); if (currentAllowance != type(uint256).max) { if (currentAllowance < value) { revert ERC20InsufficientAllowance(spender, currentAllowance, value); } unchecked { _approve(owner, spender, currentAllowance - value, false); } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (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/Nonces.sol) pragma solidity ^0.8.20; /** * @dev Provides tracking nonces for addresses. Nonces will only increment. */ abstract contract Nonces { /** * @dev The nonce used for an `account` is not the expected current nonce. */ error InvalidAccountNonce(address account, uint256 currentNonce); mapping(address account => uint256) private _nonces; /** * @dev Returns the next unused nonce for an address. */ function nonces(address owner) public view virtual returns (uint256) { return _nonces[owner]; } /** * @dev Consumes a nonce. * * Returns the current value and increments nonce. */ function _useNonce(address owner) internal virtual returns (uint256) { // For each account, the nonce has an initial value of 0, can only be incremented by one, and cannot be // decremented or reset. This guarantees that the nonce never overflows. unchecked { // It is important to do x++ and not ++x here. return _nonces[owner]++; } } /** * @dev Same as {_useNonce} but checking that `nonce` is the next valid for `owner`. */ function _useCheckedNonce(address owner, uint256 nonce) internal virtual { uint256 current = _useNonce(owner); if (nonce != current) { revert InvalidAccountNonce(owner, current); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/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) (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.20; import {IERC20} from "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (interfaces/draft-IERC6093.sol) pragma solidity ^0.8.20; /** * @dev Standard ERC20 Errors * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC20 tokens. */ interface IERC20Errors { /** * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. * @param balance Current balance for the interacting account. * @param needed Minimum amount required to perform a transfer. */ error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed); /** * @dev Indicates a failure with the token `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. */ error ERC20InvalidSender(address sender); /** * @dev Indicates a failure with the token `receiver`. Used in transfers. * @param receiver Address to which tokens are being transferred. */ error ERC20InvalidReceiver(address receiver); /** * @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers. * @param spender Address that may be allowed to operate on tokens without being their owner. * @param allowance Amount of tokens a `spender` is allowed to operate with. * @param needed Minimum amount required to perform a transfer. */ error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed); /** * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals. * @param approver Address initiating an approval operation. */ error ERC20InvalidApprover(address approver); /** * @dev Indicates a failure with the `spender` to be approved. Used in approvals. * @param spender Address that may be allowed to operate on tokens without being their owner. */ error ERC20InvalidSpender(address spender); } /** * @dev Standard ERC721 Errors * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC721 tokens. */ interface IERC721Errors { /** * @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in EIP-20. * Used in balance queries. * @param owner Address of the current owner of a token. */ error ERC721InvalidOwner(address owner); /** * @dev Indicates a `tokenId` whose `owner` is the zero address. * @param tokenId Identifier number of a token. */ error ERC721NonexistentToken(uint256 tokenId); /** * @dev Indicates an error related to the ownership over a particular token. Used in transfers. * @param sender Address whose tokens are being transferred. * @param tokenId Identifier number of a token. * @param owner Address of the current owner of a token. */ error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner); /** * @dev Indicates a failure with the token `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. */ error ERC721InvalidSender(address sender); /** * @dev Indicates a failure with the token `receiver`. Used in transfers. * @param receiver Address to which tokens are being transferred. */ error ERC721InvalidReceiver(address receiver); /** * @dev Indicates a failure with the `operator`’s approval. Used in transfers. * @param operator Address that may be allowed to operate on tokens without being their owner. * @param tokenId Identifier number of a token. */ error ERC721InsufficientApproval(address operator, uint256 tokenId); /** * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals. * @param approver Address initiating an approval operation. */ error ERC721InvalidApprover(address approver); /** * @dev Indicates a failure with the `operator` to be approved. Used in approvals. * @param operator Address that may be allowed to operate on tokens without being their owner. */ error ERC721InvalidOperator(address operator); } /** * @dev Standard ERC1155 Errors * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC1155 tokens. */ interface IERC1155Errors { /** * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. * @param balance Current balance for the interacting account. * @param needed Minimum amount required to perform a transfer. * @param tokenId Identifier number of a token. */ error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId); /** * @dev Indicates a failure with the token `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. */ error ERC1155InvalidSender(address sender); /** * @dev Indicates a failure with the token `receiver`. Used in transfers. * @param receiver Address to which tokens are being transferred. */ error ERC1155InvalidReceiver(address receiver); /** * @dev Indicates a failure with the `operator`’s approval. Used in transfers. * @param operator Address that may be allowed to operate on tokens without being their owner. * @param owner Address of the current owner of a token. */ error ERC1155MissingApprovalForAll(address operator, address owner); /** * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals. * @param approver Address initiating an approval operation. */ error ERC1155InvalidApprover(address approver); /** * @dev Indicates a failure with the `operator` to be approved. Used in approvals. * @param operator Address that may be allowed to operate on tokens without being their owner. */ error ERC1155InvalidOperator(address operator); /** * @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation. * Used in batch transfers. * @param idsLength Length of the array of token identifiers * @param valuesLength Length of the array of token amounts */ error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (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/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) (interfaces/IERC5267.sol) pragma solidity ^0.8.20; interface IERC5267 { /** * @dev MAY be emitted to signal that the domain could have changed. */ event EIP712DomainChanged(); /** * @dev returns the fields and values that describe the domain separator used by this contract for EIP-712 * signature. */ function eip712Domain() external view returns ( bytes1 fields, string memory name, string memory version, uint256 chainId, address verifyingContract, bytes32 salt, uint256[] memory extensions ); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (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 // 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/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); } } }
{ "remappings": [ "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/", "@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/", "@chainlink/contracts/=lib/chainlink/contracts/", "forge-std/=lib/forge-std/src/", "@layerzerolabs/lz-evm-protocol-v2/=lib/LayerZero-v2/protocol/", "@layerzerolabs/lz-evm-oapp-v2/=lib/LayerZero-v2/oapp/", "@createx/=lib/createx/src/", "LayerZero-v2/=lib/LayerZero-v2/", "chainlink/=lib/chainlink/contracts/", "createx/=lib/createx/src/", "ds-test/=lib/createx/lib/forge-std/lib/ds-test/src/", "erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/", "forge-std/=lib/forge-std/src/", "openzeppelin-contracts/=lib/openzeppelin-contracts/", "openzeppelin/=lib/createx/lib/openzeppelin-contracts/contracts/", "solady/=lib/createx/lib/solady/" ], "optimizer": { "enabled": true, "runs": 200 }, "metadata": { "useLiteralContent": false, "bytecodeHash": "ipfs", "appendCBOR": true }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "evmVersion": "cancun", "viaIR": true, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"admin","type":"address"},{"internalType":"contract IERC20","name":"_usdc","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":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"allowance","type":"uint256"},{"internalType":"uint256","name":"needed","type":"uint256"}],"name":"ERC20InsufficientAllowance","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"uint256","name":"balance","type":"uint256"},{"internalType":"uint256","name":"needed","type":"uint256"}],"name":"ERC20InsufficientBalance","type":"error"},{"inputs":[{"internalType":"address","name":"approver","type":"address"}],"name":"ERC20InvalidApprover","type":"error"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"}],"name":"ERC20InvalidReceiver","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"}],"name":"ERC20InvalidSender","type":"error"},{"inputs":[{"internalType":"address","name":"spender","type":"address"}],"name":"ERC20InvalidSpender","type":"error"},{"inputs":[{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"ERC2612ExpiredSignature","type":"error"},{"inputs":[{"internalType":"address","name":"signer","type":"address"},{"internalType":"address","name":"owner","type":"address"}],"name":"ERC2612InvalidSigner","type":"error"},{"inputs":[],"name":"EnforcedPause","type":"error"},{"inputs":[],"name":"ExpectedPause","type":"error"},{"inputs":[],"name":"FailedInnerCall","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"currentNonce","type":"uint256"}],"name":"InvalidAccountNonce","type":"error"},{"inputs":[],"name":"InvalidShortString","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"inputs":[{"internalType":"string","name":"str","type":"string"}],"name":"StringTooLong","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Deposit","type":"event"},{"anonymous":false,"inputs":[],"name":"EIP712DomainChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Execute","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"newFeeRate","type":"uint256"}],"name":"MintFeeRateChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Redeem","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"newFeeRate","type":"uint256"}],"name":"RedeemFeeRateChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Repay","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newTreasury","type":"address"}],"name":"TreasuryChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DOMAIN_SEPARATOR","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"FEE_COEFFICIENT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"POOL_MANAGER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"_users","type":"address[]"}],"name":"addBatchToWhitelist","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"}],"name":"addToWhitelist","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"deposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"depositByFiat","outputs":[],"stateMutability":"nonpayable","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":"uint256","name":"_amount","type":"uint256"}],"name":"execute","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"executedUSD","outputs":[{"internalType":"uint256","name":"","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":"address","name":"_user","type":"address"}],"name":"isWhitelist","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxMintFeeRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxRedeemFeeRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"mintFeeRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"nonces","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"value","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"}],"name":"permit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"redeem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"redeemByFiat","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"redeemFeeRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"_users","type":"address[]"}],"name":"removeBatchFromWhitelist","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"}],"name":"removeFromWhitelist","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"callerConfirmation","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"repay","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"token","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"rescueERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"reserveUSD","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newMintFeeRate","type":"uint256"}],"name":"setMintFeeRate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newRedeemFeeRate","type":"uint256"}],"name":"setRedeemFeeRate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newTreasury","type":"address"}],"name":"setTreasury","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":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalPooledUSD","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"treasury","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"usdc","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
610180346200056257601f62002e4a38819003918201601f19168301916001600160401b0383118484101762000317578084926040948552833981010312620005625780516001600160a01b039182821682036200056257602001519182168203620005625760405191620000748362000566565b600483526314d410d560e21b9283602082015260405193620000968562000566565b601c85527f5365637572656420507269766174652043726564697420546f6b656e00000000602086015260405190620000cf8262000566565b60048252602082015260405194620000e78662000566565b60018652603160f81b60208701528051906001600160401b038211620003175760035490600182811c9216801562000557575b6020831014620004305781601f849311620004e4575b50602090601f83116001146200045b575f926200044f575b50508160011b915f199060031b1c1916176003555b8051906001600160401b038211620003175760045490600182811c9216801562000444575b6020831014620004305781601f849311620003c0575b50602090601f831160011462000337575f926200032b575b50508160011b915f199060031b1c1916176004555b620001d08162000604565b92610120938452620001e285620007bc565b9161014092835260208151910120948560e0526020815191012094610100958087524660a0526040519060208201927f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f8452604083015260608201524660808201523060a082015260a0815260c0810181811060018060401b0382111762000317576040525190206080523060c0526200028760ff1991826009541660095562000582565b506101609283525f80526010602052600160405f2091825416179055604051926124c094856200096a863960805185611f25015260a05185611ff1015260c05185611eef015260e05185611f7401525184611f9a01525183610e3101525182610e5b0152518181816102b00152818161055e015281816108d801528181610a2c0152818161113a01526111e80152f35b634e487b7160e01b5f52604160045260245ffd5b015190505f80620001b0565b60045f9081527f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b9350601f198516905b818110620003a757509084600195949392106200038e575b505050811b01600455620001c5565b01515f1960f88460031b161c191690555f80806200037f565b9293602060018192878601518155019501930162000367565b60045f529091507f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b601f840160051c81016020851062000428575b90849392915b601f830160051c820181106200041957505062000198565b5f815585945060010162000401565b5080620003fb565b634e487b7160e01b5f52602260045260245ffd5b91607f169162000182565b015190505f8062000148565b60035f9081527fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b9350601f198516905b818110620004cb5750908460019594939210620004b2575b505050811b016003556200015d565b01515f1960f88460031b161c191690555f8080620004a3565b929360206001819287860151815501950193016200048b565b60035f529091507fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b601f840160051c810191602085106200054c575b90601f859493920160051c01905b8181106200053d575062000130565b5f81558493506001016200052e565b909150819062000520565b91607f16916200011a565b5f80fd5b604081019081106001600160401b038211176200031757604052565b6001600160a01b03165f8181525f8051602062002e2a833981519152602052604090205460ff16620005ff575f8181525f8051602062002e2a83398151915260205260408120805460ff191660011790553391907f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d8180a4600190565b505f90565b80516020919082811015620006a0575090601f8251116200064157808251920151908083106200063357501790565b825f19910360031b1b161790565b90604051809263305a27a960e01b82528060048301528251908160248401525f935b82851062000686575050604492505f838284010152601f80199101168101030190fd5b848101820151868601604401529381019385935062000663565b6001600160401b03811162000317576005928354926001938481811c91168015620007b1575b838210146200043057601f81116200077d575b5081601f84116001146200071757509282939183925f946200070b575b50501b915f199060031b1c191617905560ff90565b015192505f80620006f6565b919083601f198116875f52845f20945f905b8883831062000762575050501062000749575b505050811b01905560ff90565b01515f1960f88460031b161c191690555f80806200073c565b85870151885590960195948501948793509081019062000729565b855f5284601f845f209201871c820191601f8601881c015b828110620007a5575050620006d9565b5f815501859062000795565b90607f1690620006c6565b805160209081811015620008485750601f825111620007e957808251920151908083106200063357501790565b90604051809263305a27a960e01b82528060048301528251908160248401525f935b8285106200082e575050604492505f838284010152601f80199101168101030190fd5b84810182015186860160440152938101938593506200080b565b906001600160401b0382116200031757600654926001938481811c911680156200095e575b838210146200043057601f811162000927575b5081601f8411600114620008bf57509282939183925f94620008b3575b50501b915f199060031b1c19161760065560ff90565b015192505f806200089d565b919083601f19811660065f52845f20945f905b888383106200090c5750505010620008f3575b505050811b0160065560ff90565b01515f1960f88460031b161c191690555f8080620008e5565b858701518855909601959485019487935090810190620008d2565b60065f5284601f845f20920160051c820191601f860160051c015b8281106200095257505062000880565b5f815501859062000942565b90607f16906200086d56fe6080604081815260049182361015610015575f80fd5b5f3560e01c90816301ffc9a7146117555750806306fdde0314611683578063095ea7b31461165a5780630ca699c71461161a578063123a6a82146115c557806318160ddd146115a757806318819a311461158957806321260ef01461152257806321e822c5146114ce57806323b872dd146113dc578063248a9ca3146113b25780632f2ff15d1461138a578063313ce5671461136f5780633143ab571461131b5780633644e515146112f857806336568abe146112b4578063371fd8e6146111695780633e413bee146111265780633f4ba83a146110bf57806356d73568146110855780635872e6fa146110675780635c975abb1461104457806361d027b31461101c578063664692f214610ffe57806370a0823114610fc85780637ecebe0014610f915780638456cb5914610f3857806384b0196e14610e1a5780638ab1d68114610ddb57806391d1485414610d9757806395d89b4114610cab578063a217fddf14610c91578063a3d19d8c14610c35578063a9059cbb14610c05578063b2118a8d146109ed578063b6b55f2514610873578063bf32bf3614610855578063c2d24d4614610454578063c683630d14610819578063d505accf146106ba578063d547741f1461067e578063d8b0eadc14610660578063db006a75146104e4578063dd62ed3e1461049b578063e43252d714610459578063eecadaac14610454578063f05a6b6d14610436578063f0f44260146103855763fe0d94c11461023a575f80fd5b3461038157602036600319011261038157813591610256611a53565b821561034657906020836102ab9361027082600a546120ac565b600a5561027f82600c5461208b565b600c55835163a9059cbb60e01b8152339181019182526020820192909252909384918291604090910190565b03815f7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03165af190811561033d575061030e575b507fddb556f1d2c1ec821e910b019d3685b229db152a0ecd517ca7e24b8bd71392895f80a2005b61032f9060203d602011610336575b61032781836118e3565b810190611a1d565b505f6102e7565b503d61031d565b513d5f823e3d90fd5b6020606492519162461bcd60e51b83528201526016602482015275455845435554455f414d4f554e545f49535f5a45524f60501b6044820152fd5b5f80fd5b509034610381576020366003190112610381576103a06117e5565b6103a8611a53565b6001600160a01b03169081156103fd577fc714d22a2f08b695f81e7c707058db484aa5b4d6b4c9fd64beb10fe85832f60860208385816bffffffffffffffffffffffff60a01b600f541617600f5551908152a1005b606490602084519162461bcd60e51b8352820152601360248201527229a2aa2faaa82faa27afad22a927afa0a2222960691b6044820152fd5b5034610381575f36600319011261038157602090516305f5e1008152f35b61185e565b5034610381576020366003190112610381576104736117e5565b61047b611a53565b6001600160a01b03165f908152601060205220805460ff19166001179055005b50346103815780600319360112610381576020906104b76117e5565b6104bf6117fb565b9060018060a01b038091165f5260018452825f2091165f528252805f20549051908152f35b50903461038157602036600319011261038157803590610502611a35565b61050d821515611982565b600e548061060457506105208233611c52565b610559602064e8d4a51000840480935b865163a9059cbb60e01b8152339181019182526020820192909252909283918291604090910190565b03815f7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03165af180156105fa576105b19394506105db575b506105a681600c5461208b565b600c55600b5461208b565b600b55337f222838db2794d11532d940e8dec38ae307ed0b63cd97c233322e221f998767a65f80a3005b6105f39060203d6020116103365761032781836118e3565b505f610599565b84513d5f823e3d90fd5b60206305f5e10061061861055993866120b9565b0464e8d4a51000610629828761208b565b6106338133611c52565b0493818592610643575b50610530565b600f5461065a91906001600160a01b031633611da0565b5f61063d565b5034610381575f36600319011261038157602090600b549051908152f35b50346103815780600319360112610381576106b891356106b360016106a16117fb565b93835f5260086020525f200154611b22565b612017565b005b5090346103815760e0366003190112610381576106d56117e5565b6106dd6117fb565b906044359260643560843560ff81168103610381578142116108025760018060a01b039081851692835f526007602052885f209081549160018301905589519060208201927f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c98452868c840152858a1660608401528a608084015260a083015260c082015260c0815260e0810181811067ffffffffffffffff8211176107ef578a525190206107c1916107b891610792611eec565b908b519161190160f01b83526002830152602282015260c43591604260a4359220612317565b909291926123a4565b168181036107d4576106b88686866120cc565b86516325c0072360e11b815292830152602482015260449150fd5b604187634e487b7160e01b5f525260245ffd5b865163313c898160e11b8152808401839052602490fd5b5034610381576020366003190112610381576020906001600160a01b0361083e6117e5565b165f526010825260ff815f20541690519015158152f35b5034610381575f36600319011261038157602090600a549051908152f35b503461038157602036600319011261038157813591610890611a35565b82159061089d8215611905565b82516323b872dd60e01b81523382820190815230602082810191909152604082018790526001600160a01b0395918390819060600103815f897f0000000000000000000000000000000000000000000000000000000000000000165af190811561033d57506109ce575b5061091484600c546120ac565b600c5561092384600b546120ac565b600b5564e8d4a5100091828502928584041417156109bb5750600d54806109775750610950915033611b44565b337fe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c5f80a3005b6109946305f5e10061098c61099a93856120b9565b04809361208b565b33611b44565b806109a7575b5050610950565b6109b491600f5416611b44565b5f806109a0565b601190634e487b7160e01b5f525260245ffd5b6109e69060203d6020116103365761032781836118e3565b505f610907565b5090346103815760603660031901126103815780356001600160a01b038181169182900361038157610a1d6117fb565b9060443590610a2a611a53565b7f000000000000000000000000000000000000000000000000000000000000000016808414610b41575b50845163a9059cbb60e01b602082019081526001600160a01b03939093166024820152604480820192909252908152601f19915f91829190610a976064826118e3565b519082865af13d15610b34573d67ffffffffffffffff8111610b215790610add9291610acd6020885194601f84011601846118e3565b82523d5f602084013e5b83612427565b8051908115159182610b06575b5050610af257005b6024925191635274afe760e01b8352820152fd5b610b199250602080918301019101611a1d565b155f80610aea565b604185634e487b7160e01b5f525260245ffd5b610add9150606090610ad7565b60206024918751928380926370a0823160e01b8252308a8301525afa8015610bfb575f90610bc7575b610b789150600c549061208b565b8111610b84575f610a54565b845162461bcd60e51b8152602081860152601f60248201527f555344435f5245534355455f414d4f554e545f4558434545445f4445424954006044820152606490fd5b506020813d602011610bf3575b81610be1602093836118e3565b8101031261038157610b789051610b6a565b3d9150610bd4565b86513d5f823e3d90fd5b5034610381578060031936011261038157602090610c2e610c246117e5565b6024359033611da0565b5160018152f35b503461038157610c4436611811565b91610c4d611a53565b5f5b838110610c5857005b6001906001600160a01b03610c76610c7183888861194a565b61196e565b165f526010602052825f208260ff1982541617905501610c4f565b5034610381575f36600319011261038157602090515f8152f35b509034610381575f36600319011261038157815191825f8354610ccd8161187b565b90818452602095600191876001821691825f14610d70575050600114610d14575b505050610d109291610d019103856118e3565b519282849384528301906117a7565b0390f35b5f90815286935091907f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b5b828410610d585750505082010181610d01610d10610cee565b8054848a018601528895508794909301928101610d3f565b60ff19168782015293151560051b86019093019350849250610d019150610d109050610cee565b5034610381578060031936011261038157602091610db36117fb565b90355f5260088352815f209060018060a01b03165f52825260ff815f20541690519015158152f35b503461038157602036600319011261038157610df56117e5565b610dfd611a53565b6001600160a01b03165f908152601060205220805460ff19169055005b509034610381575f36600319011261038157610e557f0000000000000000000000000000000000000000000000000000000000000000612159565b91610e7f7f000000000000000000000000000000000000000000000000000000000000000061225a565b815191602091602084019484861067ffffffffffffffff871117610f255750610eda8260209287610ecd99989795525f85528151988998600f60f81b8a5260e0868b015260e08a01906117a7565b91888303908901526117a7565b914660608701523060808701525f60a087015285830360c087015251918281520192915f5b828110610f0e57505050500390f35b835185528695509381019392810192600101610eff565b604190634e487b7160e01b5f525260245ffd5b5034610381575f3660031901126103815760207f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25891610f75611acc565b610f7d611a35565b600160ff19600954161760095551338152a1005b5034610381576020366003190112610381576020906001600160a01b03610fb66117e5565b165f5260078252805f20549051908152f35b5034610381576020366003190112610381576020906001600160a01b03610fed6117e5565b165f525f8252805f20549051908152f35b5034610381575f36600319011261038157602090600c549051908152f35b5034610381575f36600319011261038157600f5490516001600160a01b039091168152602090f35b5034610381575f3660031901126103815760209060ff6009541690519015158152f35b5034610381575f36600319011261038157602090600e549051908152f35b5034610381575f36600319011261038157602090517f6077685936c8169d09204a1d97db12e41713588c38e1d29a61867d3dcee98aff8152f35b5034610381575f366003190112610381576110d8611acc565b6009549160ff831615611118577f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6020838560ff191660095551338152a1005b9051638dfc202b60e01b8152fd5b5034610381575f36600319011261038157517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b503461038157602036600319011261038157813591611186611a53565b600a5480841161126557836111e393926111a28260209461208b565b600a556111b182600c546120ac565b600c5583516323b872dd60e01b8152339181019182523060208301526040820192909252909384918291606090910190565b03815f7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03165af190811561033d5750611246575b507fa6ffc78a660e4971a47a0f916a0abae483804e6f42c9292ed06aa64f8fe462305f80a2005b61125e9060203d6020116103365761032781836118e3565b505f61121f565b506020608492519162461bcd60e51b8352820152602360248201527f52455041595f414d4f554e545f4558434545445f45584543555445445f53484160448201526252455360e81b6064820152fd5b50346103815780600319360112610381576112cd6117fb565b90336001600160a01b038316036112e957506106b89135612017565b5163334bd91960e11b81529050fd5b5034610381575f36600319011261038157602090611314611eec565b9051908152f35b82346103815760203660031901126103815735611336611a53565b611345620f42408211156119c6565b80600d557fb2956d477e9ae9221f099e28a17128777c4a3a3a710bb762fa426700e59bbb975f80a2005b5034610381575f366003190112610381576020905160128152f35b50346103815780600319360112610381576106b891356113ad60016106a16117fb565b611e6e565b503461038157602036600319011261038157602091355f52600882526001815f2001549051908152f35b509034610381576060366003190112610381576113f76117e5565b6113ff6117fb565b906044359260018060a01b038216805f526001602052855f20335f52602052855f2054915f19830361143a575b602087610c2e888888611da0565b8583106114a257811561148c57331561147657505f90815260016020908152868220338352815290869020918590039091558290610c2e61142c565b6024905f885191634a1406b160e11b8352820152fd5b6024905f88519163e602df0560e01b8352820152fd5b8651637dc7a0d960e11b8152339181019182526020820193909352604081018690528291506060010390fd5b823461038157602036600319011261038157356114e9611a53565b6114f8620f42408211156119c6565b80600e557fd467b60b26d4173f4875c5fbcd2e14cf43da3a2fd7424cf1776eff2cda18c25b5f80a2005b5034610381573660031901126103815761153a6117e5565b611562602435809261154a611a35565b611552611a53565b61155d821515611982565b611c52565b337f222838db2794d11532d940e8dec38ae307ed0b63cd97c233322e221f998767a65f80a3005b5034610381575f36600319011261038157602090600d549051908152f35b5034610381575f366003190112610381576020906002549051908152f35b5034610381576115d436611811565b916115dd611a53565b5f5b8381106115e857005b6001906001600160a01b03611601610c7183888861194a565b165f526010602052825f2060ff198154169055016115df565b503461038157366003190112610381576116326117e5565b6109506024358092611642611a35565b61164a611a53565b611655821515611905565b611b44565b5034610381578060031936011261038157602090610c2e6116796117e5565b60243590336120cc565b5034610381575f3660031901126103815780516003549091825f6116a68461187b565b808352602094600190866001821691825f146117335750506001146116d8575b5050610d109291610d019103856118e3565b9085925060035f527fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b915f925b82841061171b5750505082010181610d016116c6565b8054848a018601528895508794909301928101611705565b60ff19168682015292151560051b85019092019250839150610d0190506116c6565b833461038157602036600319011261038157359063ffffffff60e01b821680920361038157602091637965db0b60e01b8114908115611796575b5015158152f35b6301ffc9a760e01b1490508361178f565b91908251928382525f5b8481106117d1575050825f602080949584010152601f8019910116010190565b6020818301810151848301820152016117b1565b600435906001600160a01b038216820361038157565b602435906001600160a01b038216820361038157565b9060206003198301126103815760043567ffffffffffffffff9283821161038157806023830112156103815781600401359384116103815760248460051b83010111610381576024019190565b34610381575f366003190112610381576020604051620f42408152f35b90600182811c921680156118a9575b602083101461189557565b634e487b7160e01b5f52602260045260245ffd5b91607f169161188a565b6040810190811067ffffffffffffffff8211176118cf57604052565b634e487b7160e01b5f52604160045260245ffd5b90601f8019910116810190811067ffffffffffffffff8211176118cf57604052565b1561190c57565b60405162461bcd60e51b81526020600482015260166024820152754445504f5349545f414d4f554e545f49535f5a45524f60501b6044820152606490fd5b919081101561195a5760051b0190565b634e487b7160e01b5f52603260045260245ffd5b356001600160a01b03811681036103815790565b1561198957565b60405162461bcd60e51b815260206004820152601560248201527452454445454d5f414d4f554e545f49535f5a45524f60581b6044820152606490fd5b156119cd57565b60405162461bcd60e51b815260206004820152602260248201527f53484f554c445f42455f4c4553535f5448414e5f4f525f455155414c5f544f5f604482015261031560f41b6064820152608490fd5b90816020910312610381575180151581036103815790565b60ff60095416611a4157565b60405163d93c066560e01b8152600490fd5b335f9081527f21e04bb1dd5b7e22c69104638dd01721ade7ca4fd4ac34e47ddd7469cc905be960205260409020547f6077685936c8169d09204a1d97db12e41713588c38e1d29a61867d3dcee98aff9060ff1615611aae5750565b6044906040519063e2517d3f60e01b82523360048301526024820152fd5b335f9081527f5eff886ea0ce6ca488a3d6e336d6c0f75f46d19b42c06ce5ee98e42c96d256c7602052604090205460ff1615611b0457565b60405163e2517d3f60e01b81523360048201525f6024820152604490fd5b805f52600860205260405f20335f5260205260ff60405f20541615611aae5750565b6001600160a01b0316908115611c3a575f805260209060108252604060ff815f20541615611c0357835f526010835260ff815f20541615611bc95791815f93611bb07fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef946002546120ac565b60025585855284835280852082815401905551908152a3565b5162461bcd60e51b81526004810183905260146024820152731553959154925192515117d49150d2541251539560621b6044820152606490fd5b5162461bcd60e51b81526004810183905260116024820152702aa72b22a924a324a2a22fa9a2a72222a960791b6044820152606490fd5b60405163ec442f0560e01b81525f6004820152602490fd5b6001600160a01b038116918215611d8857825f526020916010835260409060ff825f20541615611d50575f80526010845260ff825f20541615611d1557845f525f8452815f205490838210611ce4575091849391817fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef945f9788528785520381872055816002540360025551908152a3565b825163391434e360e21b81526001600160a01b03919091166004820152602481019190915260448101839052606490fd5b815162461bcd60e51b81526004810185905260146024820152731553959154925192515117d49150d2541251539560621b6044820152606490fd5b815162461bcd60e51b81526004810185905260116024820152702aa72b22a924a324a2a22fa9a2a72222a960791b6044820152606490fd5b604051634b637e8f60e11b81525f6004820152602490fd5b9291906001600160a01b03808516918215611d885716918215611c3a57815f5260209060108252604060ff815f20541615611c0357845f526010835260ff815f20541615611bc957835f525f8352805f205496828810611e3f575081849596977fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef955f525f855203815f2055855f52805f2082815401905551908152a3565b905163391434e360e21b81526001600160a01b0390911660048201526024810187905260448101829052606490fd5b90815f52600860205260405f209060018060a01b031690815f5260205260ff60405f205416155f14611ee657815f52600860205260405f20815f5260205260405f20600160ff1982541617905533917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d5f80a4600190565b50505f90565b307f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03161480611fee575b15611f47577f000000000000000000000000000000000000000000000000000000000000000090565b60405160208101907f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f82527f000000000000000000000000000000000000000000000000000000000000000060408201527f000000000000000000000000000000000000000000000000000000000000000060608201524660808201523060a082015260a0815260c0810181811067ffffffffffffffff8211176118cf5760405251902090565b507f00000000000000000000000000000000000000000000000000000000000000004614611f1e565b90815f52600860205260405f209060018060a01b031690815f5260205260ff60405f2054165f14611ee657815f52600860205260405f20815f5260205260405f2060ff19815416905533917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b5f80a4600190565b9190820391821161209857565b634e487b7160e01b5f52601160045260245ffd5b9190820180921161209857565b8181029291811591840414171561209857565b6001600160a01b0390811691821561214157169182156121295760207f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591835f526001825260405f20855f5282528060405f2055604051908152a3565b604051634a1406b160e11b81525f6004820152602490fd5b60405163e602df0560e01b81525f6004820152602490fd5b60ff81146121975760ff811690601f8211612185576040519161217b836118b3565b8252602082015290565b604051632cd44ac360e21b8152600490fd5b50604051600554815f6121a98361187b565b8083529260209060019081811690811561223657506001146121d7575b50506121d4925003826118e3565b90565b91509260055f527f036b6384b5eca791c62761152d0c79bb0604c104a5fb6f4eb0703f3154bb3db0935f925b82841061221e57506121d49450505081016020015f806121c6565b85548785018301529485019486945092810192612203565b915050602092506121d494915060ff191682840152151560051b8201015f806121c6565b60ff811461227c5760ff811690601f8211612185576040519161217b836118b3565b50604051600654815f61228e8361187b565b8083529260209060019081811690811561223657506001146122b85750506121d4925003826118e3565b91509260065f527ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f935f925b8284106122ff57506121d49450505081016020015f806121c6565b855487850183015294850194869450928101926122e4565b91907f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08411612399579160209360809260ff5f9560405194855216868401526040830152606082015282805260015afa1561238e575f516001600160a01b0381161561238457905f905f90565b505f906001905f90565b6040513d5f823e3d90fd5b5050505f9160039190565b600481101561241357806123b6575050565b600181036123d05760405163f645eedf60e01b8152600490fd5b600281036123f15760405163fce698f760e01b815260048101839052602490fd5b6003146123fb5750565b602490604051906335e2f38360e21b82526004820152fd5b634e487b7160e01b5f52602160045260245ffd5b9061244e575080511561243c57805190602001fd5b604051630a12f52160e11b8152600490fd5b81511580612481575b61245f575090565b604051639996b31560e01b81526001600160a01b039091166004820152602490fd5b50803b1561245756fea2646970667358221220eb38ccdba384a967878c5d12f281a41d10870d97e83bc8f99306dfa938eda3dd64736f6c634300081800335eff886ea0ce6ca488a3d6e336d6c0f75f46d19b42c06ce5ee98e42c96d256c70000000000000000000000003def017cd003f44aa7b49bdfcf95fd61cf5294cb000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48
Deployed Bytecode
0x6080604081815260049182361015610015575f80fd5b5f3560e01c90816301ffc9a7146117555750806306fdde0314611683578063095ea7b31461165a5780630ca699c71461161a578063123a6a82146115c557806318160ddd146115a757806318819a311461158957806321260ef01461152257806321e822c5146114ce57806323b872dd146113dc578063248a9ca3146113b25780632f2ff15d1461138a578063313ce5671461136f5780633143ab571461131b5780633644e515146112f857806336568abe146112b4578063371fd8e6146111695780633e413bee146111265780633f4ba83a146110bf57806356d73568146110855780635872e6fa146110675780635c975abb1461104457806361d027b31461101c578063664692f214610ffe57806370a0823114610fc85780637ecebe0014610f915780638456cb5914610f3857806384b0196e14610e1a5780638ab1d68114610ddb57806391d1485414610d9757806395d89b4114610cab578063a217fddf14610c91578063a3d19d8c14610c35578063a9059cbb14610c05578063b2118a8d146109ed578063b6b55f2514610873578063bf32bf3614610855578063c2d24d4614610454578063c683630d14610819578063d505accf146106ba578063d547741f1461067e578063d8b0eadc14610660578063db006a75146104e4578063dd62ed3e1461049b578063e43252d714610459578063eecadaac14610454578063f05a6b6d14610436578063f0f44260146103855763fe0d94c11461023a575f80fd5b3461038157602036600319011261038157813591610256611a53565b821561034657906020836102ab9361027082600a546120ac565b600a5561027f82600c5461208b565b600c55835163a9059cbb60e01b8152339181019182526020820192909252909384918291604090910190565b03815f7f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb486001600160a01b03165af190811561033d575061030e575b507fddb556f1d2c1ec821e910b019d3685b229db152a0ecd517ca7e24b8bd71392895f80a2005b61032f9060203d602011610336575b61032781836118e3565b810190611a1d565b505f6102e7565b503d61031d565b513d5f823e3d90fd5b6020606492519162461bcd60e51b83528201526016602482015275455845435554455f414d4f554e545f49535f5a45524f60501b6044820152fd5b5f80fd5b509034610381576020366003190112610381576103a06117e5565b6103a8611a53565b6001600160a01b03169081156103fd577fc714d22a2f08b695f81e7c707058db484aa5b4d6b4c9fd64beb10fe85832f60860208385816bffffffffffffffffffffffff60a01b600f541617600f5551908152a1005b606490602084519162461bcd60e51b8352820152601360248201527229a2aa2faaa82faa27afad22a927afa0a2222960691b6044820152fd5b5034610381575f36600319011261038157602090516305f5e1008152f35b61185e565b5034610381576020366003190112610381576104736117e5565b61047b611a53565b6001600160a01b03165f908152601060205220805460ff19166001179055005b50346103815780600319360112610381576020906104b76117e5565b6104bf6117fb565b9060018060a01b038091165f5260018452825f2091165f528252805f20549051908152f35b50903461038157602036600319011261038157803590610502611a35565b61050d821515611982565b600e548061060457506105208233611c52565b610559602064e8d4a51000840480935b865163a9059cbb60e01b8152339181019182526020820192909252909283918291604090910190565b03815f7f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb486001600160a01b03165af180156105fa576105b19394506105db575b506105a681600c5461208b565b600c55600b5461208b565b600b55337f222838db2794d11532d940e8dec38ae307ed0b63cd97c233322e221f998767a65f80a3005b6105f39060203d6020116103365761032781836118e3565b505f610599565b84513d5f823e3d90fd5b60206305f5e10061061861055993866120b9565b0464e8d4a51000610629828761208b565b6106338133611c52565b0493818592610643575b50610530565b600f5461065a91906001600160a01b031633611da0565b5f61063d565b5034610381575f36600319011261038157602090600b549051908152f35b50346103815780600319360112610381576106b891356106b360016106a16117fb565b93835f5260086020525f200154611b22565b612017565b005b5090346103815760e0366003190112610381576106d56117e5565b6106dd6117fb565b906044359260643560843560ff81168103610381578142116108025760018060a01b039081851692835f526007602052885f209081549160018301905589519060208201927f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c98452868c840152858a1660608401528a608084015260a083015260c082015260c0815260e0810181811067ffffffffffffffff8211176107ef578a525190206107c1916107b891610792611eec565b908b519161190160f01b83526002830152602282015260c43591604260a4359220612317565b909291926123a4565b168181036107d4576106b88686866120cc565b86516325c0072360e11b815292830152602482015260449150fd5b604187634e487b7160e01b5f525260245ffd5b865163313c898160e11b8152808401839052602490fd5b5034610381576020366003190112610381576020906001600160a01b0361083e6117e5565b165f526010825260ff815f20541690519015158152f35b5034610381575f36600319011261038157602090600a549051908152f35b503461038157602036600319011261038157813591610890611a35565b82159061089d8215611905565b82516323b872dd60e01b81523382820190815230602082810191909152604082018790526001600160a01b0395918390819060600103815f897f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48165af190811561033d57506109ce575b5061091484600c546120ac565b600c5561092384600b546120ac565b600b5564e8d4a5100091828502928584041417156109bb5750600d54806109775750610950915033611b44565b337fe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c5f80a3005b6109946305f5e10061098c61099a93856120b9565b04809361208b565b33611b44565b806109a7575b5050610950565b6109b491600f5416611b44565b5f806109a0565b601190634e487b7160e01b5f525260245ffd5b6109e69060203d6020116103365761032781836118e3565b505f610907565b5090346103815760603660031901126103815780356001600160a01b038181169182900361038157610a1d6117fb565b9060443590610a2a611a53565b7f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4816808414610b41575b50845163a9059cbb60e01b602082019081526001600160a01b03939093166024820152604480820192909252908152601f19915f91829190610a976064826118e3565b519082865af13d15610b34573d67ffffffffffffffff8111610b215790610add9291610acd6020885194601f84011601846118e3565b82523d5f602084013e5b83612427565b8051908115159182610b06575b5050610af257005b6024925191635274afe760e01b8352820152fd5b610b199250602080918301019101611a1d565b155f80610aea565b604185634e487b7160e01b5f525260245ffd5b610add9150606090610ad7565b60206024918751928380926370a0823160e01b8252308a8301525afa8015610bfb575f90610bc7575b610b789150600c549061208b565b8111610b84575f610a54565b845162461bcd60e51b8152602081860152601f60248201527f555344435f5245534355455f414d4f554e545f4558434545445f4445424954006044820152606490fd5b506020813d602011610bf3575b81610be1602093836118e3565b8101031261038157610b789051610b6a565b3d9150610bd4565b86513d5f823e3d90fd5b5034610381578060031936011261038157602090610c2e610c246117e5565b6024359033611da0565b5160018152f35b503461038157610c4436611811565b91610c4d611a53565b5f5b838110610c5857005b6001906001600160a01b03610c76610c7183888861194a565b61196e565b165f526010602052825f208260ff1982541617905501610c4f565b5034610381575f36600319011261038157602090515f8152f35b509034610381575f36600319011261038157815191825f8354610ccd8161187b565b90818452602095600191876001821691825f14610d70575050600114610d14575b505050610d109291610d019103856118e3565b519282849384528301906117a7565b0390f35b5f90815286935091907f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b5b828410610d585750505082010181610d01610d10610cee565b8054848a018601528895508794909301928101610d3f565b60ff19168782015293151560051b86019093019350849250610d019150610d109050610cee565b5034610381578060031936011261038157602091610db36117fb565b90355f5260088352815f209060018060a01b03165f52825260ff815f20541690519015158152f35b503461038157602036600319011261038157610df56117e5565b610dfd611a53565b6001600160a01b03165f908152601060205220805460ff19169055005b509034610381575f36600319011261038157610e557f5350435400000000000000000000000000000000000000000000000000000004612159565b91610e7f7f310000000000000000000000000000000000000000000000000000000000000161225a565b815191602091602084019484861067ffffffffffffffff871117610f255750610eda8260209287610ecd99989795525f85528151988998600f60f81b8a5260e0868b015260e08a01906117a7565b91888303908901526117a7565b914660608701523060808701525f60a087015285830360c087015251918281520192915f5b828110610f0e57505050500390f35b835185528695509381019392810192600101610eff565b604190634e487b7160e01b5f525260245ffd5b5034610381575f3660031901126103815760207f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25891610f75611acc565b610f7d611a35565b600160ff19600954161760095551338152a1005b5034610381576020366003190112610381576020906001600160a01b03610fb66117e5565b165f5260078252805f20549051908152f35b5034610381576020366003190112610381576020906001600160a01b03610fed6117e5565b165f525f8252805f20549051908152f35b5034610381575f36600319011261038157602090600c549051908152f35b5034610381575f36600319011261038157600f5490516001600160a01b039091168152602090f35b5034610381575f3660031901126103815760209060ff6009541690519015158152f35b5034610381575f36600319011261038157602090600e549051908152f35b5034610381575f36600319011261038157602090517f6077685936c8169d09204a1d97db12e41713588c38e1d29a61867d3dcee98aff8152f35b5034610381575f366003190112610381576110d8611acc565b6009549160ff831615611118577f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6020838560ff191660095551338152a1005b9051638dfc202b60e01b8152fd5b5034610381575f36600319011261038157517f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb486001600160a01b03168152602090f35b503461038157602036600319011261038157813591611186611a53565b600a5480841161126557836111e393926111a28260209461208b565b600a556111b182600c546120ac565b600c5583516323b872dd60e01b8152339181019182523060208301526040820192909252909384918291606090910190565b03815f7f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb486001600160a01b03165af190811561033d5750611246575b507fa6ffc78a660e4971a47a0f916a0abae483804e6f42c9292ed06aa64f8fe462305f80a2005b61125e9060203d6020116103365761032781836118e3565b505f61121f565b506020608492519162461bcd60e51b8352820152602360248201527f52455041595f414d4f554e545f4558434545445f45584543555445445f53484160448201526252455360e81b6064820152fd5b50346103815780600319360112610381576112cd6117fb565b90336001600160a01b038316036112e957506106b89135612017565b5163334bd91960e11b81529050fd5b5034610381575f36600319011261038157602090611314611eec565b9051908152f35b82346103815760203660031901126103815735611336611a53565b611345620f42408211156119c6565b80600d557fb2956d477e9ae9221f099e28a17128777c4a3a3a710bb762fa426700e59bbb975f80a2005b5034610381575f366003190112610381576020905160128152f35b50346103815780600319360112610381576106b891356113ad60016106a16117fb565b611e6e565b503461038157602036600319011261038157602091355f52600882526001815f2001549051908152f35b509034610381576060366003190112610381576113f76117e5565b6113ff6117fb565b906044359260018060a01b038216805f526001602052855f20335f52602052855f2054915f19830361143a575b602087610c2e888888611da0565b8583106114a257811561148c57331561147657505f90815260016020908152868220338352815290869020918590039091558290610c2e61142c565b6024905f885191634a1406b160e11b8352820152fd5b6024905f88519163e602df0560e01b8352820152fd5b8651637dc7a0d960e11b8152339181019182526020820193909352604081018690528291506060010390fd5b823461038157602036600319011261038157356114e9611a53565b6114f8620f42408211156119c6565b80600e557fd467b60b26d4173f4875c5fbcd2e14cf43da3a2fd7424cf1776eff2cda18c25b5f80a2005b5034610381573660031901126103815761153a6117e5565b611562602435809261154a611a35565b611552611a53565b61155d821515611982565b611c52565b337f222838db2794d11532d940e8dec38ae307ed0b63cd97c233322e221f998767a65f80a3005b5034610381575f36600319011261038157602090600d549051908152f35b5034610381575f366003190112610381576020906002549051908152f35b5034610381576115d436611811565b916115dd611a53565b5f5b8381106115e857005b6001906001600160a01b03611601610c7183888861194a565b165f526010602052825f2060ff198154169055016115df565b503461038157366003190112610381576116326117e5565b6109506024358092611642611a35565b61164a611a53565b611655821515611905565b611b44565b5034610381578060031936011261038157602090610c2e6116796117e5565b60243590336120cc565b5034610381575f3660031901126103815780516003549091825f6116a68461187b565b808352602094600190866001821691825f146117335750506001146116d8575b5050610d109291610d019103856118e3565b9085925060035f527fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b915f925b82841061171b5750505082010181610d016116c6565b8054848a018601528895508794909301928101611705565b60ff19168682015292151560051b85019092019250839150610d0190506116c6565b833461038157602036600319011261038157359063ffffffff60e01b821680920361038157602091637965db0b60e01b8114908115611796575b5015158152f35b6301ffc9a760e01b1490508361178f565b91908251928382525f5b8481106117d1575050825f602080949584010152601f8019910116010190565b6020818301810151848301820152016117b1565b600435906001600160a01b038216820361038157565b602435906001600160a01b038216820361038157565b9060206003198301126103815760043567ffffffffffffffff9283821161038157806023830112156103815781600401359384116103815760248460051b83010111610381576024019190565b34610381575f366003190112610381576020604051620f42408152f35b90600182811c921680156118a9575b602083101461189557565b634e487b7160e01b5f52602260045260245ffd5b91607f169161188a565b6040810190811067ffffffffffffffff8211176118cf57604052565b634e487b7160e01b5f52604160045260245ffd5b90601f8019910116810190811067ffffffffffffffff8211176118cf57604052565b1561190c57565b60405162461bcd60e51b81526020600482015260166024820152754445504f5349545f414d4f554e545f49535f5a45524f60501b6044820152606490fd5b919081101561195a5760051b0190565b634e487b7160e01b5f52603260045260245ffd5b356001600160a01b03811681036103815790565b1561198957565b60405162461bcd60e51b815260206004820152601560248201527452454445454d5f414d4f554e545f49535f5a45524f60581b6044820152606490fd5b156119cd57565b60405162461bcd60e51b815260206004820152602260248201527f53484f554c445f42455f4c4553535f5448414e5f4f525f455155414c5f544f5f604482015261031560f41b6064820152608490fd5b90816020910312610381575180151581036103815790565b60ff60095416611a4157565b60405163d93c066560e01b8152600490fd5b335f9081527f21e04bb1dd5b7e22c69104638dd01721ade7ca4fd4ac34e47ddd7469cc905be960205260409020547f6077685936c8169d09204a1d97db12e41713588c38e1d29a61867d3dcee98aff9060ff1615611aae5750565b6044906040519063e2517d3f60e01b82523360048301526024820152fd5b335f9081527f5eff886ea0ce6ca488a3d6e336d6c0f75f46d19b42c06ce5ee98e42c96d256c7602052604090205460ff1615611b0457565b60405163e2517d3f60e01b81523360048201525f6024820152604490fd5b805f52600860205260405f20335f5260205260ff60405f20541615611aae5750565b6001600160a01b0316908115611c3a575f805260209060108252604060ff815f20541615611c0357835f526010835260ff815f20541615611bc95791815f93611bb07fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef946002546120ac565b60025585855284835280852082815401905551908152a3565b5162461bcd60e51b81526004810183905260146024820152731553959154925192515117d49150d2541251539560621b6044820152606490fd5b5162461bcd60e51b81526004810183905260116024820152702aa72b22a924a324a2a22fa9a2a72222a960791b6044820152606490fd5b60405163ec442f0560e01b81525f6004820152602490fd5b6001600160a01b038116918215611d8857825f526020916010835260409060ff825f20541615611d50575f80526010845260ff825f20541615611d1557845f525f8452815f205490838210611ce4575091849391817fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef945f9788528785520381872055816002540360025551908152a3565b825163391434e360e21b81526001600160a01b03919091166004820152602481019190915260448101839052606490fd5b815162461bcd60e51b81526004810185905260146024820152731553959154925192515117d49150d2541251539560621b6044820152606490fd5b815162461bcd60e51b81526004810185905260116024820152702aa72b22a924a324a2a22fa9a2a72222a960791b6044820152606490fd5b604051634b637e8f60e11b81525f6004820152602490fd5b9291906001600160a01b03808516918215611d885716918215611c3a57815f5260209060108252604060ff815f20541615611c0357845f526010835260ff815f20541615611bc957835f525f8352805f205496828810611e3f575081849596977fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef955f525f855203815f2055855f52805f2082815401905551908152a3565b905163391434e360e21b81526001600160a01b0390911660048201526024810187905260448101829052606490fd5b90815f52600860205260405f209060018060a01b031690815f5260205260ff60405f205416155f14611ee657815f52600860205260405f20815f5260205260405f20600160ff1982541617905533917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d5f80a4600190565b50505f90565b307f000000000000000000000000f30a29f1c540724fd8c5c4be1af604a6c6800d296001600160a01b03161480611fee575b15611f47577fdbf45866b965b099e39c5eb2229d39f18981a675738abb608ccbef0da46fceae90565b60405160208101907f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f82527f89131f7876dfb5ce3307b3478f07cd82682d0a50accf748285192d5974485d4060408201527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608201524660808201523060a082015260a0815260c0810181811067ffffffffffffffff8211176118cf5760405251902090565b507f00000000000000000000000000000000000000000000000000000000000000014614611f1e565b90815f52600860205260405f209060018060a01b031690815f5260205260ff60405f2054165f14611ee657815f52600860205260405f20815f5260205260405f2060ff19815416905533917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b5f80a4600190565b9190820391821161209857565b634e487b7160e01b5f52601160045260245ffd5b9190820180921161209857565b8181029291811591840414171561209857565b6001600160a01b0390811691821561214157169182156121295760207f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591835f526001825260405f20855f5282528060405f2055604051908152a3565b604051634a1406b160e11b81525f6004820152602490fd5b60405163e602df0560e01b81525f6004820152602490fd5b60ff81146121975760ff811690601f8211612185576040519161217b836118b3565b8252602082015290565b604051632cd44ac360e21b8152600490fd5b50604051600554815f6121a98361187b565b8083529260209060019081811690811561223657506001146121d7575b50506121d4925003826118e3565b90565b91509260055f527f036b6384b5eca791c62761152d0c79bb0604c104a5fb6f4eb0703f3154bb3db0935f925b82841061221e57506121d49450505081016020015f806121c6565b85548785018301529485019486945092810192612203565b915050602092506121d494915060ff191682840152151560051b8201015f806121c6565b60ff811461227c5760ff811690601f8211612185576040519161217b836118b3565b50604051600654815f61228e8361187b565b8083529260209060019081811690811561223657506001146122b85750506121d4925003826118e3565b91509260065f527ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f935f925b8284106122ff57506121d49450505081016020015f806121c6565b855487850183015294850194869450928101926122e4565b91907f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08411612399579160209360809260ff5f9560405194855216868401526040830152606082015282805260015afa1561238e575f516001600160a01b0381161561238457905f905f90565b505f906001905f90565b6040513d5f823e3d90fd5b5050505f9160039190565b600481101561241357806123b6575050565b600181036123d05760405163f645eedf60e01b8152600490fd5b600281036123f15760405163fce698f760e01b815260048101839052602490fd5b6003146123fb5750565b602490604051906335e2f38360e21b82526004820152fd5b634e487b7160e01b5f52602160045260245ffd5b9061244e575080511561243c57805190602001fd5b604051630a12f52160e11b8152600490fd5b81511580612481575b61245f575090565b604051639996b31560e01b81526001600160a01b039091166004820152602490fd5b50803b1561245756fea2646970667358221220eb38ccdba384a967878c5d12f281a41d10870d97e83bc8f99306dfa938eda3dd64736f6c63430008180033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
0000000000000000000000003def017cd003f44aa7b49bdfcf95fd61cf5294cb000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48
-----Decoded View---------------
Arg [0] : admin (address): 0x3deF017cd003f44aa7b49BdFcF95fD61cF5294Cb
Arg [1] : _usdc (address): 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48
-----Encoded View---------------
2 Constructor Arguments found :
Arg [0] : 0000000000000000000000003def017cd003f44aa7b49bdfcf95fd61cf5294cb
Arg [1] : 000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|---|---|---|---|---|
ETH | 100.00% | $1 | 156.0614 | $156.37 |
Loading...
Loading
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.