Overview
ETH Balance
ETH Value
$0.00More Info
Private Name Tags
ContractCreator
TokenTracker
Multichain Info
Latest 1 from a total of 1 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Connect Socket | 11394122 | 16 days ago | IN | 0 ETH | 0.00000145 |
View more zero value Internal Transactions in Advanced View mode
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity ^0.8.19; import "lib/solady/src/tokens/ERC20.sol"; import "../../utils/AccessControl.sol"; import "../../utils/RescueFundsLib.sol"; import "../../protocol/base/PlugBase.sol"; import {RESCUE_ROLE} from "../../utils/common/AccessRoles.sol"; import "../interfaces/IFeesManager.sol"; /// @title AdvancedToken /// @notice An advanced ERC20 token with minting, burning, and pausing capabilities /// @author Your Name contract SUSDC is ERC20, AccessControl, PlugBase { /// @notice The name of the token string private _name; /// @notice The symbol of the token string private _symbol; /// @notice The number of decimals for the token uint8 private _decimals; /// @notice Emitted when tokens are minted event TokensMinted(address indexed to, uint256 amount); /// @notice Emitted when tokens are burned event TokensBurned(address indexed from, address indexed to, uint256 amount, bytes data); /// @notice Constructor that sets token metadata and mints initial supply /// @param initialOwner The address to receive the initial supply and ownership /// @param tokenName The name of the token /// @param tokenSymbol The symbol of the token /// @param tokenDecimals The number of decimals for the token constructor( uint8 tokenDecimals, address initialOwner, address socket, string memory tokenName, string memory tokenSymbol ) { isSocketInitialized = 1; _decimals = tokenDecimals; _name = tokenName; _symbol = tokenSymbol; _setSocket(socket); _initializeOwner(initialOwner); } /// @notice Returns the name of the token /// @return The name of the token function name() public view override returns (string memory) { return _name; } /// @notice Returns the symbol of the token /// @return The symbol of the token function symbol() public view override returns (string memory) { return _symbol; } /// @notice Returns the number of decimals used to get its user representation /// @return The number of decimals function decimals() public view override returns (uint8) { return _decimals; } /// @notice Mints new tokens (only owner) /// @param to The address to mint tokens to /// @param amount The amount of tokens to mint function mint(address to, uint256 amount) external onlySocket { require(to != address(0), "Cannot mint to zero address"); require(amount > 0, "Amount must be greater than 0"); _mint(to, amount); emit TokensMinted(to, amount); } /// @notice Burns tokens from the caller's balance /// @param amount The amount of tokens to burn function burn(address receiver_, uint256 amount, bytes memory data_) external { require(amount > 0, "Amount must be greater than 0"); require(balanceOf(msg.sender) >= amount, "Insufficient balance"); _burn(msg.sender, amount); IFeesManager(address(socket__)).mint(receiver_, amount, data_); emit TokensBurned(msg.sender, receiver_, amount, data_); } /// @notice Override transfer function to check for paused state /// @param to The address to transfer tokens to /// @param amount The amount of tokens to transfer /// @return True if the transfer was successful function transfer(address to, uint256 amount) public override returns (bool) { return super.transfer(to, amount); } /// @notice Override transferFrom function to check for paused state /// @param from The address to transfer tokens from /// @param to The address to transfer tokens to /// @param amount The amount of tokens to transfer /// @return True if the transfer was successful function transferFrom(address from, address to, uint256 amount) public override returns (bool) { return super.transferFrom(from, to, amount); } function connectSocket( bytes32 appGatewayId_, address socket_, uint64 switchboardId_ ) external onlyOwner { _connectSocket(appGatewayId_, socket_, switchboardId_); } function disconnectSocket() external onlyOwner { socket__.disconnect(); } /** * @notice Rescues funds from the contract if they are locked by mistake. This contract does not * theoretically need this function but it is added for safety. * @param token_ The address of the token contract. * @param rescueTo_ The address where rescued tokens need to be sent. * @param amount_ The amount of tokens to be rescued. */ function rescueFunds( address token_, address rescueTo_, uint256 amount_ ) external onlyRole(RESCUE_ROLE) { RescueFundsLib._rescueFunds(token_, rescueTo_, amount_); } }
// SPDX-License-Identifier: GPL-3.0-only pragma solidity ^0.8.21; import {WriteFinality, AppGatewayApprovals, OverrideParams, Transaction, QueueParams, RequestParams} from "../../utils/common/Structs.sol"; interface IFeesManager { function deposit( uint32 chainSlug_, address token_, address depositTo_, uint256 nativeAmount_, uint256 creditAmount_, bytes memory data_ ) external; function wrap(address receiver_) external payable; function unwrap(uint256 amount_, address receiver_) external; function isCreditSpendable( address consumeFrom_, address spender_, uint256 amount_ ) external view returns (bool); function approve(address appGateway_, bool approval_) external; function batchApprove(AppGatewayApprovals[] calldata params_) external; function approveWithSignature( bytes memory feeApprovalData_ ) external returns (address consumeFrom, address spender, bool approval); function withdrawCredits( uint32 chainSlug_, address token_, uint256 credits_, uint256 maxFees_, address receiver_ ) external; function blockCredits(uint40 requestCount_, address consumeFrom_, uint256 credits_) external; function unblockAndAssignCredits(uint40 requestCount_, address assignTo_) external; function unblockCredits(uint40 requestCount_) external; function isApproved(address appGateway_, address user_) external view returns (bool); function burn(uint32 chainSlug_, address receiver_, uint256 amount_) external; function mint(address to, uint256 amount, bytes memory data_) external; function setMaxFees(uint256 fees_) external; }
// SPDX-License-Identifier: GPL-3.0-only pragma solidity ^0.8.21; import {ISocket} from "../interfaces/ISocket.sol"; import {IPlug} from "../interfaces/IPlug.sol"; import {NotSocket, SocketAlreadyInitialized} from "../../utils/common/Errors.sol"; /// @title PlugBase /// @notice Abstract contract for plugs /// @dev This contract contains helpers for socket connection, disconnection, and overrides abstract contract PlugBase is IPlug { // socket instance ISocket public socket__; // app gateway id connected to this plug bytes32 public appGatewayId; // tracks if socket is initialized uint256 public isSocketInitialized; // overrides encoded in bytes bytes public overrides; // event emitted when plug is disconnected event ConnectorPlugDisconnected(); /// @notice Modifier to ensure only the socket can call the function /// @dev only the socket can call the function modifier onlySocket() { if (msg.sender != address(socket__)) revert NotSocket(); _; } /// @notice Modifier to ensure the socket is initialized and if not already initialized, it will be initialized modifier socketInitializer() { if (isSocketInitialized == 1) revert SocketAlreadyInitialized(); isSocketInitialized = 1; _; } /// @notice Connects the plug to the app gateway and switchboard /// @param appGatewayId_ The app gateway id /// @param socket_ The socket address /// @param switchboardId_ The switchboard id function _connectSocket( bytes32 appGatewayId_, address socket_, uint64 switchboardId_ ) internal { _setSocket(socket_); appGatewayId = appGatewayId_; // connect to the app gateway and switchboard socket__.connect(appGatewayId_, switchboardId_); } /// @notice Disconnects the plug from the socket function _disconnectSocket() internal { socket__.disconnect(); emit ConnectorPlugDisconnected(); } /// @notice Sets the socket /// @param socket_ The socket address function _setSocket(address socket_) internal { socket__ = ISocket(socket_); } /// @notice Sets the overrides needed for the trigger /// @dev encoding format depends on the watcher system /// @param overrides_ The overrides function _setOverrides(bytes memory overrides_) internal { overrides = overrides_; } /// @notice Initializes the socket /// @dev this function should be called even if deployed independently /// to avoid ownership and permission exploit /// @param appGatewayId_ The app gateway id /// @param socket_ The socket address /// @param switchboardId_ The switchboard id function initSocket( bytes32 appGatewayId_, address socket_, uint64 switchboardId_ ) external virtual socketInitializer { _connectSocket(appGatewayId_, socket_, switchboardId_); } }
// SPDX-License-Identifier: GPL-3.0-only pragma solidity ^0.8.21; /** * @title IPlug * @notice Interface for a plug contract that executes the payload received from a source chain. */ interface IPlug { /// @notice Initializes the socket /// @param appGatewayId_ The app gateway id /// @param socket_ The socket address /// @param switchboardId_ The switchboard id function initSocket(bytes32 appGatewayId_, address socket_, uint64 switchboardId_) external; /// @notice Gets the overrides /// @dev encoding format depends on the watcher system /// @return overrides_ The overrides function overrides() external view returns (bytes memory overrides_); }
// SPDX-License-Identifier: GPL-3.0-only pragma solidity ^0.8.21; import {ExecuteParams, TransmissionParams, ExecutionStatus} from "../../utils/common/Structs.sol"; /** * @title ISocket * @notice An interface for a Chain Abstraction contract * @dev This interface provides methods for transmitting and executing payloads, * connecting a plug to a remote chain and setting up switchboards for the payload transmission * This interface also emits events for important operations such as payload transmission, execution status, * and plug connection */ interface ISocket { /** * @notice emits the status of payload after external call * @param payloadId payload id which is executed */ event ExecutionSuccess(bytes32 payloadId, bool exceededMaxCopy, bytes returnData); /** * @notice emits the status of payload after external call * @param payloadId payload id which is executed */ event ExecutionFailed(bytes32 payloadId, bool exceededMaxCopy, bytes returnData); /** * @notice emits the config set by a plug for a remoteChainSlug * @param plug The address of plug on current chain * @param appGatewayId The address of plug on sibling chain * @param switchboardId The outbound switchboard (select from registered options) */ event PlugConnected(address plug, bytes32 appGatewayId, uint64 switchboardId); /** * @notice emits the config set by a plug for a remoteChainSlug * @param plug The address of plug on current chain */ event PlugDisconnected(address plug); /** * @notice emits the payload details when a new payload arrives at outbound * @param triggerId trigger id * @param switchboardId switchboard id * @param plug local plug address * @param overrides params, for specifying details like fee pool chain, fee pool token and max fees if required * @param payload the data which will be used by contracts on chain */ event AppGatewayCallRequested( bytes32 triggerId, bytes32 appGatewayId, uint64 switchboardId, bytes32 plug, bytes overrides, bytes payload ); /** * @notice Executes a payload * @param executeParams_ The execution parameters * @param transmissionParams_ The transmission parameters * @return success True if the payload was executed successfully * @return returnData The return data from the execution */ function execute( ExecuteParams calldata executeParams_, TransmissionParams calldata transmissionParams_ ) external payable returns (bool, bytes memory); /** * @notice sets the config specific to the plug * @param appGatewayId_ The address of plug present at sibling chain * @param switchboardId_ The id of switchboard to use for executing payloads */ function connect(bytes32 appGatewayId_, uint64 switchboardId_) external; /** * @notice Disconnects Plug from Socket */ function disconnect() external; /** * @notice Registers a switchboard for the socket * @return switchboardId The id of the switchboard */ function registerSwitchboard() external returns (uint64); /** * @notice Returns the config for given `plugAddress_` and `siblingChainSlug_` * @param plugAddress_ The address of plug present at current chain * @return appGatewayId The address of plug on sibling chain * @return switchboardId The id of the switchboard */ function getPlugConfig( address plugAddress_ ) external view returns (bytes32 appGatewayId, uint64 switchboardId); /** * @notice Returns the execution status of a payload * @param payloadId_ The payload id * @return executionStatus The execution status */ function payloadExecuted(bytes32 payloadId_) external view returns (ExecutionStatus); /** * @notice Returns the chain slug * @return chainSlug The chain slug */ function chainSlug() external view returns (uint32); /** * @notice Returns the digest of a payload * @param payloadId_ The payload id * @return digest The digest */ function payloadIdToDigest(bytes32 payloadId_) external view returns (bytes32); /** * @notice Returns the current trigger counter * @return triggerCounter The trigger counter */ function triggerCounter() external view returns (uint64); /** * @notice Returns the switchboard address for a given switchboard id * @param switchboardId_ The switchboard id * @return switchboardAddress The switchboard address */ function switchboardAddresses(uint64 switchboardId_) external view returns (address); }
// SPDX-License-Identifier: GPL-3.0-only pragma solidity ^0.8.21; import "lib/solady/src/auth/Ownable.sol"; /** * @title AccessControl * @dev This abstract contract implements access control mechanism based on roles. * Each role can have one or more addresses associated with it, which are granted * permission to execute functions with the onlyRole modifier. */ abstract contract AccessControl is Ownable { /** * @dev A mapping of roles to a mapping of addresses to boolean values indicating whether or not they have the role. * @dev slot 0 */ mapping(bytes32 => mapping(address => bool)) private _permits; // slots 1-50: gap for future storage variables uint256[49] _gap_access_control; /** * @dev Emitted when a role is granted to an address. */ event RoleGranted(bytes32 indexed role, address indexed grantee); /** * @dev Emitted when a role is revoked from an address. */ event RoleRevoked(bytes32 indexed role, address indexed revokee); /** * @dev Error message thrown when an address does not have permission to execute a function with onlyRole modifier. */ error NoPermit(bytes32 role); /** * @dev Modifier that restricts access to addresses having roles * Throws an error if the caller do not have permit */ modifier onlyRole(bytes32 role) { if (!_permits[role][msg.sender]) revert NoPermit(role); _; } /** * @dev Checks and reverts if an address do not have a specific role. * @param role_ The role to check. * @param address_ The address to check. */ function _checkRole(bytes32 role_, address address_) internal virtual { if (!_hasRole(role_, address_)) revert NoPermit(role_); } /** * @dev Grants a role to a given address. * @param role_ The role to grant. * @param grantee_ The address to grant the role to. * Emits a RoleGranted event. * Can only be called by the owner of the contract. */ function grantRole(bytes32 role_, address grantee_) external virtual onlyOwner { _grantRole(role_, grantee_); } /** * @dev Revokes a role from a given address. * @param role_ The role to revoke. * @param revokee_ The address to revoke the role from. * Emits a RoleRevoked event. * Can only be called by the owner of the contract. */ function revokeRole(bytes32 role_, address revokee_) external virtual onlyOwner { _revokeRole(role_, revokee_); } /** * @dev Internal function to grant a role to a given address. * @param role_ The role to grant. * @param grantee_ The address to grant the role to. * Emits a RoleGranted event. */ function _grantRole(bytes32 role_, address grantee_) internal { _permits[role_][grantee_] = true; emit RoleGranted(role_, grantee_); } /** * @dev Internal function to revoke a role from a given address. * @param role_ The role to revoke. * @param revokee_ The address to revoke the role from. * Emits a RoleRevoked event. */ function _revokeRole(bytes32 role_, address revokee_) internal { _permits[role_][revokee_] = false; emit RoleRevoked(role_, revokee_); } /** * @dev Checks whether an address has a specific role. * @param role_ The role to check. * @param address_ The address to check. * @return A boolean value indicating whether or not the address has the role. */ function hasRole(bytes32 role_, address address_) external view returns (bool) { return _hasRole(role_, address_); } function _hasRole(bytes32 role_, address address_) internal view returns (bool) { return _permits[role_][address_]; } }
// SPDX-License-Identifier: GPL-3.0-only pragma solidity ^0.8.21; // contains role hashes used in socket for various different operation // used to rescue funds bytes32 constant RESCUE_ROLE = keccak256("RESCUE_ROLE"); // used by governance bytes32 constant GOVERNANCE_ROLE = keccak256("GOVERNANCE_ROLE"); // used by transmitters who execute payloads in socket bytes32 constant TRANSMITTER_ROLE = keccak256("TRANSMITTER_ROLE"); // used by switchboard watchers who work against transmitters bytes32 constant WATCHER_ROLE = keccak256("WATCHER_ROLE"); // used to disable switchboard bytes32 constant SWITCHBOARD_DISABLER_ROLE = keccak256("SWITCHBOARD_DISABLER_ROLE"); // used by fees manager to withdraw native tokens bytes32 constant FEE_MANAGER_ROLE = keccak256("FEE_MANAGER_ROLE");
// SPDX-License-Identifier: GPL-3.0-only pragma solidity ^0.8.21; address constant ETH_ADDRESS = address(0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE); bytes32 constant FORWARD_CALL = keccak256("FORWARD_CALL"); bytes32 constant DISTRIBUTE_FEE = keccak256("DISTRIBUTE_FEE"); bytes32 constant DEPLOY = keccak256("DEPLOY"); bytes4 constant READ = bytes4(keccak256("READ")); bytes4 constant WRITE = bytes4(keccak256("WRITE")); bytes4 constant SCHEDULE = bytes4(keccak256("SCHEDULE")); bytes32 constant CALLBACK = keccak256("CALLBACK"); bytes32 constant FAST = keccak256("FAST"); bytes32 constant CCTP = keccak256("CCTP"); uint256 constant PAYLOAD_SIZE_LIMIT = 24_500; uint16 constant MAX_COPY_BYTES = 2048; // 2KB uint32 constant CHAIN_SLUG_SOLANA_MAINNET = 10000001; uint32 constant CHAIN_SLUG_SOLANA_DEVNET = 10000002; // Constant appGatewayId used on all chains bytes32 constant APP_GATEWAY_ID = 0xdeadbeefcafebabe1234567890abcdef1234567890abcdef1234567890abcdef;
// SPDX-License-Identifier: GPL-3.0-only pragma solidity ^0.8.21; error ZeroAddress(); error InvalidTransmitter(); error InvalidTokenAddress(); error InvalidSwitchboard(); error SocketAlreadyInitialized(); // Socket error NotSocket(); error PlugNotFound(); // EVMx error ResolvingScheduleTooEarly(); error CallFailed(); error InvalidAppGateway(); error AppGatewayAlreadyCalled(); error InvalidCallerTriggered(); error InvalidPromise(); error InvalidWatcherSignature(); error NonceUsed(); error AsyncModifierNotSet(); error WatcherNotSet(); error InvalidTarget(); error InvalidIndex(); error InvalidChainSlug(); error InvalidPayloadSize(); error InvalidOnChainAddress(); error InvalidScheduleDelay(); /// @notice Error thrown when trying to start or bid a closed auction error AuctionClosed(); /// @notice Error thrown when trying to start or bid an auction that is not open error AuctionNotOpen(); /// @notice Error thrown if fees exceed the maximum set fees error BidExceedsMaxFees(); /// @notice Error thrown if a lower bid already exists error LowerBidAlreadyExists(); /// @notice Error thrown when request count mismatch error RequestCountMismatch(); error InvalidAmount(); error InsufficientCreditsAvailable(); error InsufficientBalance(); /// @notice Error thrown when a caller is invalid error InvalidCaller(); /// @notice Error thrown when a gateway is invalid error InvalidGateway(); /// @notice Error thrown when a request is already cancelled error RequestAlreadyCancelled(); error DeadlineNotPassedForOnChainRevert(); error InvalidBid(); error MaxReAuctionCountReached(); error MaxMsgValueLimitExceeded(); /// @notice Error thrown when an invalid address attempts to call the Watcher only function error OnlyWatcherAllowed(); error InvalidPrecompileData(); error InvalidCallType(); error NotRequestHandler(); error NotInvoker(); error NotPromiseResolver(); error RequestPayloadCountLimitExceeded(); error InsufficientFees(); error RequestAlreadySettled(); error NoWriteRequest(); error AlreadyAssigned(); error OnlyAppGateway(); error NewMaxFeesLowerThanCurrent(uint256 currentMaxFees, uint256 newMaxFees); error InvalidContract(); error InvalidData(); error InvalidSignature(); error DeadlinePassed(); // Only Watcher can call functions error OnlyRequestHandlerAllowed(); error OnlyPromiseResolverAllowed(); error InvalidReceiver();
// SPDX-License-Identifier: GPL-3.0-only pragma solidity ^0.8.21; //// ENUMS //// enum IsPlug { YES, NO } enum Parallel { OFF, ON } enum Read { OFF, ON } enum WriteFinality { LOW, MEDIUM, HIGH } enum SwitchboardStatus { NOT_REGISTERED, REGISTERED, DISABLED } /// @notice The state of the async promise enum AsyncPromiseState { WAITING_FOR_CALLBACK_SELECTOR, WAITING_FOR_CALLBACK_EXECUTION, CALLBACK_REVERTING, ONCHAIN_REVERTING, RESOLVED } enum ExecutionStatus { NotExecuted, Executed, Reverted } struct AppGatewayApprovals { address appGateway; bool approval; } //// STRUCTS //// struct AppGatewayConfig { PlugConfigGeneric plugConfig; bytes32 plug; uint32 chainSlug; } // Plug config: struct PlugConfigGeneric { bytes32 appGatewayId; uint64 switchboardId; } // Plug config: struct PlugConfigEvm { bytes32 appGatewayId; uint64 switchboardId; } //trigger: struct TriggerParams { bytes32 triggerId; bytes32 plug; bytes32 appGatewayId; uint32 chainSlug; bytes overrides; bytes payload; } struct PromiseReturnData { bool exceededMaxCopy; bytes32 payloadId; bytes returnData; } // AM struct ExecuteParams { bytes4 callType; uint160 payloadPointer; uint256 deadline; uint256 gasLimit; uint256 value; bytes32 prevBatchDigestHash; address target; bytes payload; bytes extraData; } struct TransmissionParams { uint256 socketFees; address refundAddress; bytes extraData; bytes transmitterProof; } struct WatcherMultiCallParams { address contractAddress; bytes data; uint256 nonce; bytes signature; } struct CreateRequestResult { uint256 totalEstimatedWatcherFees; uint256 writeCount; address[] promiseList; PayloadParams[] payloadParams; } struct Bid { uint256 fee; address transmitter; bytes extraData; } struct UserCredits { uint256 totalCredits; uint256 blockedCredits; } // digest: struct DigestParams { bytes32 socket; bytes32 transmitter; bytes32 payloadId; uint256 deadline; bytes4 callType; uint256 gasLimit; uint256 value; bytes payload; bytes32 target; bytes32 appGatewayId; bytes32 prevBatchDigestHash; bytes extraData; } // App gateway base: struct OverrideParams { bytes4 callType; Parallel isParallelCall; WriteFinality writeFinality; uint256 gasLimit; uint256 value; uint256 readAtBlockNumber; uint256 delayInSeconds; } struct Transaction { uint32 chainSlug; bytes32 target; bytes payload; } struct QueueParams { OverrideParams overrideParams; Transaction transaction; address asyncPromise; bytes32 switchboardType; } struct PayloadParams { bytes4 callType; uint160 payloadPointer; address asyncPromise; address appGateway; bytes32 payloadId; uint256 resolvedAt; uint256 deadline; bytes precompileData; } // request struct RequestTrackingParams { bool isRequestCancelled; bool isRequestExecuted; uint40 currentBatch; uint256 currentBatchPayloadsLeft; uint256 payloadsRemaining; } struct RequestFeesDetails { uint256 maxFees; address consumeFrom; Bid winningBid; } struct RequestParams { RequestTrackingParams requestTrackingParams; RequestFeesDetails requestFeesDetails; address appGateway; address auctionManager; uint256 writeCount; bytes onCompleteData; } struct CCTPExecutionParams { ExecuteParams executeParams; bytes32 digest; bytes proof; bytes transmitterSignature; address refundAddress; } struct CCTPBatchParams { bytes32[] previousPayloadIds; uint32[] nextBatchRemoteChainSlugs; bytes[] messages; bytes[] attestations; } struct SolanaInstruction { SolanaInstructionData data; SolanaInstructionDataDescription description; } struct SolanaInstructionData { bytes32 programId; bytes32[] accounts; bytes8 instructionDiscriminator; // for now we assume the all functionArguments are simple types (uint256, address, bool, etc.) not complex types (struct, array, etc.) bytes[] functionArguments; } struct SolanaInstructionDataDescription { // flags for accounts, we only need isWritable for now // 0 bit - isWritable (0|1) bytes1[] accountFlags; // names for function argument types used later in data decoding in watcher and transmitter string[] functionArgumentTypeNames; }
// SPDX-License-Identifier: GPL-3.0-only pragma solidity ^0.8.21; import "lib/solady/src/utils/SafeTransferLib.sol"; import {ZeroAddress, InvalidTokenAddress} from "./common/Errors.sol"; import {ETH_ADDRESS} from "./common/Constants.sol"; interface IERC721 { function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } interface IERC165 { function supportsInterface(bytes4 interfaceId) external view returns (bool); } /** * @title RescueFundsLib * @dev A library that provides a function to rescue funds from a contract. */ library RescueFundsLib { /** * @dev Rescues funds from a contract. * @param token_ The address of the token contract. * @param rescueTo_ The address of the user. * @param amount_ The amount of tokens to be rescued. */ function _rescueFunds(address token_, address rescueTo_, uint256 amount_) internal { if (rescueTo_ == address(0)) revert ZeroAddress(); if (token_ == ETH_ADDRESS) { SafeTransferLib.forceSafeTransferETH(rescueTo_, amount_); } else { if (token_.code.length == 0) revert InvalidTokenAddress(); // Identify if a token is an NFT (ERC721) by checking if it supports the ERC721 interface try IERC165(token_).supportsInterface(0x80ac58cd) returns (bool isERC721) { if (isERC721) IERC721(token_).safeTransferFrom(address(this), rescueTo_, amount_, ""); else { SafeTransferLib.safeTransfer(token_, rescueTo_, amount_); } } catch { SafeTransferLib.safeTransfer(token_, rescueTo_, amount_); } } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; /// @notice Simple single owner authorization mixin. /// @author Solady (https://github.com/vectorized/solady/blob/main/src/auth/Ownable.sol) /// /// @dev Note: /// This implementation does NOT auto-initialize the owner to `msg.sender`. /// You MUST call the `_initializeOwner` in the constructor / initializer. /// /// While the ownable portion follows /// [EIP-173](https://eips.ethereum.org/EIPS/eip-173) for compatibility, /// the nomenclature for the 2-step ownership handover may be unique to this codebase. abstract contract Ownable { /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* CUSTOM ERRORS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev The caller is not authorized to call the function. error Unauthorized(); /// @dev The `newOwner` cannot be the zero address. error NewOwnerIsZeroAddress(); /// @dev The `pendingOwner` does not have a valid handover request. error NoHandoverRequest(); /// @dev Cannot double-initialize. error AlreadyInitialized(); /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* EVENTS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev The ownership is transferred from `oldOwner` to `newOwner`. /// This event is intentionally kept the same as OpenZeppelin's Ownable to be /// compatible with indexers and [EIP-173](https://eips.ethereum.org/EIPS/eip-173), /// despite it not being as lightweight as a single argument event. event OwnershipTransferred(address indexed oldOwner, address indexed newOwner); /// @dev An ownership handover to `pendingOwner` has been requested. event OwnershipHandoverRequested(address indexed pendingOwner); /// @dev The ownership handover to `pendingOwner` has been canceled. event OwnershipHandoverCanceled(address indexed pendingOwner); /// @dev `keccak256(bytes("OwnershipTransferred(address,address)"))`. uint256 private constant _OWNERSHIP_TRANSFERRED_EVENT_SIGNATURE = 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0; /// @dev `keccak256(bytes("OwnershipHandoverRequested(address)"))`. uint256 private constant _OWNERSHIP_HANDOVER_REQUESTED_EVENT_SIGNATURE = 0xdbf36a107da19e49527a7176a1babf963b4b0ff8cde35ee35d6cd8f1f9ac7e1d; /// @dev `keccak256(bytes("OwnershipHandoverCanceled(address)"))`. uint256 private constant _OWNERSHIP_HANDOVER_CANCELED_EVENT_SIGNATURE = 0xfa7b8eab7da67f412cc9575ed43464468f9bfbae89d1675917346ca6d8fe3c92; /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* STORAGE */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev The owner slot is given by: /// `bytes32(~uint256(uint32(bytes4(keccak256("_OWNER_SLOT_NOT")))))`. /// It is intentionally chosen to be a high value /// to avoid collision with lower slots. /// The choice of manual storage layout is to enable compatibility /// with both regular and upgradeable contracts. bytes32 internal constant _OWNER_SLOT = 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffff74873927; /// The ownership handover slot of `newOwner` is given by: /// ``` /// mstore(0x00, or(shl(96, user), _HANDOVER_SLOT_SEED)) /// let handoverSlot := keccak256(0x00, 0x20) /// ``` /// It stores the expiry timestamp of the two-step ownership handover. uint256 private constant _HANDOVER_SLOT_SEED = 0x389a75e1; /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* INTERNAL FUNCTIONS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Override to return true to make `_initializeOwner` prevent double-initialization. function _guardInitializeOwner() internal pure virtual returns (bool guard) {} /// @dev Initializes the owner directly without authorization guard. /// This function must be called upon initialization, /// regardless of whether the contract is upgradeable or not. /// This is to enable generalization to both regular and upgradeable contracts, /// and to save gas in case the initial owner is not the caller. /// For performance reasons, this function will not check if there /// is an existing owner. function _initializeOwner(address newOwner) internal virtual { if (_guardInitializeOwner()) { /// @solidity memory-safe-assembly assembly { let ownerSlot := _OWNER_SLOT if sload(ownerSlot) { mstore(0x00, 0x0dc149f0) // `AlreadyInitialized()`. revert(0x1c, 0x04) } // Clean the upper 96 bits. newOwner := shr(96, shl(96, newOwner)) // Store the new value. sstore(ownerSlot, or(newOwner, shl(255, iszero(newOwner)))) // Emit the {OwnershipTransferred} event. log3(0, 0, _OWNERSHIP_TRANSFERRED_EVENT_SIGNATURE, 0, newOwner) } } else { /// @solidity memory-safe-assembly assembly { // Clean the upper 96 bits. newOwner := shr(96, shl(96, newOwner)) // Store the new value. sstore(_OWNER_SLOT, newOwner) // Emit the {OwnershipTransferred} event. log3(0, 0, _OWNERSHIP_TRANSFERRED_EVENT_SIGNATURE, 0, newOwner) } } } /// @dev Sets the owner directly without authorization guard. function _setOwner(address newOwner) internal virtual { if (_guardInitializeOwner()) { /// @solidity memory-safe-assembly assembly { let ownerSlot := _OWNER_SLOT // Clean the upper 96 bits. newOwner := shr(96, shl(96, newOwner)) // Emit the {OwnershipTransferred} event. log3(0, 0, _OWNERSHIP_TRANSFERRED_EVENT_SIGNATURE, sload(ownerSlot), newOwner) // Store the new value. sstore(ownerSlot, or(newOwner, shl(255, iszero(newOwner)))) } } else { /// @solidity memory-safe-assembly assembly { let ownerSlot := _OWNER_SLOT // Clean the upper 96 bits. newOwner := shr(96, shl(96, newOwner)) // Emit the {OwnershipTransferred} event. log3(0, 0, _OWNERSHIP_TRANSFERRED_EVENT_SIGNATURE, sload(ownerSlot), newOwner) // Store the new value. sstore(ownerSlot, newOwner) } } } /// @dev Throws if the sender is not the owner. function _checkOwner() internal view virtual { /// @solidity memory-safe-assembly assembly { // If the caller is not the stored owner, revert. if iszero(eq(caller(), sload(_OWNER_SLOT))) { mstore(0x00, 0x82b42900) // `Unauthorized()`. revert(0x1c, 0x04) } } } /// @dev Returns how long a two-step ownership handover is valid for in seconds. /// Override to return a different value if needed. /// Made internal to conserve bytecode. Wrap it in a public function if needed. function _ownershipHandoverValidFor() internal view virtual returns (uint64) { return 48 * 3600; } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* PUBLIC UPDATE FUNCTIONS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Allows the owner to transfer the ownership to `newOwner`. function transferOwnership(address newOwner) public payable virtual onlyOwner { /// @solidity memory-safe-assembly assembly { if iszero(shl(96, newOwner)) { mstore(0x00, 0x7448fbae) // `NewOwnerIsZeroAddress()`. revert(0x1c, 0x04) } } _setOwner(newOwner); } /// @dev Allows the owner to renounce their ownership. function renounceOwnership() public payable virtual onlyOwner { _setOwner(address(0)); } /// @dev Request a two-step ownership handover to the caller. /// The request will automatically expire in 48 hours (172800 seconds) by default. function requestOwnershipHandover() public payable virtual { unchecked { uint256 expires = block.timestamp + _ownershipHandoverValidFor(); /// @solidity memory-safe-assembly assembly { // Compute and set the handover slot to `expires`. mstore(0x0c, _HANDOVER_SLOT_SEED) mstore(0x00, caller()) sstore(keccak256(0x0c, 0x20), expires) // Emit the {OwnershipHandoverRequested} event. log2(0, 0, _OWNERSHIP_HANDOVER_REQUESTED_EVENT_SIGNATURE, caller()) } } } /// @dev Cancels the two-step ownership handover to the caller, if any. function cancelOwnershipHandover() public payable virtual { /// @solidity memory-safe-assembly assembly { // Compute and set the handover slot to 0. mstore(0x0c, _HANDOVER_SLOT_SEED) mstore(0x00, caller()) sstore(keccak256(0x0c, 0x20), 0) // Emit the {OwnershipHandoverCanceled} event. log2(0, 0, _OWNERSHIP_HANDOVER_CANCELED_EVENT_SIGNATURE, caller()) } } /// @dev Allows the owner to complete the two-step ownership handover to `pendingOwner`. /// Reverts if there is no existing ownership handover requested by `pendingOwner`. function completeOwnershipHandover(address pendingOwner) public payable virtual onlyOwner { /// @solidity memory-safe-assembly assembly { // Compute and set the handover slot to 0. mstore(0x0c, _HANDOVER_SLOT_SEED) mstore(0x00, pendingOwner) let handoverSlot := keccak256(0x0c, 0x20) // If the handover does not exist, or has expired. if gt(timestamp(), sload(handoverSlot)) { mstore(0x00, 0x6f5e8818) // `NoHandoverRequest()`. revert(0x1c, 0x04) } // Set the handover slot to 0. sstore(handoverSlot, 0) } _setOwner(pendingOwner); } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* PUBLIC READ FUNCTIONS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Returns the owner of the contract. function owner() public view virtual returns (address result) { /// @solidity memory-safe-assembly assembly { result := sload(_OWNER_SLOT) } } /// @dev Returns the expiry timestamp for the two-step ownership handover to `pendingOwner`. function ownershipHandoverExpiresAt(address pendingOwner) public view virtual returns (uint256 result) { /// @solidity memory-safe-assembly assembly { // Compute the handover slot. mstore(0x0c, _HANDOVER_SLOT_SEED) mstore(0x00, pendingOwner) // Load the handover slot. result := sload(keccak256(0x0c, 0x20)) } } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* MODIFIERS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Marks a function as only callable by the owner. modifier onlyOwner() virtual { _checkOwner(); _; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; /// @notice Simple ERC20 + EIP-2612 implementation. /// @author Solady (https://github.com/vectorized/solady/blob/main/src/tokens/ERC20.sol) /// @author Modified from Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC20.sol) /// @author Modified from OpenZeppelin (https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/ERC20.sol) /// /// @dev Note: /// - The ERC20 standard allows minting and transferring to and from the zero address, /// minting and transferring zero tokens, as well as self-approvals. /// For performance, this implementation WILL NOT revert for such actions. /// Please add any checks with overrides if desired. /// - The `permit` function uses the ecrecover precompile (0x1). /// /// If you are overriding: /// - NEVER violate the ERC20 invariant: /// the total sum of all balances must be equal to `totalSupply()`. /// - Check that the overridden function is actually used in the function you want to /// change the behavior of. Much of the code has been manually inlined for performance. abstract contract ERC20 { /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* CUSTOM ERRORS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev The total supply has overflowed. error TotalSupplyOverflow(); /// @dev The allowance has overflowed. error AllowanceOverflow(); /// @dev The allowance has underflowed. error AllowanceUnderflow(); /// @dev Insufficient balance. error InsufficientBalance(); /// @dev Insufficient allowance. error InsufficientAllowance(); /// @dev The permit is invalid. error InvalidPermit(); /// @dev The permit has expired. error PermitExpired(); /// @dev The allowance of Permit2 is fixed at infinity. error Permit2AllowanceIsFixedAtInfinity(); /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* EVENTS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Emitted when `amount` tokens is transferred from `from` to `to`. event Transfer(address indexed from, address indexed to, uint256 amount); /// @dev Emitted when `amount` tokens is approved by `owner` to be used by `spender`. event Approval(address indexed owner, address indexed spender, uint256 amount); /// @dev `keccak256(bytes("Transfer(address,address,uint256)"))`. uint256 private constant _TRANSFER_EVENT_SIGNATURE = 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef; /// @dev `keccak256(bytes("Approval(address,address,uint256)"))`. uint256 private constant _APPROVAL_EVENT_SIGNATURE = 0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925; /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* STORAGE */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev The storage slot for the total supply. uint256 private constant _TOTAL_SUPPLY_SLOT = 0x05345cdf77eb68f44c; /// @dev The balance slot of `owner` is given by: /// ``` /// mstore(0x0c, _BALANCE_SLOT_SEED) /// mstore(0x00, owner) /// let balanceSlot := keccak256(0x0c, 0x20) /// ``` uint256 private constant _BALANCE_SLOT_SEED = 0x87a211a2; /// @dev The allowance slot of (`owner`, `spender`) is given by: /// ``` /// mstore(0x20, spender) /// mstore(0x0c, _ALLOWANCE_SLOT_SEED) /// mstore(0x00, owner) /// let allowanceSlot := keccak256(0x0c, 0x34) /// ``` uint256 private constant _ALLOWANCE_SLOT_SEED = 0x7f5e9f20; /// @dev The nonce slot of `owner` is given by: /// ``` /// mstore(0x0c, _NONCES_SLOT_SEED) /// mstore(0x00, owner) /// let nonceSlot := keccak256(0x0c, 0x20) /// ``` uint256 private constant _NONCES_SLOT_SEED = 0x38377508; /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* CONSTANTS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev `(_NONCES_SLOT_SEED << 16) | 0x1901`. uint256 private constant _NONCES_SLOT_SEED_WITH_SIGNATURE_PREFIX = 0x383775081901; /// @dev `keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)")`. bytes32 private constant _DOMAIN_TYPEHASH = 0x8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f; /// @dev `keccak256("1")`. /// If you need to use a different version, override `_versionHash`. bytes32 private constant _DEFAULT_VERSION_HASH = 0xc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc6; /// @dev `keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)")`. bytes32 private constant _PERMIT_TYPEHASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9; /// @dev The canonical Permit2 address. /// For signature-based allowance granting for single transaction ERC20 `transferFrom`. /// To enable, override `_givePermit2InfiniteAllowance()`. /// [Github](https://github.com/Uniswap/permit2) /// [Etherscan](https://etherscan.io/address/0x000000000022D473030F116dDEE9F6B43aC78BA3) address internal constant _PERMIT2 = 0x000000000022D473030F116dDEE9F6B43aC78BA3; /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* ERC20 METADATA */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Returns the name of the token. function name() public view virtual returns (string memory); /// @dev Returns the symbol of the token. function symbol() public view virtual returns (string memory); /// @dev Returns the decimals places of the token. function decimals() public view virtual returns (uint8) { return 18; } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* ERC20 */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Returns the amount of tokens in existence. function totalSupply() public view virtual returns (uint256 result) { /// @solidity memory-safe-assembly assembly { result := sload(_TOTAL_SUPPLY_SLOT) } } /// @dev Returns the amount of tokens owned by `owner`. function balanceOf(address owner) public view virtual returns (uint256 result) { /// @solidity memory-safe-assembly assembly { mstore(0x0c, _BALANCE_SLOT_SEED) mstore(0x00, owner) result := sload(keccak256(0x0c, 0x20)) } } /// @dev Returns the amount of tokens that `spender` can spend on behalf of `owner`. function allowance(address owner, address spender) public view virtual returns (uint256 result) { if (_givePermit2InfiniteAllowance()) { if (spender == _PERMIT2) return type(uint256).max; } /// @solidity memory-safe-assembly assembly { mstore(0x20, spender) mstore(0x0c, _ALLOWANCE_SLOT_SEED) mstore(0x00, owner) result := sload(keccak256(0x0c, 0x34)) } } /// @dev Sets `amount` as the allowance of `spender` over the caller's tokens. /// /// Emits a {Approval} event. function approve(address spender, uint256 amount) public virtual returns (bool) { if (_givePermit2InfiniteAllowance()) { /// @solidity memory-safe-assembly assembly { // If `spender == _PERMIT2 && amount != type(uint256).max`. if iszero(or(xor(shr(96, shl(96, spender)), _PERMIT2), iszero(not(amount)))) { mstore(0x00, 0x3f68539a) // `Permit2AllowanceIsFixedAtInfinity()`. revert(0x1c, 0x04) } } } /// @solidity memory-safe-assembly assembly { // Compute the allowance slot and store the amount. mstore(0x20, spender) mstore(0x0c, _ALLOWANCE_SLOT_SEED) mstore(0x00, caller()) sstore(keccak256(0x0c, 0x34), amount) // Emit the {Approval} event. mstore(0x00, amount) log3(0x00, 0x20, _APPROVAL_EVENT_SIGNATURE, caller(), shr(96, mload(0x2c))) } return true; } /// @dev Transfer `amount` tokens from the caller to `to`. /// /// Requirements: /// - `from` must at least have `amount`. /// /// Emits a {Transfer} event. function transfer(address to, uint256 amount) public virtual returns (bool) { _beforeTokenTransfer(msg.sender, to, amount); /// @solidity memory-safe-assembly assembly { // Compute the balance slot and load its value. mstore(0x0c, _BALANCE_SLOT_SEED) mstore(0x00, caller()) let fromBalanceSlot := keccak256(0x0c, 0x20) let fromBalance := sload(fromBalanceSlot) // Revert if insufficient balance. if gt(amount, fromBalance) { mstore(0x00, 0xf4d678b8) // `InsufficientBalance()`. revert(0x1c, 0x04) } // Subtract and store the updated balance. sstore(fromBalanceSlot, sub(fromBalance, amount)) // Compute the balance slot of `to`. mstore(0x00, to) let toBalanceSlot := keccak256(0x0c, 0x20) // Add and store the updated balance of `to`. // Will not overflow because the sum of all user balances // cannot exceed the maximum uint256 value. sstore(toBalanceSlot, add(sload(toBalanceSlot), amount)) // Emit the {Transfer} event. mstore(0x20, amount) log3(0x20, 0x20, _TRANSFER_EVENT_SIGNATURE, caller(), shr(96, mload(0x0c))) } _afterTokenTransfer(msg.sender, to, amount); return true; } /// @dev Transfers `amount` tokens from `from` to `to`. /// /// Note: Does not update the allowance if it is the maximum uint256 value. /// /// Requirements: /// - `from` must at least have `amount`. /// - The caller must have at least `amount` of allowance to transfer the tokens of `from`. /// /// Emits a {Transfer} event. function transferFrom(address from, address to, uint256 amount) public virtual returns (bool) { _beforeTokenTransfer(from, to, amount); // Code duplication is for zero-cost abstraction if possible. if (_givePermit2InfiniteAllowance()) { /// @solidity memory-safe-assembly assembly { let from_ := shl(96, from) if iszero(eq(caller(), _PERMIT2)) { // Compute the allowance slot and load its value. mstore(0x20, caller()) mstore(0x0c, or(from_, _ALLOWANCE_SLOT_SEED)) let allowanceSlot := keccak256(0x0c, 0x34) let allowance_ := sload(allowanceSlot) // If the allowance is not the maximum uint256 value. if not(allowance_) { // Revert if the amount to be transferred exceeds the allowance. if gt(amount, allowance_) { mstore(0x00, 0x13be252b) // `InsufficientAllowance()`. revert(0x1c, 0x04) } // Subtract and store the updated allowance. sstore(allowanceSlot, sub(allowance_, amount)) } } // Compute the balance slot and load its value. mstore(0x0c, or(from_, _BALANCE_SLOT_SEED)) let fromBalanceSlot := keccak256(0x0c, 0x20) let fromBalance := sload(fromBalanceSlot) // Revert if insufficient balance. if gt(amount, fromBalance) { mstore(0x00, 0xf4d678b8) // `InsufficientBalance()`. revert(0x1c, 0x04) } // Subtract and store the updated balance. sstore(fromBalanceSlot, sub(fromBalance, amount)) // Compute the balance slot of `to`. mstore(0x00, to) let toBalanceSlot := keccak256(0x0c, 0x20) // Add and store the updated balance of `to`. // Will not overflow because the sum of all user balances // cannot exceed the maximum uint256 value. sstore(toBalanceSlot, add(sload(toBalanceSlot), amount)) // Emit the {Transfer} event. mstore(0x20, amount) log3(0x20, 0x20, _TRANSFER_EVENT_SIGNATURE, shr(96, from_), shr(96, mload(0x0c))) } } else { /// @solidity memory-safe-assembly assembly { let from_ := shl(96, from) // Compute the allowance slot and load its value. mstore(0x20, caller()) mstore(0x0c, or(from_, _ALLOWANCE_SLOT_SEED)) let allowanceSlot := keccak256(0x0c, 0x34) let allowance_ := sload(allowanceSlot) // If the allowance is not the maximum uint256 value. if not(allowance_) { // Revert if the amount to be transferred exceeds the allowance. if gt(amount, allowance_) { mstore(0x00, 0x13be252b) // `InsufficientAllowance()`. revert(0x1c, 0x04) } // Subtract and store the updated allowance. sstore(allowanceSlot, sub(allowance_, amount)) } // Compute the balance slot and load its value. mstore(0x0c, or(from_, _BALANCE_SLOT_SEED)) let fromBalanceSlot := keccak256(0x0c, 0x20) let fromBalance := sload(fromBalanceSlot) // Revert if insufficient balance. if gt(amount, fromBalance) { mstore(0x00, 0xf4d678b8) // `InsufficientBalance()`. revert(0x1c, 0x04) } // Subtract and store the updated balance. sstore(fromBalanceSlot, sub(fromBalance, amount)) // Compute the balance slot of `to`. mstore(0x00, to) let toBalanceSlot := keccak256(0x0c, 0x20) // Add and store the updated balance of `to`. // Will not overflow because the sum of all user balances // cannot exceed the maximum uint256 value. sstore(toBalanceSlot, add(sload(toBalanceSlot), amount)) // Emit the {Transfer} event. mstore(0x20, amount) log3(0x20, 0x20, _TRANSFER_EVENT_SIGNATURE, shr(96, from_), shr(96, mload(0x0c))) } } _afterTokenTransfer(from, to, amount); return true; } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* EIP-2612 */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev For more performance, override to return the constant value /// of `keccak256(bytes(name()))` if `name()` will never change. function _constantNameHash() internal view virtual returns (bytes32 result) {} /// @dev If you need a different value, override this function. function _versionHash() internal view virtual returns (bytes32 result) { result = _DEFAULT_VERSION_HASH; } /// @dev For inheriting contracts to increment the nonce. function _incrementNonce(address owner) internal virtual { /// @solidity memory-safe-assembly assembly { mstore(0x0c, _NONCES_SLOT_SEED) mstore(0x00, owner) let nonceSlot := keccak256(0x0c, 0x20) sstore(nonceSlot, add(1, sload(nonceSlot))) } } /// @dev Returns the current nonce for `owner`. /// This value is used to compute the signature for EIP-2612 permit. function nonces(address owner) public view virtual returns (uint256 result) { /// @solidity memory-safe-assembly assembly { // Compute the nonce slot and load its value. mstore(0x0c, _NONCES_SLOT_SEED) mstore(0x00, owner) result := sload(keccak256(0x0c, 0x20)) } } /// @dev Sets `value` as the allowance of `spender` over the tokens of `owner`, /// authorized by a signed approval by `owner`. /// /// Emits a {Approval} event. function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) public virtual { if (_givePermit2InfiniteAllowance()) { /// @solidity memory-safe-assembly assembly { // If `spender == _PERMIT2 && value != type(uint256).max`. if iszero(or(xor(shr(96, shl(96, spender)), _PERMIT2), iszero(not(value)))) { mstore(0x00, 0x3f68539a) // `Permit2AllowanceIsFixedAtInfinity()`. revert(0x1c, 0x04) } } } bytes32 nameHash = _constantNameHash(); // We simply calculate it on-the-fly to allow for cases where the `name` may change. if (nameHash == bytes32(0)) nameHash = keccak256(bytes(name())); bytes32 versionHash = _versionHash(); /// @solidity memory-safe-assembly assembly { // Revert if the block timestamp is greater than `deadline`. if gt(timestamp(), deadline) { mstore(0x00, 0x1a15a3cc) // `PermitExpired()`. revert(0x1c, 0x04) } let m := mload(0x40) // Grab the free memory pointer. // Clean the upper 96 bits. owner := shr(96, shl(96, owner)) spender := shr(96, shl(96, spender)) // Compute the nonce slot and load its value. mstore(0x0e, _NONCES_SLOT_SEED_WITH_SIGNATURE_PREFIX) mstore(0x00, owner) let nonceSlot := keccak256(0x0c, 0x20) let nonceValue := sload(nonceSlot) // Prepare the domain separator. mstore(m, _DOMAIN_TYPEHASH) mstore(add(m, 0x20), nameHash) mstore(add(m, 0x40), versionHash) mstore(add(m, 0x60), chainid()) mstore(add(m, 0x80), address()) mstore(0x2e, keccak256(m, 0xa0)) // Prepare the struct hash. mstore(m, _PERMIT_TYPEHASH) mstore(add(m, 0x20), owner) mstore(add(m, 0x40), spender) mstore(add(m, 0x60), value) mstore(add(m, 0x80), nonceValue) mstore(add(m, 0xa0), deadline) mstore(0x4e, keccak256(m, 0xc0)) // Prepare the ecrecover calldata. mstore(0x00, keccak256(0x2c, 0x42)) mstore(0x20, and(0xff, v)) mstore(0x40, r) mstore(0x60, s) let t := staticcall(gas(), 1, 0x00, 0x80, 0x20, 0x20) // If the ecrecover fails, the returndatasize will be 0x00, // `owner` will be checked if it equals the hash at 0x00, // which evaluates to false (i.e. 0), and we will revert. // If the ecrecover succeeds, the returndatasize will be 0x20, // `owner` will be compared against the returned address at 0x20. if iszero(eq(mload(returndatasize()), owner)) { mstore(0x00, 0xddafbaef) // `InvalidPermit()`. revert(0x1c, 0x04) } // Increment and store the updated nonce. sstore(nonceSlot, add(nonceValue, t)) // `t` is 1 if ecrecover succeeds. // Compute the allowance slot and store the value. // The `owner` is already at slot 0x20. mstore(0x40, or(shl(160, _ALLOWANCE_SLOT_SEED), spender)) sstore(keccak256(0x2c, 0x34), value) // Emit the {Approval} event. log3(add(m, 0x60), 0x20, _APPROVAL_EVENT_SIGNATURE, owner, spender) mstore(0x40, m) // Restore the free memory pointer. mstore(0x60, 0) // Restore the zero pointer. } } /// @dev Returns the EIP-712 domain separator for the EIP-2612 permit. function DOMAIN_SEPARATOR() public view virtual returns (bytes32 result) { bytes32 nameHash = _constantNameHash(); // We simply calculate it on-the-fly to allow for cases where the `name` may change. if (nameHash == bytes32(0)) nameHash = keccak256(bytes(name())); bytes32 versionHash = _versionHash(); /// @solidity memory-safe-assembly assembly { let m := mload(0x40) // Grab the free memory pointer. mstore(m, _DOMAIN_TYPEHASH) mstore(add(m, 0x20), nameHash) mstore(add(m, 0x40), versionHash) mstore(add(m, 0x60), chainid()) mstore(add(m, 0x80), address()) result := keccak256(m, 0xa0) } } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* INTERNAL MINT FUNCTIONS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Mints `amount` tokens to `to`, increasing the total supply. /// /// Emits a {Transfer} event. function _mint(address to, uint256 amount) internal virtual { _beforeTokenTransfer(address(0), to, amount); /// @solidity memory-safe-assembly assembly { let totalSupplyBefore := sload(_TOTAL_SUPPLY_SLOT) let totalSupplyAfter := add(totalSupplyBefore, amount) // Revert if the total supply overflows. if lt(totalSupplyAfter, totalSupplyBefore) { mstore(0x00, 0xe5cfe957) // `TotalSupplyOverflow()`. revert(0x1c, 0x04) } // Store the updated total supply. sstore(_TOTAL_SUPPLY_SLOT, totalSupplyAfter) // Compute the balance slot and load its value. mstore(0x0c, _BALANCE_SLOT_SEED) mstore(0x00, to) let toBalanceSlot := keccak256(0x0c, 0x20) // Add and store the updated balance. sstore(toBalanceSlot, add(sload(toBalanceSlot), amount)) // Emit the {Transfer} event. mstore(0x20, amount) log3(0x20, 0x20, _TRANSFER_EVENT_SIGNATURE, 0, shr(96, mload(0x0c))) } _afterTokenTransfer(address(0), to, amount); } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* INTERNAL BURN FUNCTIONS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Burns `amount` tokens from `from`, reducing the total supply. /// /// Emits a {Transfer} event. function _burn(address from, uint256 amount) internal virtual { _beforeTokenTransfer(from, address(0), amount); /// @solidity memory-safe-assembly assembly { // Compute the balance slot and load its value. mstore(0x0c, _BALANCE_SLOT_SEED) mstore(0x00, from) let fromBalanceSlot := keccak256(0x0c, 0x20) let fromBalance := sload(fromBalanceSlot) // Revert if insufficient balance. if gt(amount, fromBalance) { mstore(0x00, 0xf4d678b8) // `InsufficientBalance()`. revert(0x1c, 0x04) } // Subtract and store the updated balance. sstore(fromBalanceSlot, sub(fromBalance, amount)) // Subtract and store the updated total supply. sstore(_TOTAL_SUPPLY_SLOT, sub(sload(_TOTAL_SUPPLY_SLOT), amount)) // Emit the {Transfer} event. mstore(0x00, amount) log3(0x00, 0x20, _TRANSFER_EVENT_SIGNATURE, shr(96, shl(96, from)), 0) } _afterTokenTransfer(from, address(0), amount); } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* INTERNAL TRANSFER FUNCTIONS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Moves `amount` of tokens from `from` to `to`. function _transfer(address from, address to, uint256 amount) internal virtual { _beforeTokenTransfer(from, to, amount); /// @solidity memory-safe-assembly assembly { let from_ := shl(96, from) // Compute the balance slot and load its value. mstore(0x0c, or(from_, _BALANCE_SLOT_SEED)) let fromBalanceSlot := keccak256(0x0c, 0x20) let fromBalance := sload(fromBalanceSlot) // Revert if insufficient balance. if gt(amount, fromBalance) { mstore(0x00, 0xf4d678b8) // `InsufficientBalance()`. revert(0x1c, 0x04) } // Subtract and store the updated balance. sstore(fromBalanceSlot, sub(fromBalance, amount)) // Compute the balance slot of `to`. mstore(0x00, to) let toBalanceSlot := keccak256(0x0c, 0x20) // Add and store the updated balance of `to`. // Will not overflow because the sum of all user balances // cannot exceed the maximum uint256 value. sstore(toBalanceSlot, add(sload(toBalanceSlot), amount)) // Emit the {Transfer} event. mstore(0x20, amount) log3(0x20, 0x20, _TRANSFER_EVENT_SIGNATURE, shr(96, from_), shr(96, mload(0x0c))) } _afterTokenTransfer(from, to, amount); } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* INTERNAL ALLOWANCE FUNCTIONS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Updates the allowance of `owner` for `spender` based on spent `amount`. function _spendAllowance(address owner, address spender, uint256 amount) internal virtual { if (_givePermit2InfiniteAllowance()) { if (spender == _PERMIT2) return; // Do nothing, as allowance is infinite. } /// @solidity memory-safe-assembly assembly { // Compute the allowance slot and load its value. mstore(0x20, spender) mstore(0x0c, _ALLOWANCE_SLOT_SEED) mstore(0x00, owner) let allowanceSlot := keccak256(0x0c, 0x34) let allowance_ := sload(allowanceSlot) // If the allowance is not the maximum uint256 value. if not(allowance_) { // Revert if the amount to be transferred exceeds the allowance. if gt(amount, allowance_) { mstore(0x00, 0x13be252b) // `InsufficientAllowance()`. revert(0x1c, 0x04) } // Subtract and store the updated allowance. sstore(allowanceSlot, sub(allowance_, amount)) } } } /// @dev Sets `amount` as the allowance of `spender` over the tokens of `owner`. /// /// Emits a {Approval} event. function _approve(address owner, address spender, uint256 amount) internal virtual { if (_givePermit2InfiniteAllowance()) { /// @solidity memory-safe-assembly assembly { // If `spender == _PERMIT2 && amount != type(uint256).max`. if iszero(or(xor(shr(96, shl(96, spender)), _PERMIT2), iszero(not(amount)))) { mstore(0x00, 0x3f68539a) // `Permit2AllowanceIsFixedAtInfinity()`. revert(0x1c, 0x04) } } } /// @solidity memory-safe-assembly assembly { let owner_ := shl(96, owner) // Compute the allowance slot and store the amount. mstore(0x20, spender) mstore(0x0c, or(owner_, _ALLOWANCE_SLOT_SEED)) sstore(keccak256(0x0c, 0x34), amount) // Emit the {Approval} event. mstore(0x00, amount) log3(0x00, 0x20, _APPROVAL_EVENT_SIGNATURE, shr(96, owner_), shr(96, mload(0x2c))) } } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* HOOKS TO OVERRIDE */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Hook that is called before any transfer of tokens. /// This includes minting and burning. function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual {} /// @dev Hook that is called after any transfer of tokens. /// This includes minting and burning. function _afterTokenTransfer(address from, address to, uint256 amount) internal virtual {} /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* PERMIT2 */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Returns whether to fix the Permit2 contract's allowance at infinity. /// /// This value should be kept constant after contract initialization, /// or else the actual allowance values may not match with the {Approval} events. /// For best performance, return a compile-time constant for zero-cost abstraction. function _givePermit2InfiniteAllowance() internal view virtual returns (bool) { return false; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; /// @notice Safe ETH and ERC20 transfer library that gracefully handles missing return values. /// @author Solady (https://github.com/vectorized/solady/blob/main/src/utils/SafeTransferLib.sol) /// @author Modified from Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/SafeTransferLib.sol) /// @author Permit2 operations from (https://github.com/Uniswap/permit2/blob/main/src/libraries/Permit2Lib.sol) /// /// @dev Note: /// - For ETH transfers, please use `forceSafeTransferETH` for DoS protection. library SafeTransferLib { /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* CUSTOM ERRORS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev The ETH transfer has failed. error ETHTransferFailed(); /// @dev The ERC20 `transferFrom` has failed. error TransferFromFailed(); /// @dev The ERC20 `transfer` has failed. error TransferFailed(); /// @dev The ERC20 `approve` has failed. error ApproveFailed(); /// @dev The ERC20 `totalSupply` query has failed. error TotalSupplyQueryFailed(); /// @dev The Permit2 operation has failed. error Permit2Failed(); /// @dev The Permit2 amount must be less than `2**160 - 1`. error Permit2AmountOverflow(); /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* CONSTANTS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Suggested gas stipend for contract receiving ETH that disallows any storage writes. uint256 internal constant GAS_STIPEND_NO_STORAGE_WRITES = 2300; /// @dev Suggested gas stipend for contract receiving ETH to perform a few /// storage reads and writes, but low enough to prevent griefing. uint256 internal constant GAS_STIPEND_NO_GRIEF = 100000; /// @dev The unique EIP-712 domain domain separator for the DAI token contract. bytes32 internal constant DAI_DOMAIN_SEPARATOR = 0xdbb8cf42e1ecb028be3f3dbc922e1d878b963f411dc388ced501601c60f7c6f7; /// @dev The address for the WETH9 contract on Ethereum mainnet. address internal constant WETH9 = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; /// @dev The canonical Permit2 address. /// [Github](https://github.com/Uniswap/permit2) /// [Etherscan](https://etherscan.io/address/0x000000000022D473030F116dDEE9F6B43aC78BA3) address internal constant PERMIT2 = 0x000000000022D473030F116dDEE9F6B43aC78BA3; /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* ETH OPERATIONS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ // If the ETH transfer MUST succeed with a reasonable gas budget, use the force variants. // // The regular variants: // - Forwards all remaining gas to the target. // - Reverts if the target reverts. // - Reverts if the current contract has insufficient balance. // // The force variants: // - Forwards with an optional gas stipend // (defaults to `GAS_STIPEND_NO_GRIEF`, which is sufficient for most cases). // - If the target reverts, or if the gas stipend is exhausted, // creates a temporary contract to force send the ETH via `SELFDESTRUCT`. // Future compatible with `SENDALL`: https://eips.ethereum.org/EIPS/eip-4758. // - Reverts if the current contract has insufficient balance. // // The try variants: // - Forwards with a mandatory gas stipend. // - Instead of reverting, returns whether the transfer succeeded. /// @dev Sends `amount` (in wei) ETH to `to`. function safeTransferETH(address to, uint256 amount) internal { /// @solidity memory-safe-assembly assembly { if iszero(call(gas(), to, amount, codesize(), 0x00, codesize(), 0x00)) { mstore(0x00, 0xb12d13eb) // `ETHTransferFailed()`. revert(0x1c, 0x04) } } } /// @dev Sends all the ETH in the current contract to `to`. function safeTransferAllETH(address to) internal { /// @solidity memory-safe-assembly assembly { // Transfer all the ETH and check if it succeeded or not. if iszero(call(gas(), to, selfbalance(), codesize(), 0x00, codesize(), 0x00)) { mstore(0x00, 0xb12d13eb) // `ETHTransferFailed()`. revert(0x1c, 0x04) } } } /// @dev Force sends `amount` (in wei) ETH to `to`, with a `gasStipend`. function forceSafeTransferETH(address to, uint256 amount, uint256 gasStipend) internal { /// @solidity memory-safe-assembly assembly { if lt(selfbalance(), amount) { mstore(0x00, 0xb12d13eb) // `ETHTransferFailed()`. revert(0x1c, 0x04) } if iszero(call(gasStipend, to, amount, codesize(), 0x00, codesize(), 0x00)) { mstore(0x00, to) // Store the address in scratch space. mstore8(0x0b, 0x73) // Opcode `PUSH20`. mstore8(0x20, 0xff) // Opcode `SELFDESTRUCT`. if iszero(create(amount, 0x0b, 0x16)) { revert(codesize(), codesize()) } // For gas estimation. } } } /// @dev Force sends all the ETH in the current contract to `to`, with a `gasStipend`. function forceSafeTransferAllETH(address to, uint256 gasStipend) internal { /// @solidity memory-safe-assembly assembly { if iszero(call(gasStipend, to, selfbalance(), codesize(), 0x00, codesize(), 0x00)) { mstore(0x00, to) // Store the address in scratch space. mstore8(0x0b, 0x73) // Opcode `PUSH20`. mstore8(0x20, 0xff) // Opcode `SELFDESTRUCT`. if iszero(create(selfbalance(), 0x0b, 0x16)) { revert(codesize(), codesize()) } // For gas estimation. } } } /// @dev Force sends `amount` (in wei) ETH to `to`, with `GAS_STIPEND_NO_GRIEF`. function forceSafeTransferETH(address to, uint256 amount) internal { /// @solidity memory-safe-assembly assembly { if lt(selfbalance(), amount) { mstore(0x00, 0xb12d13eb) // `ETHTransferFailed()`. revert(0x1c, 0x04) } if iszero(call(GAS_STIPEND_NO_GRIEF, to, amount, codesize(), 0x00, codesize(), 0x00)) { mstore(0x00, to) // Store the address in scratch space. mstore8(0x0b, 0x73) // Opcode `PUSH20`. mstore8(0x20, 0xff) // Opcode `SELFDESTRUCT`. if iszero(create(amount, 0x0b, 0x16)) { revert(codesize(), codesize()) } // For gas estimation. } } } /// @dev Force sends all the ETH in the current contract to `to`, with `GAS_STIPEND_NO_GRIEF`. function forceSafeTransferAllETH(address to) internal { /// @solidity memory-safe-assembly assembly { // forgefmt: disable-next-item if iszero(call(GAS_STIPEND_NO_GRIEF, to, selfbalance(), codesize(), 0x00, codesize(), 0x00)) { mstore(0x00, to) // Store the address in scratch space. mstore8(0x0b, 0x73) // Opcode `PUSH20`. mstore8(0x20, 0xff) // Opcode `SELFDESTRUCT`. if iszero(create(selfbalance(), 0x0b, 0x16)) { revert(codesize(), codesize()) } // For gas estimation. } } } /// @dev Sends `amount` (in wei) ETH to `to`, with a `gasStipend`. function trySafeTransferETH(address to, uint256 amount, uint256 gasStipend) internal returns (bool success) { /// @solidity memory-safe-assembly assembly { success := call(gasStipend, to, amount, codesize(), 0x00, codesize(), 0x00) } } /// @dev Sends all the ETH in the current contract to `to`, with a `gasStipend`. function trySafeTransferAllETH(address to, uint256 gasStipend) internal returns (bool success) { /// @solidity memory-safe-assembly assembly { success := call(gasStipend, to, selfbalance(), codesize(), 0x00, codesize(), 0x00) } } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* ERC20 OPERATIONS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Sends `amount` of ERC20 `token` from `from` to `to`. /// Reverts upon failure. /// /// The `from` account must have at least `amount` approved for /// the current contract to manage. function safeTransferFrom(address token, address from, address to, uint256 amount) internal { /// @solidity memory-safe-assembly assembly { let m := mload(0x40) // Cache the free memory pointer. mstore(0x60, amount) // Store the `amount` argument. mstore(0x40, to) // Store the `to` argument. mstore(0x2c, shl(96, from)) // Store the `from` argument. mstore(0x0c, 0x23b872dd000000000000000000000000) // `transferFrom(address,address,uint256)`. let success := call(gas(), token, 0, 0x1c, 0x64, 0x00, 0x20) if iszero(and(eq(mload(0x00), 1), success)) { if iszero(lt(or(iszero(extcodesize(token)), returndatasize()), success)) { mstore(0x00, 0x7939f424) // `TransferFromFailed()`. revert(0x1c, 0x04) } } mstore(0x60, 0) // Restore the zero slot to zero. mstore(0x40, m) // Restore the free memory pointer. } } /// @dev Sends `amount` of ERC20 `token` from `from` to `to`. /// /// The `from` account must have at least `amount` approved for the current contract to manage. function trySafeTransferFrom(address token, address from, address to, uint256 amount) internal returns (bool success) { /// @solidity memory-safe-assembly assembly { let m := mload(0x40) // Cache the free memory pointer. mstore(0x60, amount) // Store the `amount` argument. mstore(0x40, to) // Store the `to` argument. mstore(0x2c, shl(96, from)) // Store the `from` argument. mstore(0x0c, 0x23b872dd000000000000000000000000) // `transferFrom(address,address,uint256)`. success := call(gas(), token, 0, 0x1c, 0x64, 0x00, 0x20) if iszero(and(eq(mload(0x00), 1), success)) { success := lt(or(iszero(extcodesize(token)), returndatasize()), success) } mstore(0x60, 0) // Restore the zero slot to zero. mstore(0x40, m) // Restore the free memory pointer. } } /// @dev Sends all of ERC20 `token` from `from` to `to`. /// Reverts upon failure. /// /// The `from` account must have their entire balance approved for the current contract to manage. function safeTransferAllFrom(address token, address from, address to) internal returns (uint256 amount) { /// @solidity memory-safe-assembly assembly { let m := mload(0x40) // Cache the free memory pointer. mstore(0x40, to) // Store the `to` argument. mstore(0x2c, shl(96, from)) // Store the `from` argument. mstore(0x0c, 0x70a08231000000000000000000000000) // `balanceOf(address)`. // Read the balance, reverting upon failure. if iszero( and( // The arguments of `and` are evaluated from right to left. gt(returndatasize(), 0x1f), // At least 32 bytes returned. staticcall(gas(), token, 0x1c, 0x24, 0x60, 0x20) ) ) { mstore(0x00, 0x7939f424) // `TransferFromFailed()`. revert(0x1c, 0x04) } mstore(0x00, 0x23b872dd) // `transferFrom(address,address,uint256)`. amount := mload(0x60) // The `amount` is already at 0x60. We'll need to return it. // Perform the transfer, reverting upon failure. let success := call(gas(), token, 0, 0x1c, 0x64, 0x00, 0x20) if iszero(and(eq(mload(0x00), 1), success)) { if iszero(lt(or(iszero(extcodesize(token)), returndatasize()), success)) { mstore(0x00, 0x7939f424) // `TransferFromFailed()`. revert(0x1c, 0x04) } } mstore(0x60, 0) // Restore the zero slot to zero. mstore(0x40, m) // Restore the free memory pointer. } } /// @dev Sends `amount` of ERC20 `token` from the current contract to `to`. /// Reverts upon failure. function safeTransfer(address token, address to, uint256 amount) internal { /// @solidity memory-safe-assembly assembly { mstore(0x14, to) // Store the `to` argument. mstore(0x34, amount) // Store the `amount` argument. mstore(0x00, 0xa9059cbb000000000000000000000000) // `transfer(address,uint256)`. // Perform the transfer, reverting upon failure. let success := call(gas(), token, 0, 0x10, 0x44, 0x00, 0x20) if iszero(and(eq(mload(0x00), 1), success)) { if iszero(lt(or(iszero(extcodesize(token)), returndatasize()), success)) { mstore(0x00, 0x90b8ec18) // `TransferFailed()`. revert(0x1c, 0x04) } } mstore(0x34, 0) // Restore the part of the free memory pointer that was overwritten. } } /// @dev Sends all of ERC20 `token` from the current contract to `to`. /// Reverts upon failure. function safeTransferAll(address token, address to) internal returns (uint256 amount) { /// @solidity memory-safe-assembly assembly { mstore(0x00, 0x70a08231) // Store the function selector of `balanceOf(address)`. mstore(0x20, address()) // Store the address of the current contract. // Read the balance, reverting upon failure. if iszero( and( // The arguments of `and` are evaluated from right to left. gt(returndatasize(), 0x1f), // At least 32 bytes returned. staticcall(gas(), token, 0x1c, 0x24, 0x34, 0x20) ) ) { mstore(0x00, 0x90b8ec18) // `TransferFailed()`. revert(0x1c, 0x04) } mstore(0x14, to) // Store the `to` argument. amount := mload(0x34) // The `amount` is already at 0x34. We'll need to return it. mstore(0x00, 0xa9059cbb000000000000000000000000) // `transfer(address,uint256)`. // Perform the transfer, reverting upon failure. let success := call(gas(), token, 0, 0x10, 0x44, 0x00, 0x20) if iszero(and(eq(mload(0x00), 1), success)) { if iszero(lt(or(iszero(extcodesize(token)), returndatasize()), success)) { mstore(0x00, 0x90b8ec18) // `TransferFailed()`. revert(0x1c, 0x04) } } mstore(0x34, 0) // Restore the part of the free memory pointer that was overwritten. } } /// @dev Sets `amount` of ERC20 `token` for `to` to manage on behalf of the current contract. /// Reverts upon failure. function safeApprove(address token, address to, uint256 amount) internal { /// @solidity memory-safe-assembly assembly { mstore(0x14, to) // Store the `to` argument. mstore(0x34, amount) // Store the `amount` argument. mstore(0x00, 0x095ea7b3000000000000000000000000) // `approve(address,uint256)`. let success := call(gas(), token, 0, 0x10, 0x44, 0x00, 0x20) if iszero(and(eq(mload(0x00), 1), success)) { if iszero(lt(or(iszero(extcodesize(token)), returndatasize()), success)) { mstore(0x00, 0x3e3f8f73) // `ApproveFailed()`. revert(0x1c, 0x04) } } mstore(0x34, 0) // Restore the part of the free memory pointer that was overwritten. } } /// @dev Sets `amount` of ERC20 `token` for `to` to manage on behalf of the current contract. /// If the initial attempt to approve fails, attempts to reset the approved amount to zero, /// then retries the approval again (some tokens, e.g. USDT, requires this). /// Reverts upon failure. function safeApproveWithRetry(address token, address to, uint256 amount) internal { /// @solidity memory-safe-assembly assembly { mstore(0x14, to) // Store the `to` argument. mstore(0x34, amount) // Store the `amount` argument. mstore(0x00, 0x095ea7b3000000000000000000000000) // `approve(address,uint256)`. // Perform the approval, retrying upon failure. let success := call(gas(), token, 0, 0x10, 0x44, 0x00, 0x20) if iszero(and(eq(mload(0x00), 1), success)) { if iszero(lt(or(iszero(extcodesize(token)), returndatasize()), success)) { mstore(0x34, 0) // Store 0 for the `amount`. mstore(0x00, 0x095ea7b3000000000000000000000000) // `approve(address,uint256)`. pop(call(gas(), token, 0, 0x10, 0x44, codesize(), 0x00)) // Reset the approval. mstore(0x34, amount) // Store back the original `amount`. // Retry the approval, reverting upon failure. success := call(gas(), token, 0, 0x10, 0x44, 0x00, 0x20) if iszero(and(eq(mload(0x00), 1), success)) { // Check the `extcodesize` again just in case the token selfdestructs lol. if iszero(lt(or(iszero(extcodesize(token)), returndatasize()), success)) { mstore(0x00, 0x3e3f8f73) // `ApproveFailed()`. revert(0x1c, 0x04) } } } } mstore(0x34, 0) // Restore the part of the free memory pointer that was overwritten. } } /// @dev Returns the amount of ERC20 `token` owned by `account`. /// Returns zero if the `token` does not exist. function balanceOf(address token, address account) internal view returns (uint256 amount) { /// @solidity memory-safe-assembly assembly { mstore(0x14, account) // Store the `account` argument. mstore(0x00, 0x70a08231000000000000000000000000) // `balanceOf(address)`. amount := mul( // The arguments of `mul` are evaluated from right to left. mload(0x20), and( // The arguments of `and` are evaluated from right to left. gt(returndatasize(), 0x1f), // At least 32 bytes returned. staticcall(gas(), token, 0x10, 0x24, 0x20, 0x20) ) ) } } /// @dev Returns the total supply of the `token`. /// Reverts if the token does not exist or does not implement `totalSupply()`. function totalSupply(address token) internal view returns (uint256 result) { /// @solidity memory-safe-assembly assembly { mstore(0x00, 0x18160ddd) // `totalSupply()`. if iszero( and(gt(returndatasize(), 0x1f), staticcall(gas(), token, 0x1c, 0x04, 0x00, 0x20)) ) { mstore(0x00, 0x54cd9435) // `TotalSupplyQueryFailed()`. revert(0x1c, 0x04) } result := mload(0x00) } } /// @dev Sends `amount` of ERC20 `token` from `from` to `to`. /// If the initial attempt fails, try to use Permit2 to transfer the token. /// Reverts upon failure. /// /// The `from` account must have at least `amount` approved for the current contract to manage. function safeTransferFrom2(address token, address from, address to, uint256 amount) internal { if (!trySafeTransferFrom(token, from, to, amount)) { permit2TransferFrom(token, from, to, amount); } } /// @dev Sends `amount` of ERC20 `token` from `from` to `to` via Permit2. /// Reverts upon failure. function permit2TransferFrom(address token, address from, address to, uint256 amount) internal { /// @solidity memory-safe-assembly assembly { let m := mload(0x40) mstore(add(m, 0x74), shr(96, shl(96, token))) mstore(add(m, 0x54), amount) mstore(add(m, 0x34), to) mstore(add(m, 0x20), shl(96, from)) // `transferFrom(address,address,uint160,address)`. mstore(m, 0x36c78516000000000000000000000000) let p := PERMIT2 let exists := eq(chainid(), 1) if iszero(exists) { exists := iszero(iszero(extcodesize(p))) } if iszero( and( call(gas(), p, 0, add(m, 0x10), 0x84, codesize(), 0x00), lt(iszero(extcodesize(token)), exists) // Token has code and Permit2 exists. ) ) { mstore(0x00, 0x7939f4248757f0fd) // `TransferFromFailed()` or `Permit2AmountOverflow()`. revert(add(0x18, shl(2, iszero(iszero(shr(160, amount))))), 0x04) } } } /// @dev Permit a user to spend a given amount of /// another user's tokens via native EIP-2612 permit if possible, falling /// back to Permit2 if native permit fails or is not implemented on the token. function permit2( address token, address owner, address spender, uint256 amount, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) internal { bool success; /// @solidity memory-safe-assembly assembly { for {} shl(96, xor(token, WETH9)) {} { mstore(0x00, 0x3644e515) // `DOMAIN_SEPARATOR()`. if iszero( and( // The arguments of `and` are evaluated from right to left. lt(iszero(mload(0x00)), eq(returndatasize(), 0x20)), // Returns 1 non-zero word. // Gas stipend to limit gas burn for tokens that don't refund gas when // an non-existing function is called. 5K should be enough for a SLOAD. staticcall(5000, token, 0x1c, 0x04, 0x00, 0x20) ) ) { break } // After here, we can be sure that token is a contract. let m := mload(0x40) mstore(add(m, 0x34), spender) mstore(add(m, 0x20), shl(96, owner)) mstore(add(m, 0x74), deadline) if eq(mload(0x00), DAI_DOMAIN_SEPARATOR) { mstore(0x14, owner) mstore(0x00, 0x7ecebe00000000000000000000000000) // `nonces(address)`. mstore(add(m, 0x94), staticcall(gas(), token, 0x10, 0x24, add(m, 0x54), 0x20)) mstore(m, 0x8fcbaf0c000000000000000000000000) // `IDAIPermit.permit`. // `nonces` is already at `add(m, 0x54)`. // `1` is already stored at `add(m, 0x94)`. mstore(add(m, 0xb4), and(0xff, v)) mstore(add(m, 0xd4), r) mstore(add(m, 0xf4), s) success := call(gas(), token, 0, add(m, 0x10), 0x104, codesize(), 0x00) break } mstore(m, 0xd505accf000000000000000000000000) // `IERC20Permit.permit`. mstore(add(m, 0x54), amount) mstore(add(m, 0x94), and(0xff, v)) mstore(add(m, 0xb4), r) mstore(add(m, 0xd4), s) success := call(gas(), token, 0, add(m, 0x10), 0xe4, codesize(), 0x00) break } } if (!success) simplePermit2(token, owner, spender, amount, deadline, v, r, s); } /// @dev Simple permit on the Permit2 contract. function simplePermit2( address token, address owner, address spender, uint256 amount, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) internal { /// @solidity memory-safe-assembly assembly { let m := mload(0x40) mstore(m, 0x927da105) // `allowance(address,address,address)`. { let addressMask := shr(96, not(0)) mstore(add(m, 0x20), and(addressMask, owner)) mstore(add(m, 0x40), and(addressMask, token)) mstore(add(m, 0x60), and(addressMask, spender)) mstore(add(m, 0xc0), and(addressMask, spender)) } let p := mul(PERMIT2, iszero(shr(160, amount))) if iszero( and( // The arguments of `and` are evaluated from right to left. gt(returndatasize(), 0x5f), // Returns 3 words: `amount`, `expiration`, `nonce`. staticcall(gas(), p, add(m, 0x1c), 0x64, add(m, 0x60), 0x60) ) ) { mstore(0x00, 0x6b836e6b8757f0fd) // `Permit2Failed()` or `Permit2AmountOverflow()`. revert(add(0x18, shl(2, iszero(p))), 0x04) } mstore(m, 0x2b67b570) // `Permit2.permit` (PermitSingle variant). // `owner` is already `add(m, 0x20)`. // `token` is already at `add(m, 0x40)`. mstore(add(m, 0x60), amount) mstore(add(m, 0x80), 0xffffffffffff) // `expiration = type(uint48).max`. // `nonce` is already at `add(m, 0xa0)`. // `spender` is already at `add(m, 0xc0)`. mstore(add(m, 0xe0), deadline) mstore(add(m, 0x100), 0x100) // `signature` offset. mstore(add(m, 0x120), 0x41) // `signature` length. mstore(add(m, 0x140), r) mstore(add(m, 0x160), s) mstore(add(m, 0x180), shl(248, v)) if iszero( // Revert if token does not have code, or if the call fails. mul(extcodesize(token), call(gas(), p, 0, add(m, 0x1c), 0x184, codesize(), 0x00))) { mstore(0x00, 0x6b836e6b) // `Permit2Failed()`. revert(0x1c, 0x04) } } } }
{ "evmVersion": "paris", "optimizer": { "enabled": true, "runs": 1, "details": { "yul": true, "yulDetails": { "stackAllocation": true } } }, "viaIR": false, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "metadata": { "useLiteralContent": true } }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"uint8","name":"tokenDecimals","type":"uint8"},{"internalType":"address","name":"initialOwner","type":"address"},{"internalType":"address","name":"socket","type":"address"},{"internalType":"string","name":"tokenName","type":"string"},{"internalType":"string","name":"tokenSymbol","type":"string"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AllowanceOverflow","type":"error"},{"inputs":[],"name":"AllowanceUnderflow","type":"error"},{"inputs":[],"name":"AlreadyInitialized","type":"error"},{"inputs":[],"name":"InsufficientAllowance","type":"error"},{"inputs":[],"name":"InsufficientBalance","type":"error"},{"inputs":[],"name":"InvalidPermit","type":"error"},{"inputs":[],"name":"InvalidTokenAddress","type":"error"},{"inputs":[],"name":"NewOwnerIsZeroAddress","type":"error"},{"inputs":[],"name":"NoHandoverRequest","type":"error"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"NoPermit","type":"error"},{"inputs":[],"name":"NotSocket","type":"error"},{"inputs":[],"name":"Permit2AllowanceIsFixedAtInfinity","type":"error"},{"inputs":[],"name":"PermitExpired","type":"error"},{"inputs":[],"name":"SocketAlreadyInitialized","type":"error"},{"inputs":[],"name":"TotalSupplyOverflow","type":"error"},{"inputs":[],"name":"Unauthorized","type":"error"},{"inputs":[],"name":"ZeroAddress","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":"amount","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[],"name":"ConnectorPlugDisconnected","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"pendingOwner","type":"address"}],"name":"OwnershipHandoverCanceled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"pendingOwner","type":"address"}],"name":"OwnershipHandoverRequested","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"oldOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"grantee","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"revokee","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":"amount","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"data","type":"bytes"}],"name":"TokensBurned","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"TokensMinted","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":"amount","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[],"name":"DOMAIN_SEPARATOR","outputs":[{"internalType":"bytes32","name":"result","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"result","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"appGatewayId","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"result","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"receiver_","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"data_","type":"bytes"}],"name":"burn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"cancelOwnershipHandover","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"pendingOwner","type":"address"}],"name":"completeOwnershipHandover","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"appGatewayId_","type":"bytes32"},{"internalType":"address","name":"socket_","type":"address"},{"internalType":"uint64","name":"switchboardId_","type":"uint64"}],"name":"connectSocket","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"disconnectSocket","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role_","type":"bytes32"},{"internalType":"address","name":"grantee_","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role_","type":"bytes32"},{"internalType":"address","name":"address_","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"appGatewayId_","type":"bytes32"},{"internalType":"address","name":"socket_","type":"address"},{"internalType":"uint64","name":"switchboardId_","type":"uint64"}],"name":"initSocket","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"isSocketInitialized","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"mint","outputs":[],"stateMutability":"nonpayable","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":"result","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"overrides","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"result","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"pendingOwner","type":"address"}],"name":"ownershipHandoverExpiresAt","outputs":[{"internalType":"uint256","name":"result","type":"uint256"}],"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":[],"name":"renounceOwnership","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"requestOwnershipHandover","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"token_","type":"address"},{"internalType":"address","name":"rescueTo_","type":"address"},{"internalType":"uint256","name":"amount_","type":"uint256"}],"name":"rescueFunds","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role_","type":"bytes32"},{"internalType":"address","name":"revokee_","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"socket__","outputs":[{"internalType":"contract ISocket","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"result","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","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":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"payable","type":"function"}]
Contract Creation Code
60806040523480156200001157600080fd5b5060405162001b3438038062001b348339810160408190526200003491620001b8565b60016034556038805460ff191660ff87161790556036620000568382620002f3565b506037620000658282620002f3565b50603280546001600160a01b0319166001600160a01b0385161790556200008c8462000097565b5050505050620003bf565b6001600160a01b0316638b78c6d8198190558060007f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08180a350565b80516001600160a01b0381168114620000eb57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b600082601f8301126200011857600080fd5b81516001600160401b0380821115620001355762000135620000f0565b604051601f8301601f19908116603f01168101908282118183101715620001605762000160620000f0565b81604052838152602092508660208588010111156200017e57600080fd5b600091505b83821015620001a2578582018301518183018401529082019062000183565b6000602085830101528094505050505092915050565b600080600080600060a08688031215620001d157600080fd5b855160ff81168114620001e357600080fd5b9450620001f360208701620000d3565b93506200020360408701620000d3565b60608701519093506001600160401b03808211156200022157600080fd5b6200022f89838a0162000106565b935060808801519150808211156200024657600080fd5b50620002558882890162000106565b9150509295509295909350565b600181811c908216806200027757607f821691505b6020821081036200029857634e487b7160e01b600052602260045260246000fd5b50919050565b601f821115620002ee576000816000526020600020601f850160051c81016020861015620002c95750805b601f850160051c820191505b81811015620002ea57828155600101620002d5565b5050505b505050565b81516001600160401b038111156200030f576200030f620000f0565b620003278162000320845462000262565b846200029e565b602080601f8311600181146200035f5760008415620003465750858301515b600019600386901b1c1916600185901b178555620002ea565b600085815260208120601f198616915b8281101562000390578886015182559484019460019091019084016200036f565b5085821015620003af5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b61176580620003cf6000396000f3fe6080604052600436106101735760003560e01c806306fdde0314610178578063095ea7b3146101a357806318160ddd146101d357806318b7ff72146101fa5780631c335f491461021c57806323b872dd1461023257806325692962146102525780632f2ff15d1461025a578063313ce5671461027a5780633644e5151461029c57806340c10f19146102b157806344d17187146102d15780634a85f041146102f157806354d1f13d146103065780636ccae0541461030e57806370a082311461032e578063715018a61461034e5780637ecebe00146103565780638da5cb5b1461038957806391d14854146103b6578063943103c3146103d657806395d89b41146103f65780639a7d9a9b1461040b578063a9059cbb14610421578063c6a261d214610441578063d505accf14610461578063d547741f14610481578063dd62ed3e146104a1578063e90e5cc1146104d7578063f04e283e146104ec578063f2fde38b146104ff578063fee81cf414610512575b600080fd5b34801561018457600080fd5b5061018d610545565b60405161019a919061134e565b60405180910390f35b3480156101af57600080fd5b506101c36101be36600461137d565b6105d7565b604051901515815260200161019a565b3480156101df57600080fd5b506805345cdf77eb68f44c545b60405190815260200161019a565b34801561020657600080fd5b5061021a6102153660046113a7565b610618565b005b34801561022857600080fd5b506101ec60335481565b34801561023e57600080fd5b506101c361024d3660046113f3565b61064f565b61021a610664565b34801561026657600080fd5b5061021a61027536600461142f565b6106b3565b34801561028657600080fd5b5060385460405160ff909116815260200161019a565b3480156102a857600080fd5b506101ec6106c9565b3480156102bd57600080fd5b5061021a6102cc36600461137d565b61071d565b3480156102dd57600080fd5b5061021a6102ec366004611471565b610812565b3480156102fd57600080fd5b5061018d610943565b61021a6109d1565b34801561031a57600080fd5b5061021a6103293660046113f3565b610a0d565b34801561033a57600080fd5b506101ec61034936600461153b565b610a92565b61021a610aaa565b34801561036257600080fd5b506101ec61037136600461153b565b6338377508600c908152600091909152602090205490565b34801561039557600080fd5b50638b78c6d819545b6040516001600160a01b03909116815260200161019a565b3480156103c257600080fd5b506101c36103d136600461142f565b610abe565b3480156103e257600080fd5b5061021a6103f13660046113a7565b610aea565b34801561040257600080fd5b5061018d610afd565b34801561041757600080fd5b506101ec60345481565b34801561042d57600080fd5b506101c361043c36600461137d565b610b0c565b34801561044d57600080fd5b5060325461039e906001600160a01b031681565b34801561046d57600080fd5b5061021a61047c366004611556565b610b18565b34801561048d57600080fd5b5061021a61049c36600461142f565b610c6a565b3480156104ad57600080fd5b506101ec6104bc3660046115c9565b602052637f5e9f20600c908152600091909152603490205490565b3480156104e357600080fd5b5061021a610c7c565b61021a6104fa36600461153b565b610ce8565b61021a61050d36600461153b565b610d28565b34801561051e57600080fd5b506101ec61052d36600461153b565b63389a75e1600c908152600091909152602090205490565b606060368054610554906115f3565b80601f0160208091040260200160405190810160405280929190818152602001828054610580906115f3565b80156105cd5780601f106105a2576101008083540402835291602001916105cd565b820191906000526020600020905b8154815290600101906020018083116105b057829003601f168201915b5050505050905090565b600082602052637f5e9f20600c5233600052816034600c205581600052602c5160601c336000805160206116f083398151915260206000a350600192915050565b60345460010361063a5760405162c9500b60e81b815260040160405180910390fd5b600160345561064a838383610d4f565b505050565b600061065c848484610de1565b949350505050565b60006202a3006001600160401b03164201905063389a75e1600c5233600052806020600c2055337fdbf36a107da19e49527a7176a1babf963b4b0ff8cde35ee35d6cd8f1f9ac7e1d600080a250565b6106bb610e8b565b6106c58282610ea6565b5050565b6000806106d4610545565b80519060200120905060006106e7610eff565b60408051600080516020611710833981519152815260208101949094528301525046606082015230608082015260a09020919050565b6032546001600160a01b0316331461074857604051633167e3df60e21b815260040160405180910390fd5b6001600160a01b0382166107a15760405162461bcd60e51b815260206004820152601b60248201527a43616e6e6f74206d696e7420746f207a65726f206164647265737360281b60448201526064015b60405180910390fd5b600081116107c15760405162461bcd60e51b81526004016107989061162d565b6107cb8282610f23565b816001600160a01b03167f3f2c9d57c068687834f0de942a9babb9e5acab57d516d3480a3c16ee165a42738260405161080691815260200190565b60405180910390a25050565b600082116108325760405162461bcd60e51b81526004016107989061162d565b8161083c33610a92565b10156108815760405162461bcd60e51b8152602060048201526014602482015273496e73756666696369656e742062616c616e636560601b6044820152606401610798565b61088b3383610f90565b6032546040516394d008ef60e01b81526001600160a01b03909116906394d008ef906108bf90869086908690600401611664565b600060405180830381600087803b1580156108d957600080fd5b505af11580156108ed573d6000803e3d6000fd5b50505050826001600160a01b0316336001600160a01b03167f568ab03f32147bb501e2805da5910cb00bfca97231507d615ce5326dcf93eae68484604051610936929190611694565b60405180910390a3505050565b60358054610950906115f3565b80601f016020809104026020016040519081016040528092919081815260200182805461097c906115f3565b80156109c95780601f1061099e576101008083540402835291602001916109c9565b820191906000526020600020905b8154815290600101906020018083116109ac57829003601f168201915b505050505081565b63389a75e1600c523360005260006020600c2055337ffa7b8eab7da67f412cc9575ed43464468f9bfbae89d1675917346ca6d8fe3c92600080a2565b3360009081527f266cad2a07820380da249144ee0922486396c59c16dc4ab5f4c00611d746e9b760205260409020547fc4c453d647953c0fd35db5a34ee76e60fb4abc3a8fb891a25936b70b38f292539060ff16610a815760405163962f633360e01b815260048101829052602401610798565b610a8c848484610ff5565b50505050565b6387a211a2600c908152600091909152602090205490565b610ab2610e8b565b610abc6000611178565b565b6000828152602081815260408083206001600160a01b038516845290915281205460ff165b9392505050565b610af2610e8b565b61064a838383610d4f565b606060378054610554906115f3565b6000610ae383836111b6565b6000610b22610545565b8051906020012090506000610b35610eff565b905085421115610b4d57631a15a3cc6000526004601cfd5b6040518960601b60601c99508860601b60601c985065383775081901600e52896000526020600c208054600080516020611710833981519152835284602084015283604084015246606084015230608084015260a08320602e527f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c983528b60208401528a60408401528960608401528060808401528860a084015260c08320604e526042602c206000528760ff1660205286604052856060526020806080600060015afa8c3d5114610c275763ddafbaef6000526004601cfd5b0190556303faf4f960a51b89176040526034602c20889055888a6000805160206116f0833981519152602060608501a36040525050600060605250505050505050565b610c72610e8b565b6106c5828261121f565b610c84610e8b565b603260009054906101000a90046001600160a01b03166001600160a01b031663d9374bff6040518163ffffffff1660e01b8152600401600060405180830381600087803b158015610cd457600080fd5b505af1158015610a8c573d6000803e3d6000fd5b610cf0610e8b565b63389a75e1600c52806000526020600c208054421115610d1857636f5e88186000526004601cfd5b60009055610d2581611178565b50565b610d30610e8b565b8060601b610d4657637448fbae6000526004601cfd5b610d2581611178565b603280546001600160a01b0319166001600160a01b038416179055603383905560325460405163f3aebe4d60e01b8152600481018590526001600160401b03831660248201526001600160a01b039091169063f3aebe4d90604401600060405180830381600087803b158015610dc457600080fd5b505af1158015610dd8573d6000803e3d6000fd5b50505050505050565b60008360601b33602052637f5e9f208117600c526034600c208054801915610e1f5780851115610e19576313be252b6000526004601cfd5b84810382555b50506387a211a28117600c526020600c20805480851115610e485763f4d678b86000526004601cfd5b84810382555050836000526020600c208381540181555082602052600c5160601c8160601c6000805160206116d0833981519152602080a3505060019392505050565b638b78c6d819543314610abc576382b429006000526004601cfd5b6000828152602081815260408083206001600160a01b0385168085529252808320805460ff1916600117905551909184917f2ae6a113c0ed5b78a53413ffbb7679881f11145ccfba4fb92e863dfcd5a1d2f39190a35050565b7fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc690565b6805345cdf77eb68f44c5481810181811015610f475763e5cfe9576000526004601cfd5b806805345cdf77eb68f44c5550506387a211a2600c52816000526020600c208181540181555080602052600c5160601c60006000805160206116d0833981519152602080a35050565b6387a211a2600c52816000526020600c20805480831115610fb95763f4d678b86000526004601cfd5b82900390556805345cdf77eb68f44c8054829003905560008181526001600160a01b0383166000805160206116d0833981519152602083a35050565b6001600160a01b03821661101c5760405163d92e233d60e01b815260040160405180910390fd5b73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeed196001600160a01b0384160161104b5761064a8282611275565b826001600160a01b03163b60000361107657604051630f58058360e11b815260040160405180910390fd5b6040516301ffc9a760e01b81526380ac58cd60e01b60048201526001600160a01b038416906301ffc9a790602401602060405180830381865afa9250505080156110dd575060408051601f3d908101601f191682019092526110da918101906116ad565b60015b6110ec5761064a8383836112b8565b801561116d57604051635c46a7ef60e11b81523060048201526001600160a01b03848116602483015260448201849052608060648301526000608483015285169063b88d4fde9060a401600060405180830381600087803b15801561115057600080fd5b505af1158015611164573d6000803e3d6000fd5b50505050610a8c565b610a8c8484846112b8565b638b78c6d81980546001600160a01b039092169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a355565b60006387a211a2600c52336000526020600c208054808411156111e15763f4d678b86000526004601cfd5b83810382555050826000526020600c208281540181555081602052600c5160601c336000805160206116d0833981519152602080a350600192915050565b6000828152602081815260408083206001600160a01b0385168085529252808320805460ff1916905551909184917f155aaafb6329a2098580462df33ec4b7441b19729b9601c5fc17ae1cf99a8a529190a35050565b8047101561128b5763b12d13eb6000526004601cfd5b6000386000388486620186a0f16106c557816000526073600b5360ff6020536016600b82f06106c5573838fd5b816014528060345263a9059cbb60601b60005260206000604460106000875af180600160005114166112fd57803d853b1517106112fd576390b8ec186000526004601cfd5b506000603452505050565b6000815180845260005b8181101561132e57602081850181015186830182015201611312565b506000602082860101526020601f19601f83011685010191505092915050565b602081526000610ae36020830184611308565b80356001600160a01b038116811461137857600080fd5b919050565b6000806040838503121561139057600080fd5b61139983611361565b946020939093013593505050565b6000806000606084860312156113bc57600080fd5b833592506113cc60208501611361565b915060408401356001600160401b03811681146113e857600080fd5b809150509250925092565b60008060006060848603121561140857600080fd5b61141184611361565b925061141f60208501611361565b9150604084013590509250925092565b6000806040838503121561144257600080fd5b8235915061145260208401611361565b90509250929050565b634e487b7160e01b600052604160045260246000fd5b60008060006060848603121561148657600080fd5b61148f84611361565b92506020840135915060408401356001600160401b03808211156114b257600080fd5b818601915086601f8301126114c657600080fd5b8135818111156114d8576114d861145b565b604051601f8201601f19908116603f011681019083821181831017156115005761150061145b565b8160405282815289602084870101111561151957600080fd5b8260208601602083013760006020848301015280955050505050509250925092565b60006020828403121561154d57600080fd5b610ae382611361565b600080600080600080600060e0888a03121561157157600080fd5b61157a88611361565b965061158860208901611361565b95506040880135945060608801359350608088013560ff811681146115ac57600080fd5b9699959850939692959460a0840135945060c09093013592915050565b600080604083850312156115dc57600080fd5b6115e583611361565b915061145260208401611361565b600181811c9082168061160757607f821691505b60208210810361162757634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252601d908201527f416d6f756e74206d7573742062652067726561746572207468616e2030000000604082015260600190565b60018060a01b038416815282602082015260606040820152600061168b6060830184611308565b95945050505050565b82815260406020820152600061065c6040830184611308565b6000602082840312156116bf57600080fd5b81518015158114610ae357600080fdfeddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400fa26469706673582212205cf96b6cb6a0e01a463e422032227434e7e8e521d70b36a0df870c4531ccf84f64736f6c6343000816003300000000000000000000000000000000000000000000000000000000000000120000000000000000000000007bd61c667f869fb21b77626f0ac0acee51e4be7c000000000000000000000000b94742b094f89a8d53e15a45cdbf9810a5b090eb00000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000005535553444300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000055355534443000000000000000000000000000000000000000000000000000000
Deployed Bytecode
0x6080604052600436106101735760003560e01c806306fdde0314610178578063095ea7b3146101a357806318160ddd146101d357806318b7ff72146101fa5780631c335f491461021c57806323b872dd1461023257806325692962146102525780632f2ff15d1461025a578063313ce5671461027a5780633644e5151461029c57806340c10f19146102b157806344d17187146102d15780634a85f041146102f157806354d1f13d146103065780636ccae0541461030e57806370a082311461032e578063715018a61461034e5780637ecebe00146103565780638da5cb5b1461038957806391d14854146103b6578063943103c3146103d657806395d89b41146103f65780639a7d9a9b1461040b578063a9059cbb14610421578063c6a261d214610441578063d505accf14610461578063d547741f14610481578063dd62ed3e146104a1578063e90e5cc1146104d7578063f04e283e146104ec578063f2fde38b146104ff578063fee81cf414610512575b600080fd5b34801561018457600080fd5b5061018d610545565b60405161019a919061134e565b60405180910390f35b3480156101af57600080fd5b506101c36101be36600461137d565b6105d7565b604051901515815260200161019a565b3480156101df57600080fd5b506805345cdf77eb68f44c545b60405190815260200161019a565b34801561020657600080fd5b5061021a6102153660046113a7565b610618565b005b34801561022857600080fd5b506101ec60335481565b34801561023e57600080fd5b506101c361024d3660046113f3565b61064f565b61021a610664565b34801561026657600080fd5b5061021a61027536600461142f565b6106b3565b34801561028657600080fd5b5060385460405160ff909116815260200161019a565b3480156102a857600080fd5b506101ec6106c9565b3480156102bd57600080fd5b5061021a6102cc36600461137d565b61071d565b3480156102dd57600080fd5b5061021a6102ec366004611471565b610812565b3480156102fd57600080fd5b5061018d610943565b61021a6109d1565b34801561031a57600080fd5b5061021a6103293660046113f3565b610a0d565b34801561033a57600080fd5b506101ec61034936600461153b565b610a92565b61021a610aaa565b34801561036257600080fd5b506101ec61037136600461153b565b6338377508600c908152600091909152602090205490565b34801561039557600080fd5b50638b78c6d819545b6040516001600160a01b03909116815260200161019a565b3480156103c257600080fd5b506101c36103d136600461142f565b610abe565b3480156103e257600080fd5b5061021a6103f13660046113a7565b610aea565b34801561040257600080fd5b5061018d610afd565b34801561041757600080fd5b506101ec60345481565b34801561042d57600080fd5b506101c361043c36600461137d565b610b0c565b34801561044d57600080fd5b5060325461039e906001600160a01b031681565b34801561046d57600080fd5b5061021a61047c366004611556565b610b18565b34801561048d57600080fd5b5061021a61049c36600461142f565b610c6a565b3480156104ad57600080fd5b506101ec6104bc3660046115c9565b602052637f5e9f20600c908152600091909152603490205490565b3480156104e357600080fd5b5061021a610c7c565b61021a6104fa36600461153b565b610ce8565b61021a61050d36600461153b565b610d28565b34801561051e57600080fd5b506101ec61052d36600461153b565b63389a75e1600c908152600091909152602090205490565b606060368054610554906115f3565b80601f0160208091040260200160405190810160405280929190818152602001828054610580906115f3565b80156105cd5780601f106105a2576101008083540402835291602001916105cd565b820191906000526020600020905b8154815290600101906020018083116105b057829003601f168201915b5050505050905090565b600082602052637f5e9f20600c5233600052816034600c205581600052602c5160601c336000805160206116f083398151915260206000a350600192915050565b60345460010361063a5760405162c9500b60e81b815260040160405180910390fd5b600160345561064a838383610d4f565b505050565b600061065c848484610de1565b949350505050565b60006202a3006001600160401b03164201905063389a75e1600c5233600052806020600c2055337fdbf36a107da19e49527a7176a1babf963b4b0ff8cde35ee35d6cd8f1f9ac7e1d600080a250565b6106bb610e8b565b6106c58282610ea6565b5050565b6000806106d4610545565b80519060200120905060006106e7610eff565b60408051600080516020611710833981519152815260208101949094528301525046606082015230608082015260a09020919050565b6032546001600160a01b0316331461074857604051633167e3df60e21b815260040160405180910390fd5b6001600160a01b0382166107a15760405162461bcd60e51b815260206004820152601b60248201527a43616e6e6f74206d696e7420746f207a65726f206164647265737360281b60448201526064015b60405180910390fd5b600081116107c15760405162461bcd60e51b81526004016107989061162d565b6107cb8282610f23565b816001600160a01b03167f3f2c9d57c068687834f0de942a9babb9e5acab57d516d3480a3c16ee165a42738260405161080691815260200190565b60405180910390a25050565b600082116108325760405162461bcd60e51b81526004016107989061162d565b8161083c33610a92565b10156108815760405162461bcd60e51b8152602060048201526014602482015273496e73756666696369656e742062616c616e636560601b6044820152606401610798565b61088b3383610f90565b6032546040516394d008ef60e01b81526001600160a01b03909116906394d008ef906108bf90869086908690600401611664565b600060405180830381600087803b1580156108d957600080fd5b505af11580156108ed573d6000803e3d6000fd5b50505050826001600160a01b0316336001600160a01b03167f568ab03f32147bb501e2805da5910cb00bfca97231507d615ce5326dcf93eae68484604051610936929190611694565b60405180910390a3505050565b60358054610950906115f3565b80601f016020809104026020016040519081016040528092919081815260200182805461097c906115f3565b80156109c95780601f1061099e576101008083540402835291602001916109c9565b820191906000526020600020905b8154815290600101906020018083116109ac57829003601f168201915b505050505081565b63389a75e1600c523360005260006020600c2055337ffa7b8eab7da67f412cc9575ed43464468f9bfbae89d1675917346ca6d8fe3c92600080a2565b3360009081527f266cad2a07820380da249144ee0922486396c59c16dc4ab5f4c00611d746e9b760205260409020547fc4c453d647953c0fd35db5a34ee76e60fb4abc3a8fb891a25936b70b38f292539060ff16610a815760405163962f633360e01b815260048101829052602401610798565b610a8c848484610ff5565b50505050565b6387a211a2600c908152600091909152602090205490565b610ab2610e8b565b610abc6000611178565b565b6000828152602081815260408083206001600160a01b038516845290915281205460ff165b9392505050565b610af2610e8b565b61064a838383610d4f565b606060378054610554906115f3565b6000610ae383836111b6565b6000610b22610545565b8051906020012090506000610b35610eff565b905085421115610b4d57631a15a3cc6000526004601cfd5b6040518960601b60601c99508860601b60601c985065383775081901600e52896000526020600c208054600080516020611710833981519152835284602084015283604084015246606084015230608084015260a08320602e527f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c983528b60208401528a60408401528960608401528060808401528860a084015260c08320604e526042602c206000528760ff1660205286604052856060526020806080600060015afa8c3d5114610c275763ddafbaef6000526004601cfd5b0190556303faf4f960a51b89176040526034602c20889055888a6000805160206116f0833981519152602060608501a36040525050600060605250505050505050565b610c72610e8b565b6106c5828261121f565b610c84610e8b565b603260009054906101000a90046001600160a01b03166001600160a01b031663d9374bff6040518163ffffffff1660e01b8152600401600060405180830381600087803b158015610cd457600080fd5b505af1158015610a8c573d6000803e3d6000fd5b610cf0610e8b565b63389a75e1600c52806000526020600c208054421115610d1857636f5e88186000526004601cfd5b60009055610d2581611178565b50565b610d30610e8b565b8060601b610d4657637448fbae6000526004601cfd5b610d2581611178565b603280546001600160a01b0319166001600160a01b038416179055603383905560325460405163f3aebe4d60e01b8152600481018590526001600160401b03831660248201526001600160a01b039091169063f3aebe4d90604401600060405180830381600087803b158015610dc457600080fd5b505af1158015610dd8573d6000803e3d6000fd5b50505050505050565b60008360601b33602052637f5e9f208117600c526034600c208054801915610e1f5780851115610e19576313be252b6000526004601cfd5b84810382555b50506387a211a28117600c526020600c20805480851115610e485763f4d678b86000526004601cfd5b84810382555050836000526020600c208381540181555082602052600c5160601c8160601c6000805160206116d0833981519152602080a3505060019392505050565b638b78c6d819543314610abc576382b429006000526004601cfd5b6000828152602081815260408083206001600160a01b0385168085529252808320805460ff1916600117905551909184917f2ae6a113c0ed5b78a53413ffbb7679881f11145ccfba4fb92e863dfcd5a1d2f39190a35050565b7fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc690565b6805345cdf77eb68f44c5481810181811015610f475763e5cfe9576000526004601cfd5b806805345cdf77eb68f44c5550506387a211a2600c52816000526020600c208181540181555080602052600c5160601c60006000805160206116d0833981519152602080a35050565b6387a211a2600c52816000526020600c20805480831115610fb95763f4d678b86000526004601cfd5b82900390556805345cdf77eb68f44c8054829003905560008181526001600160a01b0383166000805160206116d0833981519152602083a35050565b6001600160a01b03821661101c5760405163d92e233d60e01b815260040160405180910390fd5b73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeed196001600160a01b0384160161104b5761064a8282611275565b826001600160a01b03163b60000361107657604051630f58058360e11b815260040160405180910390fd5b6040516301ffc9a760e01b81526380ac58cd60e01b60048201526001600160a01b038416906301ffc9a790602401602060405180830381865afa9250505080156110dd575060408051601f3d908101601f191682019092526110da918101906116ad565b60015b6110ec5761064a8383836112b8565b801561116d57604051635c46a7ef60e11b81523060048201526001600160a01b03848116602483015260448201849052608060648301526000608483015285169063b88d4fde9060a401600060405180830381600087803b15801561115057600080fd5b505af1158015611164573d6000803e3d6000fd5b50505050610a8c565b610a8c8484846112b8565b638b78c6d81980546001600160a01b039092169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a355565b60006387a211a2600c52336000526020600c208054808411156111e15763f4d678b86000526004601cfd5b83810382555050826000526020600c208281540181555081602052600c5160601c336000805160206116d0833981519152602080a350600192915050565b6000828152602081815260408083206001600160a01b0385168085529252808320805460ff1916905551909184917f155aaafb6329a2098580462df33ec4b7441b19729b9601c5fc17ae1cf99a8a529190a35050565b8047101561128b5763b12d13eb6000526004601cfd5b6000386000388486620186a0f16106c557816000526073600b5360ff6020536016600b82f06106c5573838fd5b816014528060345263a9059cbb60601b60005260206000604460106000875af180600160005114166112fd57803d853b1517106112fd576390b8ec186000526004601cfd5b506000603452505050565b6000815180845260005b8181101561132e57602081850181015186830182015201611312565b506000602082860101526020601f19601f83011685010191505092915050565b602081526000610ae36020830184611308565b80356001600160a01b038116811461137857600080fd5b919050565b6000806040838503121561139057600080fd5b61139983611361565b946020939093013593505050565b6000806000606084860312156113bc57600080fd5b833592506113cc60208501611361565b915060408401356001600160401b03811681146113e857600080fd5b809150509250925092565b60008060006060848603121561140857600080fd5b61141184611361565b925061141f60208501611361565b9150604084013590509250925092565b6000806040838503121561144257600080fd5b8235915061145260208401611361565b90509250929050565b634e487b7160e01b600052604160045260246000fd5b60008060006060848603121561148657600080fd5b61148f84611361565b92506020840135915060408401356001600160401b03808211156114b257600080fd5b818601915086601f8301126114c657600080fd5b8135818111156114d8576114d861145b565b604051601f8201601f19908116603f011681019083821181831017156115005761150061145b565b8160405282815289602084870101111561151957600080fd5b8260208601602083013760006020848301015280955050505050509250925092565b60006020828403121561154d57600080fd5b610ae382611361565b600080600080600080600060e0888a03121561157157600080fd5b61157a88611361565b965061158860208901611361565b95506040880135945060608801359350608088013560ff811681146115ac57600080fd5b9699959850939692959460a0840135945060c09093013592915050565b600080604083850312156115dc57600080fd5b6115e583611361565b915061145260208401611361565b600181811c9082168061160757607f821691505b60208210810361162757634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252601d908201527f416d6f756e74206d7573742062652067726561746572207468616e2030000000604082015260600190565b60018060a01b038416815282602082015260606040820152600061168b6060830184611308565b95945050505050565b82815260406020820152600061065c6040830184611308565b6000602082840312156116bf57600080fd5b81518015158114610ae357600080fdfeddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400fa26469706673582212205cf96b6cb6a0e01a463e422032227434e7e8e521d70b36a0df870c4531ccf84f64736f6c63430008160033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
00000000000000000000000000000000000000000000000000000000000000120000000000000000000000007bd61c667f869fb21b77626f0ac0acee51e4be7c000000000000000000000000b94742b094f89a8d53e15a45cdbf9810a5b090eb00000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000005535553444300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000055355534443000000000000000000000000000000000000000000000000000000
-----Decoded View---------------
Arg [0] : tokenDecimals (uint8): 18
Arg [1] : initialOwner (address): 0x7BD61c667f869FB21b77626f0Ac0ACEE51e4BE7C
Arg [2] : socket (address): 0xB94742B094f89A8D53e15A45CdBf9810a5B090Eb
Arg [3] : tokenName (string): SUSDC
Arg [4] : tokenSymbol (string): SUSDC
-----Encoded View---------------
9 Constructor Arguments found :
Arg [0] : 0000000000000000000000000000000000000000000000000000000000000012
Arg [1] : 0000000000000000000000007bd61c667f869fb21b77626f0ac0acee51e4be7c
Arg [2] : 000000000000000000000000b94742b094f89a8d53e15a45cdbf9810a5b090eb
Arg [3] : 00000000000000000000000000000000000000000000000000000000000000a0
Arg [4] : 00000000000000000000000000000000000000000000000000000000000000e0
Arg [5] : 0000000000000000000000000000000000000000000000000000000000000005
Arg [6] : 5355534443000000000000000000000000000000000000000000000000000000
Arg [7] : 0000000000000000000000000000000000000000000000000000000000000005
Arg [8] : 5355534443000000000000000000000000000000000000000000000000000000
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.