Latest 25 from a total of 157,237 transactions (+12 Pending)
| Transaction Hash |
|
Block
|
From
|
To
|
|||||
|---|---|---|---|---|---|---|---|---|---|
| 0x2a0d79262797f9e30e66c46256ac81aa79b8a5b856f01f9ea5a53962c8b00cf8 | - | (pending) | 3 days ago | IN | 0.022 ETH | (Pending) | |||
| 0x194fd6418235d0a6b776cc58a76ca8e593ae2bed472626d357b280e7e1eabc5e | - | (pending) | 8 days ago | IN | 0.0000673673 ETH | (Pending) | |||
| 0x2d22989b16beea92e05a69ecaac623d7309521e2f1a836273eb41e2a7a6df582 | - | (pending) | 8 days ago | IN | 0.0000610836 ETH | (Pending) | |||
| 0xcba712766956ec1d9fd18c27aa4132e19bdf88db19cab180a7ee2c91287190aa | - | (pending) | 8 days ago | IN | 0.0003136701 ETH | (Pending) | |||
| 0xaa976dca957e35714380c6bc2d5620275e79fa411175fd798473a26503f6106b | - | (pending) | 8 days ago | IN | 0.0032144687 ETH | (Pending) | |||
| 0x43176873e6bdd3b2fdf604d251f0bcb3de821fa848f5271ed361425bb18f307d | - | (pending) | 8 days ago | IN | 0.0034144687 ETH | (Pending) | |||
| 0x5ba35e30cd0acde8000f96585807242baa608f8e600940597ab945c415dad2e1 | - | (pending) | 9 days ago | IN | 0.00001 ETH | (Pending) | |||
| 0xaed38ce14558b8c871f203c09e82e44d3813906e5684988a6240c69823669f20 | - | (pending) | 9 days ago | IN | 0.0001 ETH | (Pending) | |||
| 0xc3dc1bf6f406b466e791645c81dcc00e25d702d90e1eaa783dfd1f5f5608b73a | - | (pending) | 9 days ago | IN | 0.00003 ETH | (Pending) | |||
| 0x863fa1804cc9fd826c0ced5c7f2c86b7d7474b00733b768632334a7b999bc10b | - | (pending) | 9 days ago | IN | 0.008 ETH | (Pending) | |||
| 0xd47680f1dbdf20046cbb3000c880456005f508e1a7da8cd2fa6aea21c378610f | - | (pending) | 10 days ago | IN | 0.0034144687 ETH | (Pending) | |||
| 0x7b52a6a9f6c302281617f4feb8719524d1b1573798f2c9e8a52feb8395612d2a | - | (pending) | 65 days ago | IN | 0.0000741795 ETH | (Pending) | |||
| Deposit Native | 28259162 | 1 min ago | IN | 0.028 ETH | 0.00000123 | ||||
| Deposit Native | 28258966 | 7 mins ago | IN | 0.0205 ETH | 0.00000123 | ||||
| Deposit Native | 28258914 | 9 mins ago | IN | 0.00043459 ETH | 0.00000194 | ||||
| Deposit Native | 28258807 | 13 mins ago | IN | 0.00119096 ETH | 0.00000162 | ||||
| Deposit Native | 28258762 | 15 mins ago | IN | 0.00029547 ETH | 0.0000022 | ||||
| Deposit Native | 28258708 | 17 mins ago | IN | 0.01784924 ETH | 0.00000104 | ||||
| Deposit Native | 28258659 | 18 mins ago | IN | 0.0003061 ETH | 0.00000314 | ||||
| Deposit Native | 28258531 | 23 mins ago | IN | 0.00033565 ETH | 0.0000018 | ||||
| Deposit Native | 28258406 | 27 mins ago | IN | 0.006 ETH | 0.00000596 | ||||
| Deposit Native | 28258374 | 28 mins ago | IN | 0.0065 ETH | 0.0000011 | ||||
| Deposit Native | 28258337 | 30 mins ago | IN | 0.0065 ETH | 0.00000105 | ||||
| Deposit Native | 28258282 | 32 mins ago | IN | 0.03 ETH | 0.00000205 | ||||
| Deposit Native | 28258242 | 33 mins ago | IN | 0.01 ETH | 0.00000123 |
Latest 25 internal transactions (View All)
Advanced mode:
| Parent Transaction Hash | Block | From | To | |||
|---|---|---|---|---|---|---|
| 28259000 | 6 mins ago | 0.13523554 ETH | ||||
| 28257637 | 55 mins ago | 0.03387628 ETH | ||||
| 28257306 | 1 hr ago | 0.00016596 ETH | ||||
| 28257127 | 1 hr ago | 0.00006175 ETH | ||||
| 28256958 | 1 hr ago | 0.00144184 ETH | ||||
| 28256573 | 1 hr ago | 0.00016607 ETH | ||||
| 28256381 | 1 hr ago | 0.33747743 ETH | ||||
| 28256215 | 1 hr ago | 3.45523178 ETH | ||||
| 28256215 | 1 hr ago | 0 ETH | ||||
| 28256180 | 1 hr ago | 0.00180396 ETH | ||||
| 28256165 | 1 hr ago | 0.00039771 ETH | ||||
| 28256159 | 1 hr ago | 0.0008 ETH | ||||
| 28256022 | 1 hr ago | 0.00013545 ETH | ||||
| 28255921 | 1 hr ago | 0.04658325 ETH | ||||
| 28255776 | 2 hrs ago | 0.00056419 ETH | ||||
| 28255601 | 2 hrs ago | 0.00014687 ETH | ||||
| 28255527 | 2 hrs ago | 0.006349 ETH | ||||
| 28255456 | 2 hrs ago | 0.00986275 ETH | ||||
| 28255335 | 2 hrs ago | 0.0003378 ETH | ||||
| 28255302 | 2 hrs ago | 0.0108799 ETH | ||||
| 28255165 | 2 hrs ago | 0.01845383 ETH | ||||
| 28254935 | 2 hrs ago | 0.01109147 ETH | ||||
| 28254916 | 2 hrs ago | 0.00680305 ETH | ||||
| 28254879 | 2 hrs ago | 0.00007 ETH | ||||
| 28254790 | 2 hrs ago | 0.01973888 ETH |
Cross-Chain Transactions
Loading...
Loading
Contract Name:
RelayDepository
Compiler Version
v0.8.28+commit.7893614a
Optimization Enabled:
No with 200 runs
Other Settings:
london EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;
import {Ownable} from "solady/auth/Ownable.sol";
import {ERC20} from "solady/tokens/ERC20.sol";
import {EIP712} from "solady/utils/EIP712.sol";
import {SafeTransferLib} from "solady/utils/SafeTransferLib.sol";
import {SignatureCheckerLib} from "solady/utils/SignatureCheckerLib.sol";
import {Call, CallRequest, CallResult} from "./utils/RelayDepositoryStructs.sol";
/// @title RelayDepository
/// @author Relay
contract RelayDepository is Ownable, EIP712 {
using SafeTransferLib for address;
using SignatureCheckerLib for address;
/// @notice Revert if the address is zero
error AddressCannotBeZero();
/// @notice Revert if the signature is invalid
error InvalidSignature();
/// @notice Revert if the call request is expired
error CallRequestExpired();
/// @notice Revert if the call request has already been used
error CallRequestAlreadyUsed();
/// @notice Revert if a call fails
error CallFailed(bytes returnData);
/// @notice Emit event when a native deposit is made
event RelayNativeDeposit(address from, uint256 amount, bytes32 id);
/// @notice Emit event when an erc20 deposit is made
event RelayErc20Deposit(
address from,
address token,
uint256 amount,
bytes32 id
);
/// @notice Emit event when a call is executed
event RelayCallExecuted(bytes32 id, Call call);
/// @notice The EIP-712 typehash for the Call struct
bytes32 public constant _CALL_TYPEHASH =
keccak256(
"Call(address to,bytes data,uint256 value,bool allowFailure)"
);
/// @notice The EIP-712 typehash for the CallRequest struct
bytes32 public constant _CALL_REQUEST_TYPEHASH =
keccak256(
"CallRequest(Call[] calls,uint256 nonce,uint256 expiration)Call(address to,bytes data,uint256 value,bool allowFailure)"
);
/// @notice Set of executed call requests
mapping(bytes32 => bool) public callRequests;
/// @notice The allocator address
address public allocator;
constructor(address _owner, address _allocator) {
_initializeOwner(_owner);
allocator = _allocator;
}
/// @notice Set the allocator address
/// @param _allocator The new allocator address
function setAllocator(address _allocator) external onlyOwner {
if (_allocator == address(0)) {
revert AddressCannotBeZero();
}
allocator = _allocator;
}
/// @notice Deposit native tokens and emit a `RelayNativeDeposit` event
/// @param depositor The address of the depositor - set to `address(0)` to credit `msg.sender`
/// @param id The id associated with the deposit
function depositNative(address depositor, bytes32 id) external payable {
address depositorAddress = depositor == address(0)
? msg.sender
: depositor;
// Emit the `RelayNativeDeposit` event
emit RelayNativeDeposit(depositorAddress, msg.value, id);
}
/// @notice Deposit erc20 tokens and emit an `RelayErc20Deposit` event
/// @param depositor The address of the depositor - set to `address(0)` to credit `msg.sender`
/// @param token The erc20 token to deposit
/// @param amount The amount to deposit
/// @param id The id associated with the deposit
function depositErc20(
address depositor,
address token,
uint256 amount,
bytes32 id
) public {
// Transfer the tokens to the contract
token.safeTransferFrom(msg.sender, address(this), amount);
address depositorAddress = depositor == address(0)
? msg.sender
: depositor;
// Emit the `RelayErc20Deposit` event
emit RelayErc20Deposit(depositorAddress, token, amount, id);
}
/// @notice Deposit erc20 tokens and emit an `RelayErc20Deposit` event
/// @param depositor The address of the depositor - set to `address(0)` to credit `msg.sender`
/// @param token The erc20 token to deposit
/// @param id The id associated with the deposit
function depositErc20(
address depositor,
address token,
bytes32 id
) external {
uint256 amount = ERC20(token).allowance(msg.sender, address(this));
depositErc20(depositor, token, amount, id);
}
/// @notice Execute a `CallRequest` signed by the allocator
/// @param request The `CallRequest` to execute
/// @param signature The signature from the allocator
/// @return results The results of the calls
function execute(
CallRequest calldata request,
bytes memory signature
) external returns (CallResult[] memory results) {
(bytes32 structHash, bytes32 eip712Hash) = _hashCallRequest(request);
// Validate the call request expiration
if (request.expiration < block.timestamp) {
revert CallRequestExpired();
}
// Validate the allocator signature
if (!allocator.isValidSignatureNow(eip712Hash, signature)) {
revert InvalidSignature();
}
// Revert if the call request has already been used
if (callRequests[structHash]) {
revert CallRequestAlreadyUsed();
}
// Mark the call request as used
callRequests[structHash] = true;
// Execute the calls
results = _executeCalls(structHash, request.calls);
}
/// @notice Execute a list of calls
/// @param id The id of the call request
/// @param calls The calls to execute
/// @return returnData The results of the calls
function _executeCalls(
bytes32 id,
Call[] calldata calls
) internal returns (CallResult[] memory returnData) {
unchecked {
uint256 length = calls.length;
// Initialize the return data array
returnData = new CallResult[](length);
// Iterate over the calls
for (uint256 i; i < length; i++) {
Call memory c = calls[i];
// Execute the call
(bool success, bytes memory data) = c.to.call{value: c.value}(
c.data
);
// Revert if the call failed and failure is not allowed
if (!success && !c.allowFailure) {
revert CallFailed(data);
}
// Store the success status and return data
returnData[i] = CallResult({
success: success,
returnData: data
});
// Emit the `RelayCallExecuted` event if the call was successful
if (success) {
emit RelayCallExecuted(id, c);
}
}
}
}
/// @notice Helper function to hash a `CallRequest` and return the EIP-712 digest
/// @param request The `CallRequest` to hash
/// @return structHash The struct hash
/// @return eip712Hash The EIP712 hash
function _hashCallRequest(
CallRequest calldata request
) internal view returns (bytes32 structHash, bytes32 eip712Hash) {
// Initialize the array of call hashes
bytes32[] memory callHashes = new bytes32[](request.calls.length);
// Iterate over the underlying calls
for (uint256 i = 0; i < request.calls.length; i++) {
// Hash the call
bytes32 callHash = keccak256(
abi.encode(
_CALL_TYPEHASH,
request.calls[i].to,
keccak256(request.calls[i].data),
request.calls[i].value,
request.calls[i].allowFailure
)
);
// Store the hash in the array
callHashes[i] = callHash;
}
// Get the struct hash
structHash = keccak256(
abi.encode(
_CALL_REQUEST_TYPEHASH,
keccak256(abi.encodePacked(callHashes)),
request.nonce,
request.expiration
)
);
// Get the EIP-712 hash
eip712Hash = _hashTypedData(structHash);
}
/// @notice Returns the domain name and version of the contract to be used in the domain separator
/// @return name The domain name
/// @return version The version
function _domainNameAndVersion()
internal
pure
override
returns (string memory name, string memory version)
{
name = "RelayDepository";
version = "1";
}
}// 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`.
/// Enabled by default. To disable, 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 true;
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
/// @notice Contract for EIP-712 typed structured data hashing and signing.
/// @author Solady (https://github.com/vectorized/solady/blob/main/src/utils/EIP712.sol)
/// @author Modified from Solbase (https://github.com/Sol-DAO/solbase/blob/main/src/utils/EIP712.sol)
/// @author Modified from OpenZeppelin (https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/cryptography/EIP712.sol)
///
/// @dev Note, this implementation:
/// - Uses `address(this)` for the `verifyingContract` field.
/// - Does NOT use the optional EIP-712 salt.
/// - Does NOT use any EIP-712 extensions.
/// This is for simplicity and to save gas.
/// If you need to customize, please fork / modify accordingly.
abstract contract EIP712 {
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* CONSTANTS AND IMMUTABLES */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev `keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)")`.
bytes32 internal constant _DOMAIN_TYPEHASH =
0x8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f;
/// @dev `keccak256("EIP712Domain(string name,string version,address verifyingContract)")`.
/// This is only used in `_hashTypedDataSansChainId`.
bytes32 internal constant _DOMAIN_TYPEHASH_SANS_CHAIN_ID =
0x91ab3d17e3a50a9d89e63fd30b92be7f5336b03b287bb946787a83a9d62a2766;
uint256 private immutable _cachedThis;
uint256 private immutable _cachedChainId;
bytes32 private immutable _cachedNameHash;
bytes32 private immutable _cachedVersionHash;
bytes32 private immutable _cachedDomainSeparator;
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* CONSTRUCTOR */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev Cache the hashes for cheaper runtime gas costs.
/// In the case of upgradeable contracts (i.e. proxies),
/// or if the chain id changes due to a hard fork,
/// the domain separator will be seamlessly calculated on-the-fly.
constructor() {
_cachedThis = uint256(uint160(address(this)));
_cachedChainId = block.chainid;
string memory name;
string memory version;
if (!_domainNameAndVersionMayChange()) (name, version) = _domainNameAndVersion();
bytes32 nameHash = _domainNameAndVersionMayChange() ? bytes32(0) : keccak256(bytes(name));
bytes32 versionHash =
_domainNameAndVersionMayChange() ? bytes32(0) : keccak256(bytes(version));
_cachedNameHash = nameHash;
_cachedVersionHash = versionHash;
bytes32 separator;
if (!_domainNameAndVersionMayChange()) {
/// @solidity memory-safe-assembly
assembly {
let m := mload(0x40) // Load 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())
separator := keccak256(m, 0xa0)
}
}
_cachedDomainSeparator = separator;
}
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* FUNCTIONS TO OVERRIDE */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev Please override this function to return the domain name and version.
/// ```
/// function _domainNameAndVersion()
/// internal
/// pure
/// virtual
/// returns (string memory name, string memory version)
/// {
/// name = "Solady";
/// version = "1";
/// }
/// ```
///
/// Note: If the returned result may change after the contract has been deployed,
/// you must override `_domainNameAndVersionMayChange()` to return true.
function _domainNameAndVersion()
internal
view
virtual
returns (string memory name, string memory version);
/// @dev Returns if `_domainNameAndVersion()` may change
/// after the contract has been deployed (i.e. after the constructor).
/// Default: false.
function _domainNameAndVersionMayChange() internal pure virtual returns (bool result) {}
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* HASHING OPERATIONS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev Returns the EIP-712 domain separator.
function _domainSeparator() internal view virtual returns (bytes32 separator) {
if (_domainNameAndVersionMayChange()) {
separator = _buildDomainSeparator();
} else {
separator = _cachedDomainSeparator;
if (_cachedDomainSeparatorInvalidated()) separator = _buildDomainSeparator();
}
}
/// @dev Returns the hash of the fully encoded EIP-712 message for this domain,
/// given `structHash`, as defined in
/// https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct.
///
/// The hash can be used together with {ECDSA-recover} to obtain the signer of a message:
/// ```
/// bytes32 digest = _hashTypedData(keccak256(abi.encode(
/// keccak256("Mail(address to,string contents)"),
/// mailTo,
/// keccak256(bytes(mailContents))
/// )));
/// address signer = ECDSA.recover(digest, signature);
/// ```
function _hashTypedData(bytes32 structHash) internal view virtual returns (bytes32 digest) {
// We will use `digest` to store the domain separator to save a bit of gas.
if (_domainNameAndVersionMayChange()) {
digest = _buildDomainSeparator();
} else {
digest = _cachedDomainSeparator;
if (_cachedDomainSeparatorInvalidated()) digest = _buildDomainSeparator();
}
/// @solidity memory-safe-assembly
assembly {
// Compute the digest.
mstore(0x00, 0x1901000000000000) // Store "\x19\x01".
mstore(0x1a, digest) // Store the domain separator.
mstore(0x3a, structHash) // Store the struct hash.
digest := keccak256(0x18, 0x42)
// Restore the part of the free memory slot that was overwritten.
mstore(0x3a, 0)
}
}
/// @dev Variant of `_hashTypedData` that excludes the chain ID.
/// We expect that most contracts will use `_hashTypedData` as the main hash,
/// and `_hashTypedDataSansChainId` only occasionally for cross-chain workflows.
/// Thus this is optimized for smaller bytecode size over runtime gas.
function _hashTypedDataSansChainId(bytes32 structHash)
internal
view
virtual
returns (bytes32 digest)
{
(string memory name, string memory version) = _domainNameAndVersion();
/// @solidity memory-safe-assembly
assembly {
let m := mload(0x40) // Load the free memory pointer.
mstore(0x00, _DOMAIN_TYPEHASH_SANS_CHAIN_ID)
mstore(0x20, keccak256(add(name, 0x20), mload(name)))
mstore(0x40, keccak256(add(version, 0x20), mload(version)))
mstore(0x60, address())
// Compute the digest.
mstore(0x20, keccak256(0x00, 0x80)) // Store the domain separator.
mstore(0x00, 0x1901) // Store "\x19\x01".
mstore(0x40, structHash) // Store the struct hash.
digest := keccak256(0x1e, 0x42)
mstore(0x40, m) // Restore the free memory pointer.
mstore(0x60, 0) // Restore the zero pointer.
}
}
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* EIP-5267 OPERATIONS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev See: https://eips.ethereum.org/EIPS/eip-5267
function eip712Domain()
public
view
virtual
returns (
bytes1 fields,
string memory name,
string memory version,
uint256 chainId,
address verifyingContract,
bytes32 salt,
uint256[] memory extensions
)
{
fields = hex"0f"; // `0b01111`.
(name, version) = _domainNameAndVersion();
chainId = block.chainid;
verifyingContract = address(this);
salt = salt; // `bytes32(0)`.
extensions = extensions; // `new uint256[](0)`.
}
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* PRIVATE HELPERS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev Returns the EIP-712 domain separator.
function _buildDomainSeparator() private view returns (bytes32 separator) {
// We will use `separator` to store the name hash to save a bit of gas.
bytes32 versionHash;
if (_domainNameAndVersionMayChange()) {
(string memory name, string memory version) = _domainNameAndVersion();
separator = keccak256(bytes(name));
versionHash = keccak256(bytes(version));
} else {
separator = _cachedNameHash;
versionHash = _cachedVersionHash;
}
/// @solidity memory-safe-assembly
assembly {
let m := mload(0x40) // Load the free memory pointer.
mstore(m, _DOMAIN_TYPEHASH)
mstore(add(m, 0x20), separator) // Name hash.
mstore(add(m, 0x40), versionHash)
mstore(add(m, 0x60), chainid())
mstore(add(m, 0x80), address())
separator := keccak256(m, 0xa0)
}
}
/// @dev Returns if the cached domain separator has been invalidated.
function _cachedDomainSeparatorInvalidated() private view returns (bool result) {
uint256 cachedChainId = _cachedChainId;
uint256 cachedThis = _cachedThis;
/// @solidity memory-safe-assembly
assembly {
result := iszero(and(eq(chainid(), cachedChainId), eq(address(), cachedThis)))
}
}
}// 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();
/// @dev The Permit2 approve operation has failed.
error Permit2ApproveFailed();
/// @dev The Permit2 lockdown operation has failed.
error Permit2LockdownFailed();
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* 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),
lt(iszero(amount), staticcall(gas(), token, 0x10, 0x24, add(m, 0x54), 0x20))
)
mstore(m, 0x8fcbaf0c000000000000000000000000) // `IDAIPermit.permit`.
// `nonces` is already at `add(m, 0x54)`.
// `amount != 0` 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)
}
}
}
/// @dev Approves `spender` to spend `amount` of `token` for `address(this)`.
function permit2Approve(address token, address spender, uint160 amount, uint48 expiration)
internal
{
/// @solidity memory-safe-assembly
assembly {
let addressMask := shr(96, not(0))
let m := mload(0x40)
mstore(m, 0x87517c45) // `approve(address,address,uint160,uint48)`.
mstore(add(m, 0x20), and(addressMask, token))
mstore(add(m, 0x40), and(addressMask, spender))
mstore(add(m, 0x60), and(addressMask, amount))
mstore(add(m, 0x80), and(0xffffffffffff, expiration))
if iszero(call(gas(), PERMIT2, 0, add(m, 0x1c), 0xa0, codesize(), 0x00)) {
mstore(0x00, 0x324f14ae) // `Permit2ApproveFailed()`.
revert(0x1c, 0x04)
}
}
}
/// @dev Revokes an approval for `token` and `spender` for `address(this)`.
function permit2Lockdown(address token, address spender) internal {
/// @solidity memory-safe-assembly
assembly {
let m := mload(0x40)
mstore(m, 0xcc53287f) // `Permit2.lockdown`.
mstore(add(m, 0x20), 0x20) // Offset of the `approvals`.
mstore(add(m, 0x40), 1) // `approvals.length`.
mstore(add(m, 0x60), shr(96, shl(96, token)))
mstore(add(m, 0x80), shr(96, shl(96, spender)))
if iszero(call(gas(), PERMIT2, 0, add(m, 0x1c), 0xa0, codesize(), 0x00)) {
mstore(0x00, 0x96b3de23) // `Permit2LockdownFailed()`.
revert(0x1c, 0x04)
}
}
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
/// @notice Signature verification helper that supports both ECDSA signatures from EOAs
/// and ERC1271 signatures from smart contract wallets like Argent and Gnosis safe.
/// @author Solady (https://github.com/vectorized/solady/blob/main/src/utils/SignatureCheckerLib.sol)
/// @author Modified from OpenZeppelin (https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/cryptography/SignatureChecker.sol)
///
/// @dev Note:
/// - The signature checking functions use the ecrecover precompile (0x1).
/// - The `bytes memory signature` variants use the identity precompile (0x4)
/// to copy memory internally.
/// - Unlike ECDSA signatures, contract signatures are revocable.
/// - As of Solady version 0.0.134, all `bytes signature` variants accept both
/// regular 65-byte `(r, s, v)` and EIP-2098 `(r, vs)` short form signatures.
/// See: https://eips.ethereum.org/EIPS/eip-2098
/// This is for calldata efficiency on smart accounts prevalent on L2s.
///
/// WARNING! Do NOT use signatures as unique identifiers:
/// - Use a nonce in the digest to prevent replay attacks on the same contract.
/// - Use EIP-712 for the digest to prevent replay attacks across different chains and contracts.
/// EIP-712 also enables readable signing of typed data for better user safety.
/// This implementation does NOT check if a signature is non-malleable.
library SignatureCheckerLib {
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* SIGNATURE CHECKING OPERATIONS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev Returns whether `signature` is valid for `signer` and `hash`.
/// If `signer.code.length == 0`, then validate with `ecrecover`, else
/// it will validate with ERC1271 on `signer`.
function isValidSignatureNow(address signer, bytes32 hash, bytes memory signature)
internal
view
returns (bool isValid)
{
if (signer == address(0)) return isValid;
/// @solidity memory-safe-assembly
assembly {
let m := mload(0x40)
for {} 1 {} {
if iszero(extcodesize(signer)) {
switch mload(signature)
case 64 {
let vs := mload(add(signature, 0x40))
mstore(0x20, add(shr(255, vs), 27)) // `v`.
mstore(0x60, shr(1, shl(1, vs))) // `s`.
}
case 65 {
mstore(0x20, byte(0, mload(add(signature, 0x60)))) // `v`.
mstore(0x60, mload(add(signature, 0x40))) // `s`.
}
default { break }
mstore(0x00, hash)
mstore(0x40, mload(add(signature, 0x20))) // `r`.
let recovered := mload(staticcall(gas(), 1, 0x00, 0x80, 0x01, 0x20))
isValid := gt(returndatasize(), shl(96, xor(signer, recovered)))
mstore(0x60, 0) // Restore the zero slot.
mstore(0x40, m) // Restore the free memory pointer.
break
}
let f := shl(224, 0x1626ba7e)
mstore(m, f) // `bytes4(keccak256("isValidSignature(bytes32,bytes)"))`.
mstore(add(m, 0x04), hash)
let d := add(m, 0x24)
mstore(d, 0x40) // The offset of the `signature` in the calldata.
// Copy the `signature` over.
let n := add(0x20, mload(signature))
let copied := staticcall(gas(), 4, signature, n, add(m, 0x44), n)
isValid := staticcall(gas(), signer, m, add(returndatasize(), 0x44), d, 0x20)
isValid := and(eq(mload(d), f), and(isValid, copied))
break
}
}
}
/// @dev Returns whether `signature` is valid for `signer` and `hash`.
/// If `signer.code.length == 0`, then validate with `ecrecover`, else
/// it will validate with ERC1271 on `signer`.
function isValidSignatureNowCalldata(address signer, bytes32 hash, bytes calldata signature)
internal
view
returns (bool isValid)
{
if (signer == address(0)) return isValid;
/// @solidity memory-safe-assembly
assembly {
let m := mload(0x40)
for {} 1 {} {
if iszero(extcodesize(signer)) {
switch signature.length
case 64 {
let vs := calldataload(add(signature.offset, 0x20))
mstore(0x20, add(shr(255, vs), 27)) // `v`.
mstore(0x40, calldataload(signature.offset)) // `r`.
mstore(0x60, shr(1, shl(1, vs))) // `s`.
}
case 65 {
mstore(0x20, byte(0, calldataload(add(signature.offset, 0x40)))) // `v`.
calldatacopy(0x40, signature.offset, 0x40) // `r`, `s`.
}
default { break }
mstore(0x00, hash)
let recovered := mload(staticcall(gas(), 1, 0x00, 0x80, 0x01, 0x20))
isValid := gt(returndatasize(), shl(96, xor(signer, recovered)))
mstore(0x60, 0) // Restore the zero slot.
mstore(0x40, m) // Restore the free memory pointer.
break
}
let f := shl(224, 0x1626ba7e)
mstore(m, f) // `bytes4(keccak256("isValidSignature(bytes32,bytes)"))`.
mstore(add(m, 0x04), hash)
let d := add(m, 0x24)
mstore(d, 0x40) // The offset of the `signature` in the calldata.
mstore(add(m, 0x44), signature.length)
// Copy the `signature` over.
calldatacopy(add(m, 0x64), signature.offset, signature.length)
isValid := staticcall(gas(), signer, m, add(signature.length, 0x64), d, 0x20)
isValid := and(eq(mload(d), f), isValid)
break
}
}
}
/// @dev Returns whether the signature (`r`, `vs`) is valid for `signer` and `hash`.
/// If `signer.code.length == 0`, then validate with `ecrecover`, else
/// it will validate with ERC1271 on `signer`.
function isValidSignatureNow(address signer, bytes32 hash, bytes32 r, bytes32 vs)
internal
view
returns (bool isValid)
{
if (signer == address(0)) return isValid;
/// @solidity memory-safe-assembly
assembly {
let m := mload(0x40)
for {} 1 {} {
if iszero(extcodesize(signer)) {
mstore(0x00, hash)
mstore(0x20, add(shr(255, vs), 27)) // `v`.
mstore(0x40, r) // `r`.
mstore(0x60, shr(1, shl(1, vs))) // `s`.
let recovered := mload(staticcall(gas(), 1, 0x00, 0x80, 0x01, 0x20))
isValid := gt(returndatasize(), shl(96, xor(signer, recovered)))
mstore(0x60, 0) // Restore the zero slot.
mstore(0x40, m) // Restore the free memory pointer.
break
}
let f := shl(224, 0x1626ba7e)
mstore(m, f) // `bytes4(keccak256("isValidSignature(bytes32,bytes)"))`.
mstore(add(m, 0x04), hash)
let d := add(m, 0x24)
mstore(d, 0x40) // The offset of the `signature` in the calldata.
mstore(add(m, 0x44), 65) // Length of the signature.
mstore(add(m, 0x64), r) // `r`.
mstore(add(m, 0x84), shr(1, shl(1, vs))) // `s`.
mstore8(add(m, 0xa4), add(shr(255, vs), 27)) // `v`.
isValid := staticcall(gas(), signer, m, 0xa5, d, 0x20)
isValid := and(eq(mload(d), f), isValid)
break
}
}
}
/// @dev Returns whether the signature (`v`, `r`, `s`) is valid for `signer` and `hash`.
/// If `signer.code.length == 0`, then validate with `ecrecover`, else
/// it will validate with ERC1271 on `signer`.
function isValidSignatureNow(address signer, bytes32 hash, uint8 v, bytes32 r, bytes32 s)
internal
view
returns (bool isValid)
{
if (signer == address(0)) return isValid;
/// @solidity memory-safe-assembly
assembly {
let m := mload(0x40)
for {} 1 {} {
if iszero(extcodesize(signer)) {
mstore(0x00, hash)
mstore(0x20, and(v, 0xff)) // `v`.
mstore(0x40, r) // `r`.
mstore(0x60, s) // `s`.
let recovered := mload(staticcall(gas(), 1, 0x00, 0x80, 0x01, 0x20))
isValid := gt(returndatasize(), shl(96, xor(signer, recovered)))
mstore(0x60, 0) // Restore the zero slot.
mstore(0x40, m) // Restore the free memory pointer.
break
}
let f := shl(224, 0x1626ba7e)
mstore(m, f) // `bytes4(keccak256("isValidSignature(bytes32,bytes)"))`.
mstore(add(m, 0x04), hash)
let d := add(m, 0x24)
mstore(d, 0x40) // The offset of the `signature` in the calldata.
mstore(add(m, 0x44), 65) // Length of the signature.
mstore(add(m, 0x64), r) // `r`.
mstore(add(m, 0x84), s) // `s`.
mstore8(add(m, 0xa4), v) // `v`.
isValid := staticcall(gas(), signer, m, 0xa5, d, 0x20)
isValid := and(eq(mload(d), f), isValid)
break
}
}
}
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* ERC1271 OPERATIONS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
// Note: These ERC1271 operations do NOT have an ECDSA fallback.
/// @dev Returns whether `signature` is valid for `hash` for an ERC1271 `signer` contract.
function isValidERC1271SignatureNow(address signer, bytes32 hash, bytes memory signature)
internal
view
returns (bool isValid)
{
/// @solidity memory-safe-assembly
assembly {
let m := mload(0x40)
let f := shl(224, 0x1626ba7e)
mstore(m, f) // `bytes4(keccak256("isValidSignature(bytes32,bytes)"))`.
mstore(add(m, 0x04), hash)
let d := add(m, 0x24)
mstore(d, 0x40) // The offset of the `signature` in the calldata.
// Copy the `signature` over.
let n := add(0x20, mload(signature))
let copied := staticcall(gas(), 4, signature, n, add(m, 0x44), n)
isValid := staticcall(gas(), signer, m, add(returndatasize(), 0x44), d, 0x20)
isValid := and(eq(mload(d), f), and(isValid, copied))
}
}
/// @dev Returns whether `signature` is valid for `hash` for an ERC1271 `signer` contract.
function isValidERC1271SignatureNowCalldata(
address signer,
bytes32 hash,
bytes calldata signature
) internal view returns (bool isValid) {
/// @solidity memory-safe-assembly
assembly {
let m := mload(0x40)
let f := shl(224, 0x1626ba7e)
mstore(m, f) // `bytes4(keccak256("isValidSignature(bytes32,bytes)"))`.
mstore(add(m, 0x04), hash)
let d := add(m, 0x24)
mstore(d, 0x40) // The offset of the `signature` in the calldata.
mstore(add(m, 0x44), signature.length)
// Copy the `signature` over.
calldatacopy(add(m, 0x64), signature.offset, signature.length)
isValid := staticcall(gas(), signer, m, add(signature.length, 0x64), d, 0x20)
isValid := and(eq(mload(d), f), isValid)
}
}
/// @dev Returns whether the signature (`r`, `vs`) is valid for `hash`
/// for an ERC1271 `signer` contract.
function isValidERC1271SignatureNow(address signer, bytes32 hash, bytes32 r, bytes32 vs)
internal
view
returns (bool isValid)
{
/// @solidity memory-safe-assembly
assembly {
let m := mload(0x40)
let f := shl(224, 0x1626ba7e)
mstore(m, f) // `bytes4(keccak256("isValidSignature(bytes32,bytes)"))`.
mstore(add(m, 0x04), hash)
let d := add(m, 0x24)
mstore(d, 0x40) // The offset of the `signature` in the calldata.
mstore(add(m, 0x44), 65) // Length of the signature.
mstore(add(m, 0x64), r) // `r`.
mstore(add(m, 0x84), shr(1, shl(1, vs))) // `s`.
mstore8(add(m, 0xa4), add(shr(255, vs), 27)) // `v`.
isValid := staticcall(gas(), signer, m, 0xa5, d, 0x20)
isValid := and(eq(mload(d), f), isValid)
}
}
/// @dev Returns whether the signature (`v`, `r`, `s`) is valid for `hash`
/// for an ERC1271 `signer` contract.
function isValidERC1271SignatureNow(address signer, bytes32 hash, uint8 v, bytes32 r, bytes32 s)
internal
view
returns (bool isValid)
{
/// @solidity memory-safe-assembly
assembly {
let m := mload(0x40)
let f := shl(224, 0x1626ba7e)
mstore(m, f) // `bytes4(keccak256("isValidSignature(bytes32,bytes)"))`.
mstore(add(m, 0x04), hash)
let d := add(m, 0x24)
mstore(d, 0x40) // The offset of the `signature` in the calldata.
mstore(add(m, 0x44), 65) // Length of the signature.
mstore(add(m, 0x64), r) // `r`.
mstore(add(m, 0x84), s) // `s`.
mstore8(add(m, 0xa4), v) // `v`.
isValid := staticcall(gas(), signer, m, 0xa5, d, 0x20)
isValid := and(eq(mload(d), f), isValid)
}
}
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* ERC6492 OPERATIONS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
// Note: These ERC6492 operations now include an ECDSA fallback at the very end.
// The calldata variants are excluded for brevity.
/// @dev Returns whether `signature` is valid for `hash`.
/// If the signature is postfixed with the ERC6492 magic number, it will attempt to
/// deploy / prepare the `signer` smart account before doing a regular ERC1271 check.
/// Note: This function is NOT reentrancy safe.
/// The verifier must be deployed.
/// Otherwise, the function will return false if `signer` is not yet deployed / prepared.
/// See: https://gist.github.com/Vectorized/011d6becff6e0a73e42fe100f8d7ef04
/// With a dedicated verifier, this function is safe to use in contracts
/// that have been granted special permissions.
function isValidERC6492SignatureNowAllowSideEffects(
address signer,
bytes32 hash,
bytes memory signature
) internal returns (bool isValid) {
/// @solidity memory-safe-assembly
assembly {
function callIsValidSignature(signer_, hash_, signature_) -> _isValid {
let m_ := mload(0x40)
let f_ := shl(224, 0x1626ba7e)
mstore(m_, f_) // `bytes4(keccak256("isValidSignature(bytes32,bytes)"))`.
mstore(add(m_, 0x04), hash_)
let d_ := add(m_, 0x24)
mstore(d_, 0x40) // The offset of the `signature` in the calldata.
let n_ := add(0x20, mload(signature_))
let copied_ := staticcall(gas(), 4, signature_, n_, add(m_, 0x44), n_)
_isValid := staticcall(gas(), signer_, m_, add(returndatasize(), 0x44), d_, 0x20)
_isValid := and(eq(mload(d_), f_), and(_isValid, copied_))
}
let noCode := iszero(extcodesize(signer))
let n := mload(signature)
for {} 1 {} {
if iszero(eq(mload(add(signature, n)), mul(0x6492, div(not(isValid), 0xffff)))) {
if iszero(noCode) { isValid := callIsValidSignature(signer, hash, signature) }
break
}
if iszero(noCode) {
let o := add(signature, 0x20) // Signature bytes.
isValid := callIsValidSignature(signer, hash, add(o, mload(add(o, 0x40))))
if isValid { break }
}
let m := mload(0x40)
mstore(m, signer)
mstore(add(m, 0x20), hash)
pop(
call(
gas(), // Remaining gas.
0x0000bc370E4DC924F427d84e2f4B9Ec81626ba7E, // Non-reverting verifier.
0, // Send zero ETH.
m, // Start of memory.
add(returndatasize(), 0x40), // Length of calldata in memory.
staticcall(gas(), 4, add(signature, 0x20), n, add(m, 0x40), n), // 1.
0x00 // Length of returndata to write.
)
)
isValid := returndatasize()
break
}
// Do `ecrecover` fallback if `noCode && !isValid`.
for {} gt(noCode, isValid) {} {
switch n
case 64 {
let vs := mload(add(signature, 0x40))
mstore(0x20, add(shr(255, vs), 27)) // `v`.
mstore(0x60, shr(1, shl(1, vs))) // `s`.
}
case 65 {
mstore(0x20, byte(0, mload(add(signature, 0x60)))) // `v`.
mstore(0x60, mload(add(signature, 0x40))) // `s`.
}
default { break }
let m := mload(0x40)
mstore(0x00, hash)
mstore(0x40, mload(add(signature, 0x20))) // `r`.
let recovered := mload(staticcall(gas(), 1, 0x00, 0x80, 0x01, 0x20))
isValid := gt(returndatasize(), shl(96, xor(signer, recovered)))
mstore(0x60, 0) // Restore the zero slot.
mstore(0x40, m) // Restore the free memory pointer.
break
}
}
}
/// @dev Returns whether `signature` is valid for `hash`.
/// If the signature is postfixed with the ERC6492 magic number, it will attempt
/// to use a reverting verifier to deploy / prepare the `signer` smart account
/// and do a `isValidSignature` check via the reverting verifier.
/// Note: This function is reentrancy safe.
/// The reverting verifier must be deployed.
/// Otherwise, the function will return false if `signer` is not yet deployed / prepared.
/// See: https://gist.github.com/Vectorized/846a474c855eee9e441506676800a9ad
function isValidERC6492SignatureNow(address signer, bytes32 hash, bytes memory signature)
internal
returns (bool isValid)
{
/// @solidity memory-safe-assembly
assembly {
function callIsValidSignature(signer_, hash_, signature_) -> _isValid {
let m_ := mload(0x40)
let f_ := shl(224, 0x1626ba7e)
mstore(m_, f_) // `bytes4(keccak256("isValidSignature(bytes32,bytes)"))`.
mstore(add(m_, 0x04), hash_)
let d_ := add(m_, 0x24)
mstore(d_, 0x40) // The offset of the `signature` in the calldata.
let n_ := add(0x20, mload(signature_))
let copied_ := staticcall(gas(), 4, signature_, n_, add(m_, 0x44), n_)
_isValid := staticcall(gas(), signer_, m_, add(returndatasize(), 0x44), d_, 0x20)
_isValid := and(eq(mload(d_), f_), and(_isValid, copied_))
}
let noCode := iszero(extcodesize(signer))
let n := mload(signature)
for {} 1 {} {
if iszero(eq(mload(add(signature, n)), mul(0x6492, div(not(isValid), 0xffff)))) {
if iszero(noCode) { isValid := callIsValidSignature(signer, hash, signature) }
break
}
if iszero(noCode) {
let o := add(signature, 0x20) // Signature bytes.
isValid := callIsValidSignature(signer, hash, add(o, mload(add(o, 0x40))))
if isValid { break }
}
let m := mload(0x40)
mstore(m, signer)
mstore(add(m, 0x20), hash)
let willBeZeroIfRevertingVerifierExists :=
call(
gas(), // Remaining gas.
0x00007bd799e4A591FeA53f8A8a3E9f931626Ba7e, // Reverting verifier.
0, // Send zero ETH.
m, // Start of memory.
add(returndatasize(), 0x40), // Length of calldata in memory.
staticcall(gas(), 4, add(signature, 0x20), n, add(m, 0x40), n), // 1.
0x00 // Length of returndata to write.
)
isValid := gt(returndatasize(), willBeZeroIfRevertingVerifierExists)
break
}
// Do `ecrecover` fallback if `noCode && !isValid`.
for {} gt(noCode, isValid) {} {
switch n
case 64 {
let vs := mload(add(signature, 0x40))
mstore(0x20, add(shr(255, vs), 27)) // `v`.
mstore(0x60, shr(1, shl(1, vs))) // `s`.
}
case 65 {
mstore(0x20, byte(0, mload(add(signature, 0x60)))) // `v`.
mstore(0x60, mload(add(signature, 0x40))) // `s`.
}
default { break }
let m := mload(0x40)
mstore(0x00, hash)
mstore(0x40, mload(add(signature, 0x20))) // `r`.
let recovered := mload(staticcall(gas(), 1, 0x00, 0x80, 0x01, 0x20))
isValid := gt(returndatasize(), shl(96, xor(signer, recovered)))
mstore(0x60, 0) // Restore the zero slot.
mstore(0x40, m) // Restore the free memory pointer.
break
}
}
}
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* HASHING OPERATIONS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev Returns an Ethereum Signed Message, created from a `hash`.
/// This produces a hash corresponding to the one signed with the
/// [`eth_sign`](https://eth.wiki/json-rpc/API#eth_sign)
/// JSON-RPC method as part of EIP-191.
function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32 result) {
/// @solidity memory-safe-assembly
assembly {
mstore(0x20, hash) // Store into scratch space for keccak256.
mstore(0x00, "\x00\x00\x00\x00\x19Ethereum Signed Message:\n32") // 28 bytes.
result := keccak256(0x04, 0x3c) // `32 * 2 - (32 - 28) = 60 = 0x3c`.
}
}
/// @dev Returns an Ethereum Signed Message, created from `s`.
/// This produces a hash corresponding to the one signed with the
/// [`eth_sign`](https://eth.wiki/json-rpc/API#eth_sign)
/// JSON-RPC method as part of EIP-191.
/// Note: Supports lengths of `s` up to 999999 bytes.
function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32 result) {
/// @solidity memory-safe-assembly
assembly {
let sLength := mload(s)
let o := 0x20
mstore(o, "\x19Ethereum Signed Message:\n") // 26 bytes, zero-right-padded.
mstore(0x00, 0x00)
// Convert the `s.length` to ASCII decimal representation: `base10(s.length)`.
for { let temp := sLength } 1 {} {
o := sub(o, 1)
mstore8(o, add(48, mod(temp, 10)))
temp := div(temp, 10)
if iszero(temp) { break }
}
let n := sub(0x3a, o) // Header length: `26 + 32 - o`.
// Throw an out-of-offset error (consumes all gas) if the header exceeds 32 bytes.
returndatacopy(returndatasize(), returndatasize(), gt(n, 0x20))
mstore(s, or(mload(0x00), mload(n))) // Temporarily store the header.
result := keccak256(add(s, sub(0x20, n)), add(n, sLength))
mstore(s, sLength) // Restore the length.
}
}
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* EMPTY CALLDATA HELPERS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev Returns an empty calldata bytes.
function emptySignature() internal pure returns (bytes calldata signature) {
/// @solidity memory-safe-assembly
assembly {
signature.length := 0
}
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;
struct Call {
address to;
bytes data;
uint256 value;
bool allowFailure;
}
struct CallRequest {
Call[] calls;
uint256 nonce;
uint256 expiration;
}
struct CallResult {
bool success;
bytes returnData;
}{
"remappings": [
"solady/=lib/solady/src/",
"forge-std/=lib/forge-std/src/"
],
"optimizer": {
"enabled": false,
"runs": 200
},
"metadata": {
"useLiteralContent": false,
"bytecodeHash": "ipfs",
"appendCBOR": true
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "london",
"viaIR": true,
"libraries": {}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address","name":"_allocator","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AddressCannotBeZero","type":"error"},{"inputs":[],"name":"AlreadyInitialized","type":"error"},{"inputs":[{"internalType":"bytes","name":"returnData","type":"bytes"}],"name":"CallFailed","type":"error"},{"inputs":[],"name":"CallRequestAlreadyUsed","type":"error"},{"inputs":[],"name":"CallRequestExpired","type":"error"},{"inputs":[],"name":"InvalidSignature","type":"error"},{"inputs":[],"name":"NewOwnerIsZeroAddress","type":"error"},{"inputs":[],"name":"NoHandoverRequest","type":"error"},{"inputs":[],"name":"Unauthorized","type":"error"},{"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":false,"internalType":"bytes32","name":"id","type":"bytes32"},{"components":[{"internalType":"address","name":"to","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"bool","name":"allowFailure","type":"bool"}],"indexed":false,"internalType":"struct Call","name":"call","type":"tuple"}],"name":"RelayCallExecuted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"id","type":"bytes32"}],"name":"RelayErc20Deposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"id","type":"bytes32"}],"name":"RelayNativeDeposit","type":"event"},{"inputs":[],"name":"_CALL_REQUEST_TYPEHASH","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_CALL_TYPEHASH","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"allocator","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"callRequests","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","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":"address","name":"depositor","type":"address"},{"internalType":"address","name":"token","type":"address"},{"internalType":"bytes32","name":"id","type":"bytes32"}],"name":"depositErc20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"depositor","type":"address"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes32","name":"id","type":"bytes32"}],"name":"depositErc20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"depositor","type":"address"},{"internalType":"bytes32","name":"id","type":"bytes32"}],"name":"depositNative","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"eip712Domain","outputs":[{"internalType":"bytes1","name":"fields","type":"bytes1"},{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"version","type":"string"},{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"address","name":"verifyingContract","type":"address"},{"internalType":"bytes32","name":"salt","type":"bytes32"},{"internalType":"uint256[]","name":"extensions","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"components":[{"internalType":"address","name":"to","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"bool","name":"allowFailure","type":"bool"}],"internalType":"struct Call[]","name":"calls","type":"tuple[]"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint256","name":"expiration","type":"uint256"}],"internalType":"struct CallRequest","name":"request","type":"tuple"},{"internalType":"bytes","name":"signature","type":"bytes"}],"name":"execute","outputs":[{"components":[{"internalType":"bool","name":"success","type":"bool"},{"internalType":"bytes","name":"returnData","type":"bytes"}],"internalType":"struct CallResult[]","name":"results","type":"tuple[]"}],"stateMutability":"nonpayable","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":[],"name":"renounceOwnership","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"requestOwnershipHandover","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_allocator","type":"address"}],"name":"setAllocator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"payable","type":"function"}]Contract Creation Code
6101206040523461005f5761001b610015610139565b906101d6565b610023610064565b6122496105608239608051816120f8015260a051816120d7015260c051816121ce015260e051816121ef01526101005181612077015261224990f35b61006a565b60405190565b600080fd5b601f801991011690565b634e487b7160e01b600052604160045260246000fd5b906100999061006f565b810190811060018060401b038211176100b157604052565b610079565b906100c96100c2610064565b928361008f565b565b600080fd5b60018060a01b031690565b6100e4906100d0565b90565b6100f0816100db565b036100f757565b600080fd5b90505190610109826100e7565b565b9190604083820312610134578061012861013192600086016100fc565b936020016100fc565b90565b6100cb565b6101576127a98038038061014c816100b6565b92833981019061010b565b9091565b60001b90565b9061017260018060a01b039161015b565b9181191691161790565b90565b61019361018e610198926100d0565b61017c565b6100d0565b90565b6101a49061017f565b90565b6101b09061019b565b90565b90565b906101cb6101c66101d2926101a7565b6101b3565b8254610161565b9055565b906101eb6101f2926101e6610269565b6103b2565b60016101b6565b565b6101fd9061019b565b90565b6102099061017f565b90565b90565b61022361021e610228926100d0565b61017c565b61020c565b90565b606090565b151590565b90565b60200190565b5190565b90565b90565b61025c61025761026192610242565b61015b565b610245565b90565b600090565b61028261027d610278306101f4565b610200565b61020f565b6080524660a05261029161022b565b61029961022b565b906102ab6102a5610453565b15610230565b6103a2575b6102b8610453565b60001461038157506102ca6000610248565b5b906102d4610453565b60001461036057506102e66000610248565b5b908060c0528160e0526102f8610264565b9161030a610304610453565b15610230565b610317575b505061010052565b60a09250604051917f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f83526020830152604082015246606082015230608082015220388061030f565b61036990610235565b61037b6103758261023e565b91610238565b206102e7565b61038a90610235565b61039c6103968261023e565b91610238565b206102cb565b50506103ac61052e565b906102b0565b6103ba610554565b60001461041557638b78c6d8199081546104075760601b60601c90811560ff1b8217905560007f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08180a35b565b630dc149f06000526004601cfd5b60601b60601c80638b78c6d8195560007f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08180a3610405565b600090565b61045b61044e565b90565b60018060401b03811161047a5761047660209161006f565b0190565b610079565b9061049161048c8361045e565b6100b6565b918252565b60007f52656c61794465706f7369746f72790000000000000000000000000000000000910152565b6104c8600f61047f565b906104d560208301610496565b565b6104df6104be565b90565b60007f3100000000000000000000000000000000000000000000000000000000000000910152565b610514600161047f565b90610521602083016104e2565b565b61052b61050a565b90565b61053661022b565b5061053f61022b565b506105486104d7565b90610551610523565b90565b61055c61044e565b9056fe60806040526004361015610013575b610bb7565b61001e60003561012d565b806325692962146101285780632d9fb4781461012357806349290c1c1461011e57806354d1f13d146101195780635a1ee3ac14610114578063715018a61461010f57806384b0196e1461010a5780638da5cb5b14610105578063aa5dcecc14610100578063bf83f2a2146100fb578063cf5905d7146100f6578063d52bfcc8146100f1578063e8017952146100ec578063eae335b3146100e7578063f04e283e146100e2578063f2fde38b146100dd5763fee81cf40361000e57610b82565b610b43565b610b1a565b610ae5565b610a7f565b6109df565b6108fe565b610886565b610832565b6107b8565b610766565b6105c1565b61058d565b610529565b6104ff565b610439565b610154565b60e01c90565b60405190565b600080fd5b600091031261014957565b610139565b60000190565b61015f36600461013e565b610167610bf6565b61016f610133565b806101798161014e565b0390f35b600080fd5b600080fd5b600080fd5b9081606091031261019a5790565b610187565b600080fd5b600080fd5b601f801991011690565b634e487b7160e01b600052604160045260246000fd5b906101d3906101a9565b810190811067ffffffffffffffff8211176101ed57604052565b6101b3565b906102056101fe610133565b92836101c9565b565b67ffffffffffffffff8111610225576102216020916101a9565b0190565b6101b3565b90826000939282370152565b9092919261024b61024682610207565b6101f2565b93818552602085019082840111610267576102659261022a565b565b6101a4565b9080601f8301121561028a5781602061028793359101610236565b90565b61019f565b9190916040818403126102e857600081013567ffffffffffffffff81116102e357836102bc91830161018c565b92602082013567ffffffffffffffff81116102de576102db920161026c565b90565b610182565b610182565b610139565b5190565b60209181520190565b60200190565b151590565b61030e90610300565b9052565b5190565b60209181520190565b60005b838110610333575050906000910152565b806020918301518185015201610322565b61036361036c6020936103719361035a81610312565b93848093610316565b9586910161031f565b6101a9565b0190565b6103a2916020604082019261039260008201516000850190610305565b0151906020818403910152610344565b90565b906103af91610375565b90565b60200190565b906103cc6103c5836102ed565b80926102f1565b90816103dd602083028401946102fa565b926000915b8383106103f157505050505090565b9091929394602061041361040d838560019503875289516103a5565b976103b2565b93019301919392906103e2565b61043691602082019160008184039101526103b8565b90565b3461046a5761046661045561044f36600461028f565b90610d45565b61045d610133565b91829182610420565b0390f35b61017d565b60018060a01b031690565b6104839061046f565b90565b61048f8161047a565b0361049657565b600080fd5b905035906104a882610486565b565b90565b6104b6816104aa565b036104bd57565b600080fd5b905035906104cf826104ad565b565b91906040838203126104fa57806104ee6104f7926000860161049b565b936020016104c2565b90565b610139565b61051361050d3660046104d1565b90610ea0565b61051b610133565b806105258161014e565b0390f35b61053436600461013e565b61053c610f0b565b610544610133565b8061054e8161014e565b0390f35b90916060828403126105885761058561056e846000850161049b565b9361057c816020860161049b565b936040016104c2565b90565b610139565b346105bc576105a66105a0366004610552565b91611008565b6105ae610133565b806105b88161014e565b0390f35b61017d565b6105cc36600461013e565b6105d46110d0565b6105dc610133565b806105e68161014e565b0390f35b60ff60f81b1690565b6105fc906105ea565b9052565b5190565b60209181520190565b61062c61063560209361063a9361062381610600565b93848093610604565b9586910161031f565b6101a9565b0190565b90565b61064a9061063e565b9052565b6106579061047a565b9052565b610664906104aa565b9052565b5190565b60209181520190565b60200190565b6106849061063e565b9052565b906106958160209361067b565b0190565b60200190565b906106bc6106b66106af84610668565b809361066c565b92610675565b9060005b8181106106cd5750505090565b9091926106e66106e06001928651610688565b94610699565b91019190916106c0565b939591946107426107376107569561072961074c956107639c9a61071c60e08c019260008d01906105f3565b8a820360208c015261060d565b9088820360408a015261060d565b976060870190610641565b608085019061064e565b60a083019061065b565b60c081840391015261069f565b90565b3461079d5761077636600461013e565b61079961078161110c565b93610790979597939193610133565b978897886106f0565b0390f35b61017d565b91906107b69060006020850194019061064e565b565b346107e8576107c836600461013e565b6107e46107d361116e565b6107db610133565b918291826107a2565b0390f35b61017d565b1c90565b60018060a01b031690565b61080c90600861081193026107ed565b6107f1565b90565b9061081f91546107fc565b90565b61082f6001600090610814565b90565b346108625761084236600461013e565b61085e61084d610822565b610855610133565b918291826107a2565b0390f35b61017d565b906020828203126108815761087e9160000161049b565b90565b610139565b346108b45761089e610899366004610867565b611229565b6108a6610133565b806108b08161014e565b0390f35b61017d565b7fd5395b56326912498477b4b3e987bcd306e0ea8d9f9e41e3563c6176a7bc2f6590565b6108e56108b9565b90565b91906108fc9060006020850194019061065b565b565b3461092e5761090e36600461013e565b61092a6109196108dd565b610921610133565b918291826108e8565b0390f35b61017d565b9060208282031261094d5761094a916000016104c2565b90565b610139565b61095b906104aa565b90565b9061096890610952565b600052602052604060002090565b60ff1690565b61098c90600861099193026107ed565b610976565b90565b9061099f915461097c565b90565b6109b9906109b460009160009261095e565b610994565b90565b6109c590610300565b9052565b91906109dd906000602085019401906109bc565b565b34610a0f57610a0b6109fa6109f5366004610933565b6109a2565b610a02610133565b918291826109c9565b0390f35b61017d565b610a1d8161063e565b03610a2457565b600080fd5b90503590610a3682610a14565b565b608081830312610a7a57610a4f826000830161049b565b92610a77610a60846020850161049b565b93610a6e8160408601610a29565b936060016104c2565b90565b610139565b34610ab157610a9b610a92366004610a38565b92919091611273565b610aa3610133565b80610aad8161014e565b0390f35b61017d565b7f1dcae8e357e31cf00a7777284e6f769bb6d19654688c9665de5fea6f35f5357c90565b610ae2610ab6565b90565b34610b1557610af536600461013e565b610b11610b00610ada565b610b08610133565b918291826108e8565b0390f35b61017d565b610b2d610b28366004610867565b611340565b610b35610133565b80610b3f8161014e565b0390f35b610b56610b51366004610867565b611380565b610b5e610133565b80610b688161014e565b0390f35b9190610b8090600060208501940190610641565b565b34610bb257610bae610b9d610b98366004610867565b61138b565b610ba5610133565b91829182610b6c565b0390f35b61017d565b600080fd5b67ffffffffffffffff1690565b90565b610be0610bdb610be592610bbc565b610bc9565b61063e565b90565b90610bf3910161063e565b90565b610c1042610c0a610c056113cc565b610bcc565b90610be8565b63389a75e1600c52336000526020600c2055337fdbf36a107da19e49527a7176a1babf963b4b0ff8cde35ee35d6cd8f1f9ac7e1d600080a2565b606090565b35610c5981610a14565b90565b60001c90565b610c6e610c7391610c5c565b6107f1565b90565b610c809054610c62565b90565b610c8f610c9491610c5c565b610976565b90565b610ca19054610c83565b90565b60001b90565b90610cb660ff91610ca4565b9181191691161790565b610cc990610300565b90565b90565b90610ce4610cdf610ceb92610cc0565b610ccc565b8254610caa565b9055565b600080fd5b600080fd5b600080fd5b903590600160200381360303821215610d40570180359067ffffffffffffffff8211610d3b57602001916020820236038313610d3657565b610cf9565b610cf4565b610cef565b610d4d610c4a565b50610d5781611699565b92909290610d6760408401610c4f565b610d79610d734261063e565b9161063e565b10610e2557610d9e91610d9891610d906001610c76565b9190916118c9565b15610300565b610e0857610db6610db16000849061095e565b610c97565b610deb57610de2610de892610dd76001610dd26000849061095e565b610ccf565b916000810190610cfe565b91611cba565b90565b6000630929056560e31b815280610e046004820161014e565b0390fd5b6000638baa579f60e01b815280610e216004820161014e565b0390fd5b600063345c526d60e11b815280610e3e6004820161014e565b0390fd5b90565b610e59610e54610e5e92610e42565b610bc9565b61046f565b90565b610e6a90610e45565b90565b604090610e97610e9e9496959396610e8d6060840198600085019061064e565b6020830190610641565b019061065b565b565b80610ebc610eb6610eb16000610e61565b61047a565b9161047a565b14600014610f065750335b90349091610f017f8032066556caf3967d8fec4ad22a2d9e1e9576556b2903a0fcd5b1fd201e347793610ef8610133565b93849384610e6d565b0390a1565b610ec7565b63389a75e1600c523360005260006020600c2055337ffa7b8eab7da67f412cc9575ed43464468f9bfbae89d1675917346ca6d8fe3c92600080a2565b610f5b610f56610f609261046f565b610bc9565b61046f565b90565b610f6c90610f47565b90565b610f7890610f63565b90565b610f8490610f47565b90565b610f9090610f7b565b90565b610f9c90610f7b565b90565b60e01b90565b90505190610fb282610a14565b565b90602082820312610fce57610fcb91600001610fa5565b90565b610139565b916020610ff5929493610fee6040820196600083019061064e565b019061064e565b565b610fff610133565b3d6000823e3d90fd5b9161101a61101583610f6f565b610f87565b92602063dd62ed3e94339061104961103130610f93565b9761105461103d610133565b998a9586948594610f9f565b845260048401610fd3565b03915afa80156110a55761107594600091611077575b509092909192611273565b565b611098915060203d811161109e575b61109081836101c9565b810190610fb4565b3861106a565b503d611086565b610ff7565b6110b2611e32565b6110ba6110bc565b565b6110ce6110c96000610e61565b611e4f565b565b6110d86110aa565b565b600090565b606090565b600090565b600090565b600090565b606090565b600f60f81b90565b61110990610f7b565b90565b6111146110da565b5061111d6110df565b506111266110df565b5061112f6110e4565b506111386110e9565b506111416110ee565b6111496110f3565b906111526110f8565b9261115b611fac565b929093469261116930611100565b929190565b6111766110e9565b50638b78c6d8195490565b6111929061118d611e32565b6111de565b565b906111a560018060a01b0391610ca4565b9181191691161790565b6111b890610f7b565b90565b90565b906111d36111ce6111da926111af565b6111bb565b8254611194565b9055565b806111fa6111f46111ef6000610e61565b61047a565b9161047a565b1461120c5761120a9060016111be565b565b60006303988b8160e61b8152806112256004820161014e565b0390fd5b61123290611181565b565b61126a61127194611260606094989795611256608086019a600087019061064e565b602085019061064e565b6040830190610641565b019061065b565b565b611289823361128130610f93565b908692611fd2565b806112a561129f61129a6000610e61565b61047a565b9161047a565b146000146112ee57506112e9335b9192937f49fed1d0b752ce30eee63c7a81133f3363b532fec5d4d7dd1ccfd005de4555e1946112e0610133565b94859485611234565b0390a1565b6112e9906112b3565b61130890611303611e32565b61130a565b565b63389a75e1600c52806000526020600c2090815442116113325760006113309255611e4f565b565b636f5e88186000526004601cfd5b611349906112f7565b565b61135c90611357611e32565b61135e565b565b8060601b156113725761137090611e4f565b565b637448fbae6000526004601cfd5b6113899061134b565b565b6113936110e4565b5063389a75e1600c526000526020600c205490565b600090565b90565b6113c46113bf6113c9926113ad565b610bc9565b610bbc565b90565b6113d46113a8565b506113e16202a3006113b0565b90565b5090565b67ffffffffffffffff81116114005760208091020190565b6101b3565b90611417611412836113e8565b6101f2565b918252565b369037565b9061144661142e83611405565b9260208061143c86936113e8565b920191039061141c565b565b61145c61145761146192610e42565b610bc9565b61063e565b90565b6001611470910161063e565b90565b634e487b7160e01b600052603260045260246000fd5b9035906001608003813603038212156114a0570190565b610cef565b908210156114bf5760206114bc9202810190611489565b90565b611473565b356114ce81610486565b90565b903590600160200381360303821215611513570180359067ffffffffffffffff821161150e5760200191600182023603831361150957565b610cf9565b610cf4565b610cef565b611523913691610236565b90565b60200190565b61153581610300565b0361153c57565b600080fd5b3561154b8161152c565b90565b9095949261159a946115896115939261157f60809661157560a088019c600089019061065b565b602087019061064e565b604085019061065b565b6060830190610641565b01906109bc565b565b5190565b906115aa8261159c565b8110156115bb576020809102010190565b611473565b906115ca906104aa565b9052565b905090565b60200190565b6115e2906104aa565b9052565b906115f3816020936115d9565b0190565b60200190565b9061161a61161461160d8461159c565b80936115ce565b926115d3565b9060005b81811061162b5750505090565b90919261164461163e60019286516115e6565b946115f7565b910191909161161e565b611657916115fd565b90565b6116906116979461168660609498979561167c608086019a600087019061065b565b602085019061065b565b6040830190610641565b0190610641565b565b906116a26110ee565b506116ab6110ee565b506116cb6116c66116c0846000810190610cfe565b906113e4565b611421565b916116d66000611448565b5b806117006116fa6116f56116ef866000810190610cfe565b906113e4565b61063e565b9161063e565b1015611818576118139061180e6117156108b9565b6117e961173a600061173461172d8983810190610cfe565b88916114a5565b016114c4565b916117da61176c61176661175c6117558b6000810190610cfe565b8a916114a5565b60208101906114d1565b90611518565b61177e61177882610312565b91611526565b206117a2604061179c6117958c6000810190610cfe565b8b916114a5565b01610c4f565b6117c560606117bf6117b88d6000810190610cfe565b8c916114a5565b01611541565b916117ce610133565b9687956020870161154e565b602082018103825203826101c9565b6117fb6117f582610312565b91611526565b2061180987918490926115a0565b6115c0565b611464565b6116d7565b5090916118a490611895611845611854611830610ab6565b93611839610133565b9283916020830161164e565b602082018103825203826101c9565b61186661186082610312565b91611526565b2093611880604061187960208401610c4f565b9201610c4f565b90611889610133565b9586946020860161165a565b602082018103825203826101c9565b6118b66118b082610312565b91611526565b20906118c182612035565b90565b600090565b916118d26118c4565b90836118ef6118e96118e46000610e61565b61047a565b9161047a565b146119c15760405191843b1561193f5750602090631626ba7e60e01b9384845260048401526024830194859160408352805184019081604487019160045afa9360443d01915afa1691511416905b565b9493919281518060401461199e5760411461195d575050505061193d565b602092939550606082015160001a835260408201516060525b60005201516040526020600160806000825afa511860601b3d1191600060605260405261193d565b506020929395506040820151601b8160ff1c01845260011b60011c606052611976565b5091505090565b67ffffffffffffffff81116119e05760208091020190565b6101b3565b906119f76119f2836119c8565b6101f2565b918252565b611a0660406101f2565b90565b600090565b606090565b611a1b6119fc565b9060208083611a28611a09565b815201611a33611a0e565b81525050565b611a41611a13565b90565b60005b828110611a5357505050565b602090611a5e611a39565b8184015201611a47565b90611a8d611a75836119e5565b92602080611a8386936119c8565b9201910390611a44565b565b600080fd5b600080fd5b90503590611aa68261152c565b565b919091608081840312611b2157611abf60806101f2565b92611acd816000840161049b565b600085015260208201359167ffffffffffffffff8311611b1c57611af682611b1594830161026c565b6020860152611b088260408301610a29565b6040860152606001611a99565b6060830152565b611a94565b611a8f565b611b31903690611aa8565b90565b611b3e905161047a565b90565b611b4b905161063e565b90565b90611b60611b5b83610207565b6101f2565b918252565b606090565b3d600014611b8757611b7b3d611b4e565b903d6000602084013e5b565b611b8f611b65565b90611b85565b611b9f9051610300565b90565b60209181520190565b611bca611bd3602093611bd893611bc181610312565b93848093611ba2565b9586910161031f565b6101a9565b0190565b611bf29160208201916000818403910152611bab565b90565b611bff60406101f2565b90565b90611c0c90610300565b9052565b52565b90611c1d826102ed565b811015611c2e576020809102010190565b611473565b611c3c9061047a565b9052565b90611c9090606080611c7360808401611c6160008801516000870190611c33565b60208701518582036020870152610344565b94611c866040820151604086019061067b565b0151910190610305565b90565b91611cb792611caa6040820193600083019061065b565b6020818403910152611c40565b90565b9091611cc4610c4a565b50611cd08382906113e4565b92611cda84611a68565b94611ce36110e4565b5b80611cf7611cf18861063e565b9161063e565b1015611e2a57611d11611d0c848684916114a5565b611b26565b600080611d1f818401611b34565b611d2b60408501611b41565b602085015190602082019151925af1611d42611b6a565b611d4c8215610300565b80611e0f575b611de95790611d96611da3949392611d838391611d7a611d70611bf5565b9360008501611c02565b60208301611c10565b8b8591611d908383611c13565b52611c13565b5150611da8575b50611464565b611ce4565b86907f4be109453ef7e895dc7215c929fff9b76b51483d56a4d04548b4866e9aa7c5ea91611de0611dd7610133565b92839283611c93565b0390a138611d9d565b611e0b90611df5610133565b91829163a5fa8d2b60e01b835260048301611bdc565b0390fd5b50611e25611e1f60608501611b95565b15610300565b611d52565b509350505050565b638b78c6d819543303611e4157565b6382b429006000526004601cfd5b611e576120b6565b600014611e9e57638b78c6d8199060601b60601c8082547f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a3801560ff1b1790555b565b638b78c6d8199060601b60601c908181547f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a355611e9c565b67ffffffffffffffff8111611ef857611ef46020916101a9565b0190565b6101b3565b90611f0f611f0a83611eda565b6101f2565b918252565b60007f52656c61794465706f7369746f72790000000000000000000000000000000000910152565b611f46600f611efd565b90611f5360208301611f14565b565b611f5d611f3c565b90565b60007f3100000000000000000000000000000000000000000000000000000000000000910152565b611f926001611efd565b90611f9f60208301611f60565b565b611fa9611f88565b90565b611fb46110df565b50611fbd6110df565b50611fc6611f55565b90611fcf611fa1565b90565b916040519360605260405260601b602c526323b872dd60601b600c52602060006064601c82855af190816001600051141615612015575b50506000606052604052565b3d903b15171015612027573880612009565b637939f4246000526004601cfd5b61203d6110ee565b506120466120c1565b60001461207557612055612124565b5b671901000000000000600052601a52603a526042601820906000603a52565b7f000000000000000000000000000000000000000000000000000000000000000061209e6120cc565b6120a8575b612056565b506120b1612124565b6120a3565b6120be6118c4565b90565b6120c96118c4565b90565b6120d46118c4565b507f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000003014904614161590565b90565b61212c6110ee565b506121356110ee565b5061213e6120c1565b6000146121ca5760a061215c612175612155611fac565b9290612121565b61216e61216882610312565b91611526565b2091612121565b61218761218182610312565b91611526565b205b604051917f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f8352602083015260408201524660608201523060808201522090565b60a07f00000000000000000000000000000000000000000000000000000000000000007f000000000000000000000000000000000000000000000000000000000000000061218956fea26469706673582212208eff6eb8193b46250a4616f0ae85c9dee5fa898df6306dfd010066a96bcabaad64736f6c634300081c0033000000000000000000000000f3d63166f0ca56c3c1a3508fce03ff0cf3fb691e00000000000000000000000051203c6be98052fb6d7fe1333ee6859b90d21cdf
Deployed Bytecode
0x60806040526004361015610013575b610bb7565b61001e60003561012d565b806325692962146101285780632d9fb4781461012357806349290c1c1461011e57806354d1f13d146101195780635a1ee3ac14610114578063715018a61461010f57806384b0196e1461010a5780638da5cb5b14610105578063aa5dcecc14610100578063bf83f2a2146100fb578063cf5905d7146100f6578063d52bfcc8146100f1578063e8017952146100ec578063eae335b3146100e7578063f04e283e146100e2578063f2fde38b146100dd5763fee81cf40361000e57610b82565b610b43565b610b1a565b610ae5565b610a7f565b6109df565b6108fe565b610886565b610832565b6107b8565b610766565b6105c1565b61058d565b610529565b6104ff565b610439565b610154565b60e01c90565b60405190565b600080fd5b600091031261014957565b610139565b60000190565b61015f36600461013e565b610167610bf6565b61016f610133565b806101798161014e565b0390f35b600080fd5b600080fd5b600080fd5b9081606091031261019a5790565b610187565b600080fd5b600080fd5b601f801991011690565b634e487b7160e01b600052604160045260246000fd5b906101d3906101a9565b810190811067ffffffffffffffff8211176101ed57604052565b6101b3565b906102056101fe610133565b92836101c9565b565b67ffffffffffffffff8111610225576102216020916101a9565b0190565b6101b3565b90826000939282370152565b9092919261024b61024682610207565b6101f2565b93818552602085019082840111610267576102659261022a565b565b6101a4565b9080601f8301121561028a5781602061028793359101610236565b90565b61019f565b9190916040818403126102e857600081013567ffffffffffffffff81116102e357836102bc91830161018c565b92602082013567ffffffffffffffff81116102de576102db920161026c565b90565b610182565b610182565b610139565b5190565b60209181520190565b60200190565b151590565b61030e90610300565b9052565b5190565b60209181520190565b60005b838110610333575050906000910152565b806020918301518185015201610322565b61036361036c6020936103719361035a81610312565b93848093610316565b9586910161031f565b6101a9565b0190565b6103a2916020604082019261039260008201516000850190610305565b0151906020818403910152610344565b90565b906103af91610375565b90565b60200190565b906103cc6103c5836102ed565b80926102f1565b90816103dd602083028401946102fa565b926000915b8383106103f157505050505090565b9091929394602061041361040d838560019503875289516103a5565b976103b2565b93019301919392906103e2565b61043691602082019160008184039101526103b8565b90565b3461046a5761046661045561044f36600461028f565b90610d45565b61045d610133565b91829182610420565b0390f35b61017d565b60018060a01b031690565b6104839061046f565b90565b61048f8161047a565b0361049657565b600080fd5b905035906104a882610486565b565b90565b6104b6816104aa565b036104bd57565b600080fd5b905035906104cf826104ad565b565b91906040838203126104fa57806104ee6104f7926000860161049b565b936020016104c2565b90565b610139565b61051361050d3660046104d1565b90610ea0565b61051b610133565b806105258161014e565b0390f35b61053436600461013e565b61053c610f0b565b610544610133565b8061054e8161014e565b0390f35b90916060828403126105885761058561056e846000850161049b565b9361057c816020860161049b565b936040016104c2565b90565b610139565b346105bc576105a66105a0366004610552565b91611008565b6105ae610133565b806105b88161014e565b0390f35b61017d565b6105cc36600461013e565b6105d46110d0565b6105dc610133565b806105e68161014e565b0390f35b60ff60f81b1690565b6105fc906105ea565b9052565b5190565b60209181520190565b61062c61063560209361063a9361062381610600565b93848093610604565b9586910161031f565b6101a9565b0190565b90565b61064a9061063e565b9052565b6106579061047a565b9052565b610664906104aa565b9052565b5190565b60209181520190565b60200190565b6106849061063e565b9052565b906106958160209361067b565b0190565b60200190565b906106bc6106b66106af84610668565b809361066c565b92610675565b9060005b8181106106cd5750505090565b9091926106e66106e06001928651610688565b94610699565b91019190916106c0565b939591946107426107376107569561072961074c956107639c9a61071c60e08c019260008d01906105f3565b8a820360208c015261060d565b9088820360408a015261060d565b976060870190610641565b608085019061064e565b60a083019061065b565b60c081840391015261069f565b90565b3461079d5761077636600461013e565b61079961078161110c565b93610790979597939193610133565b978897886106f0565b0390f35b61017d565b91906107b69060006020850194019061064e565b565b346107e8576107c836600461013e565b6107e46107d361116e565b6107db610133565b918291826107a2565b0390f35b61017d565b1c90565b60018060a01b031690565b61080c90600861081193026107ed565b6107f1565b90565b9061081f91546107fc565b90565b61082f6001600090610814565b90565b346108625761084236600461013e565b61085e61084d610822565b610855610133565b918291826107a2565b0390f35b61017d565b906020828203126108815761087e9160000161049b565b90565b610139565b346108b45761089e610899366004610867565b611229565b6108a6610133565b806108b08161014e565b0390f35b61017d565b7fd5395b56326912498477b4b3e987bcd306e0ea8d9f9e41e3563c6176a7bc2f6590565b6108e56108b9565b90565b91906108fc9060006020850194019061065b565b565b3461092e5761090e36600461013e565b61092a6109196108dd565b610921610133565b918291826108e8565b0390f35b61017d565b9060208282031261094d5761094a916000016104c2565b90565b610139565b61095b906104aa565b90565b9061096890610952565b600052602052604060002090565b60ff1690565b61098c90600861099193026107ed565b610976565b90565b9061099f915461097c565b90565b6109b9906109b460009160009261095e565b610994565b90565b6109c590610300565b9052565b91906109dd906000602085019401906109bc565b565b34610a0f57610a0b6109fa6109f5366004610933565b6109a2565b610a02610133565b918291826109c9565b0390f35b61017d565b610a1d8161063e565b03610a2457565b600080fd5b90503590610a3682610a14565b565b608081830312610a7a57610a4f826000830161049b565b92610a77610a60846020850161049b565b93610a6e8160408601610a29565b936060016104c2565b90565b610139565b34610ab157610a9b610a92366004610a38565b92919091611273565b610aa3610133565b80610aad8161014e565b0390f35b61017d565b7f1dcae8e357e31cf00a7777284e6f769bb6d19654688c9665de5fea6f35f5357c90565b610ae2610ab6565b90565b34610b1557610af536600461013e565b610b11610b00610ada565b610b08610133565b918291826108e8565b0390f35b61017d565b610b2d610b28366004610867565b611340565b610b35610133565b80610b3f8161014e565b0390f35b610b56610b51366004610867565b611380565b610b5e610133565b80610b688161014e565b0390f35b9190610b8090600060208501940190610641565b565b34610bb257610bae610b9d610b98366004610867565b61138b565b610ba5610133565b91829182610b6c565b0390f35b61017d565b600080fd5b67ffffffffffffffff1690565b90565b610be0610bdb610be592610bbc565b610bc9565b61063e565b90565b90610bf3910161063e565b90565b610c1042610c0a610c056113cc565b610bcc565b90610be8565b63389a75e1600c52336000526020600c2055337fdbf36a107da19e49527a7176a1babf963b4b0ff8cde35ee35d6cd8f1f9ac7e1d600080a2565b606090565b35610c5981610a14565b90565b60001c90565b610c6e610c7391610c5c565b6107f1565b90565b610c809054610c62565b90565b610c8f610c9491610c5c565b610976565b90565b610ca19054610c83565b90565b60001b90565b90610cb660ff91610ca4565b9181191691161790565b610cc990610300565b90565b90565b90610ce4610cdf610ceb92610cc0565b610ccc565b8254610caa565b9055565b600080fd5b600080fd5b600080fd5b903590600160200381360303821215610d40570180359067ffffffffffffffff8211610d3b57602001916020820236038313610d3657565b610cf9565b610cf4565b610cef565b610d4d610c4a565b50610d5781611699565b92909290610d6760408401610c4f565b610d79610d734261063e565b9161063e565b10610e2557610d9e91610d9891610d906001610c76565b9190916118c9565b15610300565b610e0857610db6610db16000849061095e565b610c97565b610deb57610de2610de892610dd76001610dd26000849061095e565b610ccf565b916000810190610cfe565b91611cba565b90565b6000630929056560e31b815280610e046004820161014e565b0390fd5b6000638baa579f60e01b815280610e216004820161014e565b0390fd5b600063345c526d60e11b815280610e3e6004820161014e565b0390fd5b90565b610e59610e54610e5e92610e42565b610bc9565b61046f565b90565b610e6a90610e45565b90565b604090610e97610e9e9496959396610e8d6060840198600085019061064e565b6020830190610641565b019061065b565b565b80610ebc610eb6610eb16000610e61565b61047a565b9161047a565b14600014610f065750335b90349091610f017f8032066556caf3967d8fec4ad22a2d9e1e9576556b2903a0fcd5b1fd201e347793610ef8610133565b93849384610e6d565b0390a1565b610ec7565b63389a75e1600c523360005260006020600c2055337ffa7b8eab7da67f412cc9575ed43464468f9bfbae89d1675917346ca6d8fe3c92600080a2565b610f5b610f56610f609261046f565b610bc9565b61046f565b90565b610f6c90610f47565b90565b610f7890610f63565b90565b610f8490610f47565b90565b610f9090610f7b565b90565b610f9c90610f7b565b90565b60e01b90565b90505190610fb282610a14565b565b90602082820312610fce57610fcb91600001610fa5565b90565b610139565b916020610ff5929493610fee6040820196600083019061064e565b019061064e565b565b610fff610133565b3d6000823e3d90fd5b9161101a61101583610f6f565b610f87565b92602063dd62ed3e94339061104961103130610f93565b9761105461103d610133565b998a9586948594610f9f565b845260048401610fd3565b03915afa80156110a55761107594600091611077575b509092909192611273565b565b611098915060203d811161109e575b61109081836101c9565b810190610fb4565b3861106a565b503d611086565b610ff7565b6110b2611e32565b6110ba6110bc565b565b6110ce6110c96000610e61565b611e4f565b565b6110d86110aa565b565b600090565b606090565b600090565b600090565b600090565b606090565b600f60f81b90565b61110990610f7b565b90565b6111146110da565b5061111d6110df565b506111266110df565b5061112f6110e4565b506111386110e9565b506111416110ee565b6111496110f3565b906111526110f8565b9261115b611fac565b929093469261116930611100565b929190565b6111766110e9565b50638b78c6d8195490565b6111929061118d611e32565b6111de565b565b906111a560018060a01b0391610ca4565b9181191691161790565b6111b890610f7b565b90565b90565b906111d36111ce6111da926111af565b6111bb565b8254611194565b9055565b806111fa6111f46111ef6000610e61565b61047a565b9161047a565b1461120c5761120a9060016111be565b565b60006303988b8160e61b8152806112256004820161014e565b0390fd5b61123290611181565b565b61126a61127194611260606094989795611256608086019a600087019061064e565b602085019061064e565b6040830190610641565b019061065b565b565b611289823361128130610f93565b908692611fd2565b806112a561129f61129a6000610e61565b61047a565b9161047a565b146000146112ee57506112e9335b9192937f49fed1d0b752ce30eee63c7a81133f3363b532fec5d4d7dd1ccfd005de4555e1946112e0610133565b94859485611234565b0390a1565b6112e9906112b3565b61130890611303611e32565b61130a565b565b63389a75e1600c52806000526020600c2090815442116113325760006113309255611e4f565b565b636f5e88186000526004601cfd5b611349906112f7565b565b61135c90611357611e32565b61135e565b565b8060601b156113725761137090611e4f565b565b637448fbae6000526004601cfd5b6113899061134b565b565b6113936110e4565b5063389a75e1600c526000526020600c205490565b600090565b90565b6113c46113bf6113c9926113ad565b610bc9565b610bbc565b90565b6113d46113a8565b506113e16202a3006113b0565b90565b5090565b67ffffffffffffffff81116114005760208091020190565b6101b3565b90611417611412836113e8565b6101f2565b918252565b369037565b9061144661142e83611405565b9260208061143c86936113e8565b920191039061141c565b565b61145c61145761146192610e42565b610bc9565b61063e565b90565b6001611470910161063e565b90565b634e487b7160e01b600052603260045260246000fd5b9035906001608003813603038212156114a0570190565b610cef565b908210156114bf5760206114bc9202810190611489565b90565b611473565b356114ce81610486565b90565b903590600160200381360303821215611513570180359067ffffffffffffffff821161150e5760200191600182023603831361150957565b610cf9565b610cf4565b610cef565b611523913691610236565b90565b60200190565b61153581610300565b0361153c57565b600080fd5b3561154b8161152c565b90565b9095949261159a946115896115939261157f60809661157560a088019c600089019061065b565b602087019061064e565b604085019061065b565b6060830190610641565b01906109bc565b565b5190565b906115aa8261159c565b8110156115bb576020809102010190565b611473565b906115ca906104aa565b9052565b905090565b60200190565b6115e2906104aa565b9052565b906115f3816020936115d9565b0190565b60200190565b9061161a61161461160d8461159c565b80936115ce565b926115d3565b9060005b81811061162b5750505090565b90919261164461163e60019286516115e6565b946115f7565b910191909161161e565b611657916115fd565b90565b6116906116979461168660609498979561167c608086019a600087019061065b565b602085019061065b565b6040830190610641565b0190610641565b565b906116a26110ee565b506116ab6110ee565b506116cb6116c66116c0846000810190610cfe565b906113e4565b611421565b916116d66000611448565b5b806117006116fa6116f56116ef866000810190610cfe565b906113e4565b61063e565b9161063e565b1015611818576118139061180e6117156108b9565b6117e961173a600061173461172d8983810190610cfe565b88916114a5565b016114c4565b916117da61176c61176661175c6117558b6000810190610cfe565b8a916114a5565b60208101906114d1565b90611518565b61177e61177882610312565b91611526565b206117a2604061179c6117958c6000810190610cfe565b8b916114a5565b01610c4f565b6117c560606117bf6117b88d6000810190610cfe565b8c916114a5565b01611541565b916117ce610133565b9687956020870161154e565b602082018103825203826101c9565b6117fb6117f582610312565b91611526565b2061180987918490926115a0565b6115c0565b611464565b6116d7565b5090916118a490611895611845611854611830610ab6565b93611839610133565b9283916020830161164e565b602082018103825203826101c9565b61186661186082610312565b91611526565b2093611880604061187960208401610c4f565b9201610c4f565b90611889610133565b9586946020860161165a565b602082018103825203826101c9565b6118b66118b082610312565b91611526565b20906118c182612035565b90565b600090565b916118d26118c4565b90836118ef6118e96118e46000610e61565b61047a565b9161047a565b146119c15760405191843b1561193f5750602090631626ba7e60e01b9384845260048401526024830194859160408352805184019081604487019160045afa9360443d01915afa1691511416905b565b9493919281518060401461199e5760411461195d575050505061193d565b602092939550606082015160001a835260408201516060525b60005201516040526020600160806000825afa511860601b3d1191600060605260405261193d565b506020929395506040820151601b8160ff1c01845260011b60011c606052611976565b5091505090565b67ffffffffffffffff81116119e05760208091020190565b6101b3565b906119f76119f2836119c8565b6101f2565b918252565b611a0660406101f2565b90565b600090565b606090565b611a1b6119fc565b9060208083611a28611a09565b815201611a33611a0e565b81525050565b611a41611a13565b90565b60005b828110611a5357505050565b602090611a5e611a39565b8184015201611a47565b90611a8d611a75836119e5565b92602080611a8386936119c8565b9201910390611a44565b565b600080fd5b600080fd5b90503590611aa68261152c565b565b919091608081840312611b2157611abf60806101f2565b92611acd816000840161049b565b600085015260208201359167ffffffffffffffff8311611b1c57611af682611b1594830161026c565b6020860152611b088260408301610a29565b6040860152606001611a99565b6060830152565b611a94565b611a8f565b611b31903690611aa8565b90565b611b3e905161047a565b90565b611b4b905161063e565b90565b90611b60611b5b83610207565b6101f2565b918252565b606090565b3d600014611b8757611b7b3d611b4e565b903d6000602084013e5b565b611b8f611b65565b90611b85565b611b9f9051610300565b90565b60209181520190565b611bca611bd3602093611bd893611bc181610312565b93848093611ba2565b9586910161031f565b6101a9565b0190565b611bf29160208201916000818403910152611bab565b90565b611bff60406101f2565b90565b90611c0c90610300565b9052565b52565b90611c1d826102ed565b811015611c2e576020809102010190565b611473565b611c3c9061047a565b9052565b90611c9090606080611c7360808401611c6160008801516000870190611c33565b60208701518582036020870152610344565b94611c866040820151604086019061067b565b0151910190610305565b90565b91611cb792611caa6040820193600083019061065b565b6020818403910152611c40565b90565b9091611cc4610c4a565b50611cd08382906113e4565b92611cda84611a68565b94611ce36110e4565b5b80611cf7611cf18861063e565b9161063e565b1015611e2a57611d11611d0c848684916114a5565b611b26565b600080611d1f818401611b34565b611d2b60408501611b41565b602085015190602082019151925af1611d42611b6a565b611d4c8215610300565b80611e0f575b611de95790611d96611da3949392611d838391611d7a611d70611bf5565b9360008501611c02565b60208301611c10565b8b8591611d908383611c13565b52611c13565b5150611da8575b50611464565b611ce4565b86907f4be109453ef7e895dc7215c929fff9b76b51483d56a4d04548b4866e9aa7c5ea91611de0611dd7610133565b92839283611c93565b0390a138611d9d565b611e0b90611df5610133565b91829163a5fa8d2b60e01b835260048301611bdc565b0390fd5b50611e25611e1f60608501611b95565b15610300565b611d52565b509350505050565b638b78c6d819543303611e4157565b6382b429006000526004601cfd5b611e576120b6565b600014611e9e57638b78c6d8199060601b60601c8082547f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a3801560ff1b1790555b565b638b78c6d8199060601b60601c908181547f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a355611e9c565b67ffffffffffffffff8111611ef857611ef46020916101a9565b0190565b6101b3565b90611f0f611f0a83611eda565b6101f2565b918252565b60007f52656c61794465706f7369746f72790000000000000000000000000000000000910152565b611f46600f611efd565b90611f5360208301611f14565b565b611f5d611f3c565b90565b60007f3100000000000000000000000000000000000000000000000000000000000000910152565b611f926001611efd565b90611f9f60208301611f60565b565b611fa9611f88565b90565b611fb46110df565b50611fbd6110df565b50611fc6611f55565b90611fcf611fa1565b90565b916040519360605260405260601b602c526323b872dd60601b600c52602060006064601c82855af190816001600051141615612015575b50506000606052604052565b3d903b15171015612027573880612009565b637939f4246000526004601cfd5b61203d6110ee565b506120466120c1565b60001461207557612055612124565b5b671901000000000000600052601a52603a526042601820906000603a52565b7fd99815f743eea513a0b0ad36376d9095f7ee9dedbc24c2f0f82fc3cfa8f26c4d61209e6120cc565b6120a8575b612056565b506120b1612124565b6120a3565b6120be6118c4565b90565b6120c96118c4565b90565b6120d46118c4565b507f000000000000000000000000000000000000000000000000000000000000e7087f00000000000000000000000059916da825d2d2ec1bf878d71c88826f6633ecca3014904614161590565b90565b61212c6110ee565b506121356110ee565b5061213e6120c1565b6000146121ca5760a061215c612175612155611fac565b9290612121565b61216e61216882610312565b91611526565b2091612121565b61218761218182610312565b91611526565b205b604051917f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f8352602083015260408201524660608201523060808201522090565b60a07fd0128829a10b084f74606dba96ed8e0c9da47bde3279386533b4ca219b665a7d7fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc661218956fea26469706673582212208eff6eb8193b46250a4616f0ae85c9dee5fa898df6306dfd010066a96bcabaad64736f6c634300081c0033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000f3d63166f0ca56c3c1a3508fce03ff0cf3fb691e00000000000000000000000051203c6be98052fb6d7fe1333ee6859b90d21cdf
-----Decoded View---------------
Arg [0] : _owner (address): 0xf3d63166F0Ca56C3c1A3508FcE03Ff0Cf3Fb691e
Arg [1] : _allocator (address): 0x51203C6be98052fb6D7fe1333ee6859B90d21cDf
-----Encoded View---------------
2 Constructor Arguments found :
Arg [0] : 000000000000000000000000f3d63166f0ca56c3c1a3508fce03ff0cf3fb691e
Arg [1] : 00000000000000000000000051203c6be98052fb6d7fe1333ee6859b90d21cdf
Loading...
Loading
Loading...
Loading
Loading...
Loading
Net Worth in USD
$2,999.18
Net Worth in ETH
Token Allocations
ETH
80.78%
USDC
19.18%
MNT
0.04%
Multichain Portfolio | 35 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|---|---|---|---|---|
| LINEA | 66.07% | $2,958.96 | 0.6697 | $1,981.63 | |
| LINEA | 0.10% | $0.9997 | 3.0299 | $3.03 | |
| MANTLE | 19.08% | $1 | 571.7022 | $572.27 | |
| MANTLE | 0.04% | $0.895041 | 1.3117 | $1.17 | |
| TAIKO | 14.04% | $2,958.18 | 0.1424 | $421.16 | |
| BASE | 0.39% | $2,958.81 | 0.00395448 | $11.7 | |
| ETH | 0.16% | $2,958.96 | 0.00164267 | $4.86 | |
| OP | 0.10% | $2,958.95 | 0.00098101 | $2.9 | |
| ARB | 0.01% | $2,958.84 | 0.00015 | $0.443826 |
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.