ETH Price: $2,948.58 (+0.26%)

Contract

0xb92fe925DC43a0ECdE6c8b1a2709c170Ec4fFf4f

Overview

ETH Balance

0 ETH

ETH Value

$0.00

Token Holdings

More Info

Private Name Tags

Multichain Info

No addresses found
Transaction Hash
Block
From
To
Multicall4248487162026-01-24 21:07:4711 mins ago1769288867IN
0xb92fe925...0Ec4fFf4f
0.0017 ETH0.000013040.020336
Multicall4248355802026-01-24 20:12:011 hr ago1769285521IN
0xb92fe925...0Ec4fFf4f
0.00022587 ETH0.000005680.02
Multicall4248352582026-01-24 20:10:391 hr ago1769285439IN
0xb92fe925...0Ec4fFf4f
0.0003 ETH0.000016010.020018
Multicall4248351262026-01-24 20:10:061 hr ago1769285406IN
0xb92fe925...0Ec4fFf4f
0.00449949 ETH0.000006080.020032
Multicall4248303112026-01-24 19:49:291 hr ago1769284169IN
0xb92fe925...0Ec4fFf4f
0.02055599 ETH0.000001310.020032
Multicall4248233862026-01-24 19:20:121 hr ago1769282412IN
0xb92fe925...0Ec4fFf4f
0.3388 ETH0.000015450.020012
Multicall4248203742026-01-24 19:07:342 hrs ago1769281654IN
0xb92fe925...0Ec4fFf4f
0.0067093 ETH0.000001310.020112
Multicall4248201572026-01-24 19:06:402 hrs ago1769281600IN
0xb92fe925...0Ec4fFf4f
0.00281028 ETH0.000007290.020122
Multicall4248195732026-01-24 19:04:142 hrs ago1769281454IN
0xb92fe925...0Ec4fFf4f
0.00289028 ETH0.000001320.02017
Multicall4248160432026-01-24 18:49:312 hrs ago1769280571IN
0xb92fe925...0Ec4fFf4f
0.002 ETH0.000004960.020314
Multicall4248151492026-01-24 18:45:462 hrs ago1769280346IN
0xb92fe925...0Ec4fFf4f
0.01766863 ETH0.000010760.02056
Multicall4248137262026-01-24 18:39:462 hrs ago1769279986IN
0xb92fe925...0Ec4fFf4f
0.0068 ETH0.000008880.02042
Multicall4248122422026-01-24 18:33:312 hrs ago1769279611IN
0xb92fe925...0Ec4fFf4f
0.05595465 ETH0.000006350.020498
Multicall4248028932026-01-24 17:54:143 hrs ago1769277254IN
0xb92fe925...0Ec4fFf4f
0.70998917 ETH0.000001430.021856
Multicall4247990572026-01-24 17:38:163 hrs ago1769276296IN
0xb92fe925...0Ec4fFf4f
0.0104242 ETH0.000001530.023344
Multicall4247984502026-01-24 17:35:443 hrs ago1769276144IN
0xb92fe925...0Ec4fFf4f
0.00011177 ETH0.000015690.023546
Multicall4247980862026-01-24 17:34:133 hrs ago1769276053IN
0xb92fe925...0Ec4fFf4f
0.01282723 ETH0.00000160.024448
Multicall4247980232026-01-24 17:33:573 hrs ago1769276037IN
0xb92fe925...0Ec4fFf4f
0.00359888 ETH0.000001540.023566
Multicall4247978822026-01-24 17:33:253 hrs ago1769276005IN
0xb92fe925...0Ec4fFf4f
0.03625146 ETH0.000001550.023592
Multicall4247946892026-01-24 17:20:033 hrs ago1769275203IN
0xb92fe925...0Ec4fFf4f
0.107 ETH0.000008870.023646
Multicall4247877892026-01-24 16:51:084 hrs ago1769273468IN
0xb92fe925...0Ec4fFf4f
0.02156229 ETH0.000001570.023912
Multicall4247843112026-01-24 16:36:344 hrs ago1769272594IN
0xb92fe925...0Ec4fFf4f
0.02998535 ETH0.000001550.023558
Multicall4247841622026-01-24 16:35:574 hrs ago1769272557IN
0xb92fe925...0Ec4fFf4f
0.02998533 ETH0.000001590.023872
Multicall4247840332026-01-24 16:35:254 hrs ago1769272525IN
0xb92fe925...0Ec4fFf4f
0.02998532 ETH0.000001580.023638
Multicall4247839862026-01-24 16:35:134 hrs ago1769272513IN
0xb92fe925...0Ec4fFf4f
0.0021 ETH0.000015440.02366
View all transactions

Latest 25 internal transactions (View All)

Parent Transaction Hash Block From To
4248487162026-01-24 21:07:4711 mins ago1769288867
0xb92fe925...0Ec4fFf4f
0.0017 ETH
4248439662026-01-24 20:47:3731 mins ago1769287657
0xb92fe925...0Ec4fFf4f
0.00067641 ETH
4248439662026-01-24 20:47:3731 mins ago1769287657
0xb92fe925...0Ec4fFf4f
0.00067641 ETH
4248429462026-01-24 20:43:2035 mins ago1769287400
0xb92fe925...0Ec4fFf4f
0.0002093 ETH
4248429462026-01-24 20:43:2035 mins ago1769287400
0xb92fe925...0Ec4fFf4f
0.0002093 ETH
4248400152026-01-24 20:30:5048 mins ago1769286650
0xb92fe925...0Ec4fFf4f
0.00001999 ETH
4248400152026-01-24 20:30:5048 mins ago1769286650
0xb92fe925...0Ec4fFf4f
0.00001999 ETH
4248389252026-01-24 20:26:1152 mins ago1769286371
0xb92fe925...0Ec4fFf4f
0.0002258 ETH
4248389252026-01-24 20:26:1152 mins ago1769286371
0xb92fe925...0Ec4fFf4f
0.0002258 ETH
4248376762026-01-24 20:20:5258 mins ago1769286052
0xb92fe925...0Ec4fFf4f
0.00054288 ETH
4248376762026-01-24 20:20:5258 mins ago1769286052
0xb92fe925...0Ec4fFf4f
0.00054288 ETH
4248375282026-01-24 20:20:1358 mins ago1769286013
0xb92fe925...0Ec4fFf4f
0.00067719 ETH
4248375282026-01-24 20:20:1358 mins ago1769286013
0xb92fe925...0Ec4fFf4f
0.00067719 ETH
4248373222026-01-24 20:19:211 hr ago1769285961
0xb92fe925...0Ec4fFf4f
0.00152351 ETH
4248373222026-01-24 20:19:211 hr ago1769285961
0xb92fe925...0Ec4fFf4f
0.00152351 ETH
4248355802026-01-24 20:12:011 hr ago1769285521
0xb92fe925...0Ec4fFf4f
0.00022587 ETH
4248353312026-01-24 20:10:581 hr ago1769285458
0xb92fe925...0Ec4fFf4f
0.00026712 ETH
4248353312026-01-24 20:10:581 hr ago1769285458
0xb92fe925...0Ec4fFf4f
0.00026712 ETH
4248352582026-01-24 20:10:391 hr ago1769285439
0xb92fe925...0Ec4fFf4f
0.0003 ETH
4248351262026-01-24 20:10:061 hr ago1769285406
0xb92fe925...0Ec4fFf4f
0.00449949 ETH
4248348382026-01-24 20:08:511 hr ago1769285331
0xb92fe925...0Ec4fFf4f
0.00067768 ETH
4248348382026-01-24 20:08:511 hr ago1769285331
0xb92fe925...0Ec4fFf4f
0.00067768 ETH
4248335512026-01-24 20:03:221 hr ago1769285002
0xb92fe925...0Ec4fFf4f
0.0001744 ETH
4248335512026-01-24 20:03:221 hr ago1769285002
0xb92fe925...0Ec4fFf4f
0.0001744 ETH
4248315352026-01-24 19:54:471 hr ago1769284487
0xb92fe925...0Ec4fFf4f
0.00120331 ETH
View All Internal Transactions

Cross-Chain Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
RelayRouterV3

Compiler Version
v0.8.28+commit.7893614a

Optimization Enabled:
Yes with 200 runs

Other Settings:
cancun EvmVersion
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.25;

import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {IERC721} from "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import {IERC1155} from "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";
import {SafeTransferLib} from "solady/src/utils/SafeTransferLib.sol";

import {Call3Value, Multicall3, Result} from "../common/Multicall3.sol";
import {ReentrancyGuardMsgSender} from "../common/ReentrancyGuardMsgSender.sol";

contract RelayRouterV3 is Multicall3, ReentrancyGuardMsgSender {
    using SafeTransferLib for address;

    /// @notice Revert if this contract is set as the recipient
    error InvalidRecipient(address recipient);

    /// @notice Revert if the native transfer failed
    error NativeTransferFailed();

    /// @notice Revert if no recipient is set
    error NoRecipientSet();

    /// @notice Revert if the array lengths do not match
    error ArrayLengthsMismatch();

    /// @notice Revert if a call fails
    error CallFailed();

    /// @notice Protocol event to be emitted when transferring native tokens
    event SolverNativeTransfer(address to, uint256 amount);

    /// @notice Emitted on any explicit movement of funds
    event FundsMovement(
        address from,
        address to,
        address currency,
        uint256 amount,
        bytes metadata
    );

    uint256 private constant RECIPIENT_STORAGE_SLOT =
        uint256(keccak256("RelayRouter.recipient")) - 1;

    constructor() {}

    receive() external payable {
        emit SolverNativeTransfer(address(this), msg.value);
    }

    /// @notice Execute a multicall with the RelayRouter as msg.sender.
    /// @dev    If a multicall is expecting to mint ERC721s or ERC1155s, the recipient must be explicitly set
    ///         All calls to ERC721s and ERC1155s in the multicall will have the same recipient set in recipient
    ///         Be sure to transfer ERC20s or native tokens out of the router as part of the multicall
    /// @param calls The calls to perform
    /// @param refundTo The address to refund any leftover native tokens to
    /// @param nftRecipient The address to set as recipient of ERC721/ERC1155 mints
    /// @param metadata Additional data to associate the call to
    function multicall(
        Call3Value[] calldata calls,
        address refundTo,
        address nftRecipient,
        bytes calldata metadata
    ) public payable nonReentrant returns (Result[] memory returnData) {
        if (msg.value > 0) {
            emit FundsMovement(
                msg.sender,
                address(this),
                address(0),
                msg.value,
                metadata
            );
        }

        // Set the NFT recipient if provided
        if (nftRecipient != address(0)) {
            _setRecipient(nftRecipient);
        }

        // Perform the multicall
        returnData = _aggregate3Value(calls);

        // Clear the recipient in storage
        _clearRecipient();

        // Refund any leftover native tokens to the sender
        cleanupNative(0, refundTo, metadata);
    }

    /// @notice Send leftover ERC20 tokens to recipients
    /// @dev    Should be included in the multicall if the router is expecting to receive tokens
    ///         Set amount to 0 to transfer the full balance
    /// @param tokens The addresses of the ERC20 tokens
    /// @param recipients The addresses to refund the tokens to
    /// @param amounts The amounts to send
    /// @param metadata Additional data to associate the call to
    function cleanupErc20s(
        address[] calldata tokens,
        address[] calldata recipients,
        uint256[] calldata amounts,
        bytes calldata metadata
    ) public nonReentrant {
        // Revert if array lengths do not match
        if (
            tokens.length != amounts.length ||
            amounts.length != recipients.length
        ) {
            revert ArrayLengthsMismatch();
        }

        for (uint256 i; i < tokens.length; i++) {
            address token = tokens[i];
            address recipient = recipients[i];

            // Get the amount to transfer
            uint256 amount = amounts[i] == 0
                ? IERC20(token).balanceOf(address(this))
                : amounts[i];

            if (amount > 0) {
                // Transfer the token to the recipient address
                token.safeTransfer(recipient, amount);

                emit FundsMovement(
                    address(this),
                    recipient,
                    token,
                    amount,
                    metadata
                );
            }
        }
    }

    /// @notice Send leftover ERC20 tokens via explicit method calls
    /// @dev    Should be included in the multicall if the router is expecting to receive tokens
    ///         Set amount to 0 to transfer the full balance
    /// @param tokens The addresses of the ERC20 tokens
    /// @param tos The target addresses for the calls
    /// @param datas The data for the calls
    /// @param amounts The amounts to send
    function cleanupErc20sViaCall(
        address[] calldata tokens,
        address[] calldata tos,
        bytes[] calldata datas,
        uint256[] calldata amounts
    ) public nonReentrant {
        // Revert if array lengths do not match
        if (
            tokens.length != amounts.length ||
            amounts.length != tos.length ||
            tos.length != datas.length
        ) {
            revert ArrayLengthsMismatch();
        }

        for (uint256 i; i < tokens.length; i++) {
            address token = tokens[i];
            address to = tos[i];
            bytes calldata data = datas[i];

            // Get the amount to transfer
            uint256 amount = amounts[i] == 0
                ? IERC20(token).balanceOf(address(this))
                : amounts[i];

            if (amount > 0) {
                // First approve the target address for the call
                IERC20(token).approve(to, amount);

                // Make the call
                (bool success, ) = to.call(data);
                if (!success) {
                    revert CallFailed();
                }
            }
        }
    }

    /// @notice Send leftover native tokens to the recipient address
    /// @dev Set amount to 0 to transfer the full balance. Set recipient to address(0) to transfer to msg.sender
    /// @param amount The amount of native tokens to transfer
    /// @param recipient The recipient address
    /// @param metadata Additional data to associate the call to
    function cleanupNative(
        uint256 amount,
        address recipient,
        bytes calldata metadata
    ) public nonReentrant {
        // If recipient is address(0), set to msg.sender
        address recipientAddr = recipient == address(0)
            ? msg.sender
            : recipient;

        uint256 amountToTransfer = amount == 0 ? address(this).balance : amount;

        if (amountToTransfer > 0) {
            recipientAddr.safeTransferETH(amountToTransfer);
            emit SolverNativeTransfer(recipientAddr, amountToTransfer);

            emit FundsMovement(
                address(this),
                recipientAddr,
                address(0),
                amountToTransfer,
                metadata
            );
        }
    }

    /// @notice Send leftover native tokens via an explicit method call
    /// @dev Set amount to 0 to transfer the full balance
    /// @param amount The amount of native tokens to transfer
    /// @param to The target address of the call
    /// @param data The data for the call
    function cleanupNativeViaCall(
        uint256 amount,
        address to,
        bytes calldata data
    ) public nonReentrant {
        uint256 amountToTransfer = amount == 0 ? address(this).balance : amount;

        if (amountToTransfer > 0) {
            (bool success, ) = to.call{value: amountToTransfer}(data);
            if (!success) {
                revert CallFailed();
            }
        }
    }

    /// @notice Internal function to set the recipient address for ERC721 or ERC1155 mint
    /// @dev If the chain does not support tstore, recipient will be saved in storage
    /// @param recipient The address of the recipient
    function _setRecipient(address recipient) internal {
        // For safety, revert if the recipient is this contract
        // Tokens should either be minted directly to recipient, or transferred to recipient through the onReceived hooks
        if (recipient == address(this)) {
            revert InvalidRecipient(address(this));
        }

        // Set the recipient in storage
        uint256 recipientStorageSlot = RECIPIENT_STORAGE_SLOT;
        uint256 recipientValue = uint256(uint160(recipient));
        assembly {
            sstore(recipientStorageSlot, recipientValue)
        }
    }

    /// @notice Internal function to get the recipient address for ERC721 or ERC1155 mint
    function _getRecipient() internal view returns (address) {
        uint256 recipientStorageSlot = RECIPIENT_STORAGE_SLOT;
        uint256 value;

        assembly {
            value := sload(recipientStorageSlot)
        }

        // Get the recipient from storage
        return address(uint160(value));
    }

    /// @notice Internal function to clear the recipient address for ERC721 or ERC1155 mint
    function _clearRecipient() internal {
        // Return if recipient hasn't been set
        if (_getRecipient() == address(0)) {
            return;
        }

        // Clear the recipient in storage
        uint256 recipientStorageSlot = RECIPIENT_STORAGE_SLOT;
        assembly {
            sstore(recipientStorageSlot, 0)
        }
    }

    function onERC721Received(
        address,
        /*_operator*/ address,
        /*_from*/ uint256 _tokenId,
        bytes calldata _data
    ) external returns (bytes4) {
        // Get the recipient from storage
        address recipient = _getRecipient();

        // Revert if no recipient is set
        // Note this means transferring NFTs to this contract via `safeTransferFrom` will revert,
        // unless the transfer is part of a multicall that sets the recipient in storage
        if (recipient == address(0)) {
            revert NoRecipientSet();
        }

        // Transfer the NFT to the recipient
        IERC721(msg.sender).safeTransferFrom(
            address(this),
            recipient,
            _tokenId,
            _data
        );

        return this.onERC721Received.selector;
    }

    function onERC1155Received(
        address /*_operator*/,
        address /*_from*/,
        uint256 _id,
        uint256 _value,
        bytes calldata _data
    ) external returns (bytes4) {
        // Get the recipient from storage
        address recipient = _getRecipient();

        // Revert if no recipient is set
        // Note this means transferring NFTs to this contract via `safeTransferFrom` will revert,
        // unless the transfer is part of a multicall that sets the recipient in storage
        if (recipient == address(0)) {
            revert NoRecipientSet();
        }

        // Transfer the tokens to the recipient
        IERC1155(msg.sender).safeTransferFrom(
            address(this),
            recipient,
            _id,
            _value,
            _data
        );

        return this.onERC1155Received.selector;
    }

    function onERC1155BatchReceived(
        address /*_operator*/,
        address /*_from*/,
        uint256[] calldata _ids,
        uint256[] calldata _values,
        bytes calldata _data
    ) external returns (bytes4) {
        // Get the recipient from storage
        address recipient = _getRecipient();

        // Revert if no recipient is set
        // Note this means transferring NFTs to this contract via `safeTransferFrom` will revert,
        // unless the transfer is part of a multicall that sets the recipient in storage
        if (recipient == address(0)) {
            revert NoRecipientSet();
        }

        // Transfer the tokens to the recipient
        IERC1155(msg.sender).safeBatchTransferFrom(
            address(this),
            recipient,
            _ids,
            _values,
            _data
        );

        return this.onERC1155BatchReceived.selector;
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.20;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);

    /**
     * @dev Returns the value of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the value of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves a `value` amount of tokens from the caller's account to `to`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address to, uint256 value) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets a `value` amount of tokens as the allowance of `spender` over the
     * caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 value) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to` using the
     * allowance mechanism. `value` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address from, address to, uint256 value) external returns (bool);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/IERC721.sol)

pragma solidity ^0.8.20;

import {IERC165} from "../../utils/introspection/IERC165.sol";

/**
 * @dev Required interface of an ERC721 compliant contract.
 */
interface IERC721 is IERC165 {
    /**
     * @dev Emitted when `tokenId` token is transferred from `from` to `to`.
     */
    event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
     */
    event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
     */
    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);

    /**
     * @dev Returns the number of tokens in ``owner``'s account.
     */
    function balanceOf(address owner) external view returns (uint256 balance);

    /**
     * @dev Returns the owner of the `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function ownerOf(uint256 tokenId) external view returns (address owner);

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon
     *   a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
     * are aware of the ERC721 protocol to prevent tokens from being forever locked.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or
     *   {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon
     *   a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(address from, address to, uint256 tokenId) external;

    /**
     * @dev Transfers `tokenId` token from `from` to `to`.
     *
     * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721
     * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
     * understand this adds an external call which potentially creates a reentrancy vulnerability.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address from, address to, uint256 tokenId) external;

    /**
     * @dev Gives permission to `to` to transfer `tokenId` token to another account.
     * The approval is cleared when the token is transferred.
     *
     * Only a single account can be approved at a time, so approving the zero address clears previous approvals.
     *
     * Requirements:
     *
     * - The caller must own the token or be an approved operator.
     * - `tokenId` must exist.
     *
     * Emits an {Approval} event.
     */
    function approve(address to, uint256 tokenId) external;

    /**
     * @dev Approve or remove `operator` as an operator for the caller.
     * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
     *
     * Requirements:
     *
     * - The `operator` cannot be the address zero.
     *
     * Emits an {ApprovalForAll} event.
     */
    function setApprovalForAll(address operator, bool approved) external;

    /**
     * @dev Returns the account approved for `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function getApproved(uint256 tokenId) external view returns (address operator);

    /**
     * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
     *
     * See {setApprovalForAll}
     */
    function isApprovedForAll(address owner, address operator) external view returns (bool);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (token/ERC1155/IERC1155.sol)

pragma solidity ^0.8.20;

import {IERC165} from "../../utils/introspection/IERC165.sol";

/**
 * @dev Required interface of an ERC1155 compliant contract, as defined in the
 * https://eips.ethereum.org/EIPS/eip-1155[EIP].
 */
interface IERC1155 is IERC165 {
    /**
     * @dev Emitted when `value` amount of tokens of type `id` are transferred from `from` to `to` by `operator`.
     */
    event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);

    /**
     * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all
     * transfers.
     */
    event TransferBatch(
        address indexed operator,
        address indexed from,
        address indexed to,
        uint256[] ids,
        uint256[] values
    );

    /**
     * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to
     * `approved`.
     */
    event ApprovalForAll(address indexed account, address indexed operator, bool approved);

    /**
     * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.
     *
     * If an {URI} event was emitted for `id`, the standard
     * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value
     * returned by {IERC1155MetadataURI-uri}.
     */
    event URI(string value, uint256 indexed id);

    /**
     * @dev Returns the value of tokens of token type `id` owned by `account`.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     */
    function balanceOf(address account, uint256 id) external view returns (uint256);

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.
     *
     * Requirements:
     *
     * - `accounts` and `ids` must have the same length.
     */
    function balanceOfBatch(
        address[] calldata accounts,
        uint256[] calldata ids
    ) external view returns (uint256[] memory);

    /**
     * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,
     *
     * Emits an {ApprovalForAll} event.
     *
     * Requirements:
     *
     * - `operator` cannot be the caller.
     */
    function setApprovalForAll(address operator, bool approved) external;

    /**
     * @dev Returns true if `operator` is approved to transfer ``account``'s tokens.
     *
     * See {setApprovalForAll}.
     */
    function isApprovedForAll(address account, address operator) external view returns (bool);

    /**
     * @dev Transfers a `value` amount of tokens of type `id` from `from` to `to`.
     *
     * WARNING: This function can potentially allow a reentrancy attack when transferring tokens
     * to an untrusted contract, when invoking {onERC1155Received} on the receiver.
     * Ensure to follow the checks-effects-interactions pattern and consider employing
     * reentrancy guards when interacting with untrusted contracts.
     *
     * Emits a {TransferSingle} event.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}.
     * - `from` must have a balance of tokens of type `id` of at least `value` amount.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
     * acceptance magic value.
     */
    function safeTransferFrom(address from, address to, uint256 id, uint256 value, bytes calldata data) external;

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.
     *
     * WARNING: This function can potentially allow a reentrancy attack when transferring tokens
     * to an untrusted contract, when invoking {onERC1155BatchReceived} on the receiver.
     * Ensure to follow the checks-effects-interactions pattern and consider employing
     * reentrancy guards when interacting with untrusted contracts.
     *
     * Emits either a {TransferSingle} or a {TransferBatch} event, depending on the length of the array arguments.
     *
     * Requirements:
     *
     * - `ids` and `values` must have the same length.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
     * acceptance magic value.
     */
    function safeBatchTransferFrom(
        address from,
        address to,
        uint256[] calldata ids,
        uint256[] calldata values,
        bytes calldata data
    ) external;
}

// SPDX-License-Identifier: MIT
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.
/// - For ERC20s, this implementation won't check that a token has code,
///   responsibility is delegated to the caller.
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 Permit2 operation has failed.
    error Permit2Failed();

    /// @dev The Permit2 amount must be less than `2**160 - 1`.
    error Permit2AmountOverflow();

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                         CONSTANTS                          */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @dev Suggested gas stipend for contract receiving ETH that disallows any storage writes.
    uint256 internal constant GAS_STIPEND_NO_STORAGE_WRITES = 2300;

    /// @dev Suggested gas stipend for contract receiving ETH to perform a few
    /// storage reads and writes, but low enough to prevent griefing.
    uint256 internal constant GAS_STIPEND_NO_GRIEF = 100000;

    /// @dev The unique EIP-712 domain domain separator for the DAI token contract.
    bytes32 internal constant DAI_DOMAIN_SEPARATOR =
        0xdbb8cf42e1ecb028be3f3dbc922e1d878b963f411dc388ced501601c60f7c6f7;

    /// @dev The address for the WETH9 contract on Ethereum mainnet.
    address internal constant WETH9 = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;

    /// @dev The canonical Permit2 address.
    /// [Github](https://github.com/Uniswap/permit2)
    /// [Etherscan](https://etherscan.io/address/0x000000000022D473030F116dDEE9F6B43aC78BA3)
    address internal constant PERMIT2 = 0x000000000022D473030F116dDEE9F6B43aC78BA3;

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                       ETH OPERATIONS                       */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    // If the ETH transfer MUST succeed with a reasonable gas budget, use the force variants.
    //
    // The regular variants:
    // - Forwards all remaining gas to the target.
    // - Reverts if the target reverts.
    // - Reverts if the current contract has insufficient balance.
    //
    // The force variants:
    // - Forwards with an optional gas stipend
    //   (defaults to `GAS_STIPEND_NO_GRIEF`, which is sufficient for most cases).
    // - If the target reverts, or if the gas stipend is exhausted,
    //   creates a temporary contract to force send the ETH via `SELFDESTRUCT`.
    //   Future compatible with `SENDALL`: https://eips.ethereum.org/EIPS/eip-4758.
    // - Reverts if the current contract has insufficient balance.
    //
    // The try variants:
    // - Forwards with a mandatory gas stipend.
    // - Instead of reverting, returns whether the transfer succeeded.

    /// @dev Sends `amount` (in wei) ETH to `to`.
    function safeTransferETH(address to, uint256 amount) internal {
        /// @solidity memory-safe-assembly
        assembly {
            if iszero(call(gas(), to, amount, codesize(), 0x00, codesize(), 0x00)) {
                mstore(0x00, 0xb12d13eb) // `ETHTransferFailed()`.
                revert(0x1c, 0x04)
            }
        }
    }

    /// @dev Sends all the ETH in the current contract to `to`.
    function safeTransferAllETH(address to) internal {
        /// @solidity memory-safe-assembly
        assembly {
            // Transfer all the ETH and check if it succeeded or not.
            if iszero(call(gas(), to, selfbalance(), codesize(), 0x00, codesize(), 0x00)) {
                mstore(0x00, 0xb12d13eb) // `ETHTransferFailed()`.
                revert(0x1c, 0x04)
            }
        }
    }

    /// @dev Force sends `amount` (in wei) ETH to `to`, with a `gasStipend`.
    function forceSafeTransferETH(address to, uint256 amount, uint256 gasStipend) internal {
        /// @solidity memory-safe-assembly
        assembly {
            if lt(selfbalance(), amount) {
                mstore(0x00, 0xb12d13eb) // `ETHTransferFailed()`.
                revert(0x1c, 0x04)
            }
            if iszero(call(gasStipend, to, amount, codesize(), 0x00, codesize(), 0x00)) {
                mstore(0x00, to) // Store the address in scratch space.
                mstore8(0x0b, 0x73) // Opcode `PUSH20`.
                mstore8(0x20, 0xff) // Opcode `SELFDESTRUCT`.
                if iszero(create(amount, 0x0b, 0x16)) { revert(codesize(), codesize()) } // For gas estimation.
            }
        }
    }

    /// @dev Force sends all the ETH in the current contract to `to`, with a `gasStipend`.
    function forceSafeTransferAllETH(address to, uint256 gasStipend) internal {
        /// @solidity memory-safe-assembly
        assembly {
            if iszero(call(gasStipend, to, selfbalance(), codesize(), 0x00, codesize(), 0x00)) {
                mstore(0x00, to) // Store the address in scratch space.
                mstore8(0x0b, 0x73) // Opcode `PUSH20`.
                mstore8(0x20, 0xff) // Opcode `SELFDESTRUCT`.
                if iszero(create(selfbalance(), 0x0b, 0x16)) { revert(codesize(), codesize()) } // For gas estimation.
            }
        }
    }

    /// @dev Force sends `amount` (in wei) ETH to `to`, with `GAS_STIPEND_NO_GRIEF`.
    function forceSafeTransferETH(address to, uint256 amount) internal {
        /// @solidity memory-safe-assembly
        assembly {
            if lt(selfbalance(), amount) {
                mstore(0x00, 0xb12d13eb) // `ETHTransferFailed()`.
                revert(0x1c, 0x04)
            }
            if iszero(call(GAS_STIPEND_NO_GRIEF, to, amount, codesize(), 0x00, codesize(), 0x00)) {
                mstore(0x00, to) // Store the address in scratch space.
                mstore8(0x0b, 0x73) // Opcode `PUSH20`.
                mstore8(0x20, 0xff) // Opcode `SELFDESTRUCT`.
                if iszero(create(amount, 0x0b, 0x16)) { revert(codesize(), codesize()) } // For gas estimation.
            }
        }
    }

    /// @dev Force sends all the ETH in the current contract to `to`, with `GAS_STIPEND_NO_GRIEF`.
    function forceSafeTransferAllETH(address to) internal {
        /// @solidity memory-safe-assembly
        assembly {
            // forgefmt: disable-next-item
            if iszero(call(GAS_STIPEND_NO_GRIEF, to, selfbalance(), codesize(), 0x00, codesize(), 0x00)) {
                mstore(0x00, to) // Store the address in scratch space.
                mstore8(0x0b, 0x73) // Opcode `PUSH20`.
                mstore8(0x20, 0xff) // Opcode `SELFDESTRUCT`.
                if iszero(create(selfbalance(), 0x0b, 0x16)) { revert(codesize(), codesize()) } // For gas estimation.
            }
        }
    }

    /// @dev Sends `amount` (in wei) ETH to `to`, with a `gasStipend`.
    function trySafeTransferETH(address to, uint256 amount, uint256 gasStipend)
        internal
        returns (bool success)
    {
        /// @solidity memory-safe-assembly
        assembly {
            success := call(gasStipend, to, amount, codesize(), 0x00, codesize(), 0x00)
        }
    }

    /// @dev Sends all the ETH in the current contract to `to`, with a `gasStipend`.
    function trySafeTransferAllETH(address to, uint256 gasStipend)
        internal
        returns (bool success)
    {
        /// @solidity memory-safe-assembly
        assembly {
            success := call(gasStipend, to, selfbalance(), codesize(), 0x00, codesize(), 0x00)
        }
    }

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                      ERC20 OPERATIONS                      */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @dev Sends `amount` of ERC20 `token` from `from` to `to`.
    /// Reverts upon failure.
    ///
    /// The `from` account must have at least `amount` approved for
    /// the current contract to manage.
    function safeTransferFrom(address token, address from, address to, uint256 amount) internal {
        /// @solidity memory-safe-assembly
        assembly {
            let m := mload(0x40) // Cache the free memory pointer.
            mstore(0x60, amount) // Store the `amount` argument.
            mstore(0x40, to) // Store the `to` argument.
            mstore(0x2c, shl(96, from)) // Store the `from` argument.
            mstore(0x0c, 0x23b872dd000000000000000000000000) // `transferFrom(address,address,uint256)`.
            // Perform the transfer, reverting upon failure.
            if iszero(
                and( // The arguments of `and` are evaluated from right to left.
                    or(eq(mload(0x00), 1), iszero(returndatasize())), // Returned 1 or nothing.
                    call(gas(), token, 0, 0x1c, 0x64, 0x00, 0x20)
                )
            ) {
                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 :=
                and( // The arguments of `and` are evaluated from right to left.
                    or(eq(mload(0x00), 1), iszero(returndatasize())), // Returned 1 or nothing.
                    call(gas(), token, 0, 0x1c, 0x64, 0x00, 0x20)
                )
            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.
            if iszero(
                and( // The arguments of `and` are evaluated from right to left.
                    or(eq(mload(0x00), 1), iszero(returndatasize())), // Returned 1 or nothing.
                    call(gas(), token, 0, 0x1c, 0x64, 0x00, 0x20)
                )
            ) {
                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.
            if iszero(
                and( // The arguments of `and` are evaluated from right to left.
                    or(eq(mload(0x00), 1), iszero(returndatasize())), // Returned 1 or nothing.
                    call(gas(), token, 0, 0x10, 0x44, 0x00, 0x20)
                )
            ) {
                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.
            if iszero(
                and( // The arguments of `and` are evaluated from right to left.
                    or(eq(mload(0x00), 1), iszero(returndatasize())), // Returned 1 or nothing.
                    call(gas(), token, 0, 0x10, 0x44, 0x00, 0x20)
                )
            ) {
                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)`.
            // Perform the approval, reverting upon failure.
            if iszero(
                and( // The arguments of `and` are evaluated from right to left.
                    or(eq(mload(0x00), 1), iszero(returndatasize())), // Returned 1 or nothing.
                    call(gas(), token, 0, 0x10, 0x44, 0x00, 0x20)
                )
            ) {
                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.
            if iszero(
                and( // The arguments of `and` are evaluated from right to left.
                    or(eq(mload(0x00), 1), iszero(returndatasize())), // Returned 1 or nothing.
                    call(gas(), token, 0, 0x10, 0x44, 0x00, 0x20)
                )
            ) {
                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.
                if iszero(
                    and(
                        or(eq(mload(0x00), 1), iszero(returndatasize())), // Returned 1 or nothing.
                        call(gas(), token, 0, 0x10, 0x44, 0x00, 0x20)
                    )
                ) {
                    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 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), exists)) {
                mstore(0x00, 0x7939f4248757f0fd) // `TransferFromFailed()` or `Permit2AmountOverflow()`.
                revert(add(0x18, shl(2, iszero(iszero(shr(160, amount))))), 0x04)
            }
        }
    }

    /// @dev Permit a user to spend a given amount of
    /// another user's tokens via native EIP-2612 permit if possible, falling
    /// back to Permit2 if native permit fails or is not implemented on the token.
    function permit2(
        address token,
        address owner,
        address spender,
        uint256 amount,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal {
        bool success;
        /// @solidity memory-safe-assembly
        assembly {
            for {} shl(96, xor(token, WETH9)) {} {
                mstore(0x00, 0x3644e515) // `DOMAIN_SEPARATOR()`.
                if iszero(
                    and( // The arguments of `and` are evaluated from right to left.
                        lt(iszero(mload(0x00)), eq(returndatasize(), 0x20)), // Returns 1 non-zero word.
                        // Gas stipend to limit gas burn for tokens that don't refund gas when
                        // an non-existing function is called. 5K should be enough for a SLOAD.
                        staticcall(5000, token, 0x1c, 0x04, 0x00, 0x20)
                    )
                ) { break }
                // After here, we can be sure that token is a contract.
                let m := mload(0x40)
                mstore(add(m, 0x34), spender)
                mstore(add(m, 0x20), shl(96, owner))
                mstore(add(m, 0x74), deadline)
                if eq(mload(0x00), DAI_DOMAIN_SEPARATOR) {
                    mstore(0x14, owner)
                    mstore(0x00, 0x7ecebe00000000000000000000000000) // `nonces(address)`.
                    mstore(add(m, 0x94), staticcall(gas(), token, 0x10, 0x24, add(m, 0x54), 0x20))
                    mstore(m, 0x8fcbaf0c000000000000000000000000) // `IDAIPermit.permit`.
                    // `nonces` is already at `add(m, 0x54)`.
                    // `1` is already stored at `add(m, 0x94)`.
                    mstore(add(m, 0xb4), and(0xff, v))
                    mstore(add(m, 0xd4), r)
                    mstore(add(m, 0xf4), s)
                    success := call(gas(), token, 0, add(m, 0x10), 0x104, codesize(), 0x00)
                    break
                }
                mstore(m, 0xd505accf000000000000000000000000) // `IERC20Permit.permit`.
                mstore(add(m, 0x54), amount)
                mstore(add(m, 0x94), and(0xff, v))
                mstore(add(m, 0xb4), r)
                mstore(add(m, 0xd4), s)
                success := call(gas(), token, 0, add(m, 0x10), 0xe4, codesize(), 0x00)
                break
            }
        }
        if (!success) simplePermit2(token, owner, spender, amount, deadline, v, r, s);
    }

    /// @dev Simple permit on the Permit2 contract.
    function simplePermit2(
        address token,
        address owner,
        address spender,
        uint256 amount,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal {
        /// @solidity memory-safe-assembly
        assembly {
            let m := mload(0x40)
            mstore(m, 0x927da105) // `allowance(address,address,address)`.
            {
                let addressMask := shr(96, not(0))
                mstore(add(m, 0x20), and(addressMask, owner))
                mstore(add(m, 0x40), and(addressMask, token))
                mstore(add(m, 0x60), and(addressMask, spender))
                mstore(add(m, 0xc0), and(addressMask, spender))
            }
            let p := mul(PERMIT2, iszero(shr(160, amount)))
            if iszero(
                and( // The arguments of `and` are evaluated from right to left.
                    gt(returndatasize(), 0x5f), // Returns 3 words: `amount`, `expiration`, `nonce`.
                    staticcall(gas(), p, add(m, 0x1c), 0x64, add(m, 0x60), 0x60)
                )
            ) {
                mstore(0x00, 0x6b836e6b8757f0fd) // `Permit2Failed()` or `Permit2AmountOverflow()`.
                revert(add(0x18, shl(2, iszero(p))), 0x04)
            }
            mstore(m, 0x2b67b570) // `Permit2.permit` (PermitSingle variant).
            // `owner` is already `add(m, 0x20)`.
            // `token` is already at `add(m, 0x40)`.
            mstore(add(m, 0x60), amount)
            mstore(add(m, 0x80), 0xffffffffffff) // `expiration = type(uint48).max`.
            // `nonce` is already at `add(m, 0xa0)`.
            // `spender` is already at `add(m, 0xc0)`.
            mstore(add(m, 0xe0), deadline)
            mstore(add(m, 0x100), 0x100) // `signature` offset.
            mstore(add(m, 0x120), 0x41) // `signature` length.
            mstore(add(m, 0x140), r)
            mstore(add(m, 0x160), s)
            mstore(add(m, 0x180), shl(248, v))
            if iszero(call(gas(), p, 0, add(m, 0x1c), 0x184, codesize(), 0x00)) {
                mstore(0x00, 0x6b836e6b) // `Permit2Failed()`.
                revert(0x1c, 0x04)
            }
        }
    }
}

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.12;

struct Call3Value {
    address target;
    bool allowFailure;
    uint256 value;
    bytes callData;
}

struct Result {
    bool success;
    bytes returnData;
}

/// @title Multicall3
/// @notice Aggregate results from multiple function calls
/// @dev Multicall & Multicall2 backwards-compatible
/// @dev Aggregate methods are marked `payable` to save 24 gas per call
/// @dev This is a fork of the original Multicall3 contract with multicalls
/// @dev only executable by address(this). This contract is meant to be inherited
/// @dev by other contracts that need to perform multicalls.
/// @author Michael Elliot <[email protected]>
/// @author Joshua Levine <[email protected]>
/// @author Nick Johnson <[email protected]>
/// @author Andreas Bigger <[email protected]>
/// @author Matt Solomon <[email protected]>
contract Multicall3 {
    event SolverCallExecuted(address to, bytes data, uint256 amount);

    /// @notice Aggregate calls
    /// @param calls An array of Call3Value structs
    /// @return returnData An array of Result structs
    function _aggregate3Value(Call3Value[] calldata calls) internal returns (Result[] memory returnData) {
        uint256 length = calls.length;
        returnData = new Result[](length);
        Call3Value calldata calli;

        for (uint256 i = 0; i < length;) {
            Result memory result = returnData[i];
            calli = calls[i];

            uint256 val = calli.value;
            (result.success, result.returnData) = calli.target.call{value: val}(calli.callData);

            // Make sure to bubble-up any reverts
            if (!calli.allowFailure && !result.success) {
                bytes memory revertData = result.returnData;
                assembly {
                    revert(add(revertData, 32), mload(revertData))
                }
            }

            if (result.success) {
                emit SolverCallExecuted(calli.target, calli.callData, calli.value);
            }

            unchecked {
                ++i;
            }
        }
    }
}

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.25;

/// @title ReentrancyGuardMsgSender
/// @notice Modified version of OpenZeppelin's ReentrancyGuardTransient
///         https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/ReentrancyGuardTransient.sol
/// @dev ReentrancyGuardMsgSender stores the original, non-reentrant msg.sender in transient storage.
///      Allows the original sender and the contract itself to reenter the contract, but prevents all other callers from reentering.
abstract contract ReentrancyGuardMsgSender {
    // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.ReentrancyGuard")) - 1)) & ~bytes32(uint256(0xff))
    bytes32 private constant MSG_SENDER_STORAGE_SLOT =
        0x9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00;

    /// @notice Unauthorized reentrant call
    error InvalidMsgSender(address storedSender, address actualSender);

    constructor() {}

    modifier nonReentrant() {
        _nonReentrantBefore();
        _;
        _nonReentrantAfter();
    }

    function _nonReentrantBefore() private {
        address sender = msg.sender;

        // Load the stored sender from the transient slot
        address storedSender;
        assembly ("memory-safe") {
            storedSender := tload(MSG_SENDER_STORAGE_SLOT)
        }

        // Revert if sender slot has been set and is not the same as the caller
        // Allow contract to reenter itself
        if (storedSender != address(0) && storedSender != sender && sender != address(this)) {
            revert InvalidMsgSender(storedSender, sender);
        }

        // Any calls to nonReentrant after this point will fail
        assembly ("memory-safe") {
            tstore(MSG_SENDER_STORAGE_SLOT, sender)
        }
    }

    function _nonReentrantAfter() private {
        // By storing the original value once again, a refund is triggered (see https://eips.ethereum.org/EIPS/eip-2200)
        address zeroAddress = address(0);
        assembly ("memory-safe") {
            tstore(MSG_SENDER_STORAGE_SLOT, zeroAddress)
        }
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)

pragma solidity ^0.8.20;

/**
 * @dev Interface of the ERC165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[EIP].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165 {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}

Settings
{
  "remappings": [
    "@openzeppelin/=lib/openzeppelin-contracts/",
    "solady/=lib/solady/",
    "permit2-relay/=lib/permit2-relay/",
    "0x-settler/=lib/0x-settler/",
    "trustlessPermit/=lib/trustlessPermit/",
    "ds-test/=lib/openzeppelin-contracts/lib/forge-std/lib/ds-test/src/",
    "erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
    "forge-gas-snapshot/=lib/0x-settler/lib/forge-gas-snapshot/src/",
    "forge-std/=lib/forge-std/src/",
    "openzeppelin-contracts/=lib/openzeppelin-contracts/",
    "permit2/=lib/0x-settler/lib/permit2/",
    "solmate/=lib/0x-settler/lib/solmate/"
  ],
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "metadata": {
    "useLiteralContent": false,
    "bytecodeHash": "none",
    "appendCBOR": false
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "evmVersion": "cancun",
  "viaIR": true
}

Contract Security Audit

Contract ABI

API
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"ArrayLengthsMismatch","type":"error"},{"inputs":[],"name":"CallFailed","type":"error"},{"inputs":[{"internalType":"address","name":"storedSender","type":"address"},{"internalType":"address","name":"actualSender","type":"address"}],"name":"InvalidMsgSender","type":"error"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"}],"name":"InvalidRecipient","type":"error"},{"inputs":[],"name":"NativeTransferFailed","type":"error"},{"inputs":[],"name":"NoRecipientSet","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"address","name":"currency","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"metadata","type":"bytes"}],"name":"FundsMovement","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"bytes","name":"data","type":"bytes"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"SolverCallExecuted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"SolverNativeTransfer","type":"event"},{"inputs":[{"internalType":"address[]","name":"tokens","type":"address[]"},{"internalType":"address[]","name":"recipients","type":"address[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"bytes","name":"metadata","type":"bytes"}],"name":"cleanupErc20s","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"tokens","type":"address[]"},{"internalType":"address[]","name":"tos","type":"address[]"},{"internalType":"bytes[]","name":"datas","type":"bytes[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"name":"cleanupErc20sViaCall","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"bytes","name":"metadata","type":"bytes"}],"name":"cleanupNative","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"to","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"cleanupNativeViaCall","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"target","type":"address"},{"internalType":"bool","name":"allowFailure","type":"bool"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"bytes","name":"callData","type":"bytes"}],"internalType":"struct Call3Value[]","name":"calls","type":"tuple[]"},{"internalType":"address","name":"refundTo","type":"address"},{"internalType":"address","name":"nftRecipient","type":"address"},{"internalType":"bytes","name":"metadata","type":"bytes"}],"name":"multicall","outputs":[{"components":[{"internalType":"bool","name":"success","type":"bool"},{"internalType":"bytes","name":"returnData","type":"bytes"}],"internalType":"struct Result[]","name":"returnData","type":"tuple[]"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256[]","name":"_ids","type":"uint256[]"},{"internalType":"uint256[]","name":"_values","type":"uint256[]"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"onERC1155BatchReceived","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"_id","type":"uint256"},{"internalType":"uint256","name":"_value","type":"uint256"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"onERC1155Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"onERC721Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]

60808060405234601557611270908161001a8239f35b5f80fdfe60806040526004361015610022575b3615610018575f80fd5b610020610eed565b005b5f3560e01c8063150b7a02146100a15780635d1fe6a21461009c57806373b7bb2f146100975780639bb4371814610092578063a6bd8c961461008d578063bc197c8114610088578063cd6e13f7146100835763f23a6e610361000e57610739565b610621565b6104e5565b61040c565b61036f565b6102d2565b610225565b34610195576080366003190112610195576100bd6004356101a8565b6100c86024356101a8565b6044356064356001600160401b038111610195576100ea9036906004016101b9565b5f5160206112105f395f51905f525491929091610117906001600160a01b03165b6001600160a01b031690565b6001600160a01b0381161561019957333b156101955761014e5f936040519586948594635c46a7ef60e11b8652306004870161087e565b038183335af1801561019057610176575b604051630a85bd0160e11b815280602081015b0390f35b806101845f61018a9361082e565b80610854565b8061015f565b6108b2565b5f80fd5b63f36675c360e01b5f5260045ffd5b6001600160a01b0381160361019557565b9181601f84011215610195578235916001600160401b038311610195576020838186019501011161019557565b60606003198201126101955760043591602435610202816101a8565b91604435906001600160401b03821161019557610221916004016101b9565b9091565b3461019557610233366101e6565b9261023f929192610f20565b8061029c575047925b83610260575b5f5f5160206112505f395f51905f525d005b5f938493826040519384928337810185815203925af161027e6108ca565b501561028d575f80808061024e565b633204506f60e01b5f5260045ffd5b92610248565b9181601f84011215610195578235916001600160401b038311610195576020808501948460051b01011161019557565b34610195576080366003190112610195576004356001600160401b038111610195576103029036906004016102a2565b6024356001600160401b038111610195576103219036906004016102a2565b6044939193356001600160401b038111610195576103439036906004016102a2565b91606435956001600160401b038711610195576103676100209736906004016102a2565b969095610908565b34610195576080366003190112610195576004356001600160401b0381116101955761039f9036906004016102a2565b6024356001600160401b038111610195576103be9036906004016102a2565b6044939193356001600160401b038111610195576103e09036906004016102a2565b91606435956001600160401b038711610195576104046100209736906004016101b9565b969095610b7c565b346101955761041a366101e6565b929091610425610f20565b6001600160a01b0381166104df575033905b806104d9575047915b8261044e575b610020610f88565b5f38818086865af1156104cc57604080516001600160a01b0384168152602081018590525f5160206112305f395f51905f52956104c093909290917fd35467972d1fda5b63c735f59d3974fa51785a41a92aa3ed1b70832836f8dba691819081015b0390a16040519485943086610ca5565b0390a15f808080610446565b63b12d13eb5f526004601cfd5b91610440565b90610437565b346101955760a0366003190112610195576105016004356101a8565b61050c6024356101a8565b6044356001600160401b0381116101955761052b9036906004016102a2565b6064356001600160401b0381116101955761054a9036906004016102a2565b919092608435926001600160401b038411610195576101729461057461057c9536906004016101b9565b949093610de8565b6040516001600160e01b031990911681529081906020820190565b602081016020825282518091526040820191602060408360051b8301019401925f915b8383106105c957505050505090565b90919293946020806060600193603f1986820301875282808b5180511515845201516040828401528051918291826040860152018484015e5f828201840152601f01601f1916010197019594919091019201906105ba565b6080366003190112610195576004356001600160401b0381116101955761064c9036906004016102a2565b906024359061065a826101a8565b604435610666816101a8565b6064356001600160401b038111610195576106859036906004016101b9565b929091610690610f20565b34610711575b6001600160a01b0316806106da575b50906106b8610172956106c694936110c7565b936106c16111e9565b610d16565b6106ce610f88565b60405191829182610597565b929190923081146106fe575f5160206112105f395f51905f525590916106b86106a5565b630bc2c5df60e11b5f523060045260245ffd5b5f5160206112305f395f51905f5260405180610731878734303386610ca5565b0390a1610696565b346101955760a0366003190112610195576107556004356101a8565b6107606024356101a8565b6064356044356084356001600160401b038111610195576107859036906004016101b9565b5f5160206112105f395f51905f5254909291906107aa906001600160a01b031661010b565b906001600160a01b0382161561019957333b15610195575f936107e3916040519687958695637921219560e11b87523060048801610eb4565b038183335af1801561019057610806575b60405163f23a6e6160e01b8152602090f35b806101845f6108149361082e565b5f6107f4565b634e487b7160e01b5f52604160045260245ffd5b90601f801991011681019081106001600160401b0382111761084f57604052565b61081a565b5f91031261019557565b908060209392818452848401375f828201840152601f01601f1916010190565b6001600160a01b0391821681529116602082015260408101919091526080606082018190526108af9391019161085e565b90565b6040513d5f823e3d90fd5b908092918237015f815290565b3d15610903573d906001600160401b03821161084f57604051916108f8601f8201601f19166020018461082e565b82523d5f602084013e565b606090565b9695929094919394610918610f20565b868114801590610ac8575b8015610abe575b610aaf575f5b81811061094a57505050505050505050610948610f88565b565b61095d61095882848c610ae6565b610afb565b61096b61095883868a610ae6565b61097683878b610b37565b9092610983858d8b610ae6565b35610a9e576040516370a0823160e01b81523060048201526020816024816001600160a01b0386165afa908115610190575f91610a70575b505b806109d0575b5050505050600101610930565b60405163095ea7b360e01b81526001600160a01b0385811660048301526024820192909252939291602091859160449183915f91165af18015610190575f9485948592610a44575b50610a28604051809481936108bd565b03925af1610a346108ca565b501561028d575f808080806109c3565b610a649060203d8111610a69575b610a5c818361082e565b810190610b67565b610a18565b503d610a52565b610a91915060203d8111610a97575b610a89818361082e565b810190610b4e565b5f6109bb565b503d610a7f565b610aa9858d8b610ae6565b356109bd565b631dc0052360e11b5f5260045ffd5b508282141561092a565b5081871415610923565b634e487b7160e01b5f52603260045260245ffd5b9190811015610af65760051b0190565b610ad2565b356108af816101a8565b903590601e198136030182121561019557018035906001600160401b0382116101955760200191813603831361019557565b90821015610af6576102219160051b810190610b05565b90816020910312610195575190565b8015150361019557565b9081602091031261019557516108af81610b5d565b959491939290610b8a610f20565b828114801590610c9b575b610aaf575f5b818110610bb357505050505050505050610948610f88565b610bc161095882848b610ae6565b90610bd061095882868a610ae6565b9188610bdd83888a610ae6565b35610c8657506040516370a0823160e01b8152306004820152906020826024816001600160a01b0385165afa938415610190576001948b935f91610c68575b505b8d81610c30575b505050505001610b9b565b5f5160206112305f395f51905f529482610c4e610c5b948688610f9a565b6040519586953087610cdc565b0390a1875f80808d610c25565b610c80915060203d8111610a9757610a89818361082e565b5f610c1c565b90600193610c9584898b610ae6565b35610c1e565b5081831415610b95565b6001600160a01b039182168152911660208201525f6040820152606081019190915260a0608082018190526108af9391019161085e565b6001600160a01b03918216815291811660208301529091166040820152606081019190915260a0608082018190526108af9391019161085e565b610d1e610f20565b6001600160a01b038116610dbf5750335b479182610d4d575b505050505f5f5160206112505f395f51905f525d565b5f38818086865af1156104cc57604080516001600160a01b0384168152602081018590525f5160206112305f395f51905f5295610db393909290917fd35467972d1fda5b63c735f59d3974fa51785a41a92aa3ed1b70832836f8dba691819081016104b0565b0390a15f808080610d37565b610d2f565b81835290916001600160fb1b0383116101955760209260051b809284830137010190565b5f5160206112105f395f51905f52549495939490939192916001600160a01b0390911690811561019957333b1561019557604051631759616b60e11b815230600482019081526001600160a01b03909316602482015260a06044820152965f9688968796610e8396610e759390929091610e679160a48b019190610dc4565b918683036060880152610dc4565b92608081850391015261085e565b038183335af1801561019057610ea0575b5063bc197c8160e01b90565b806101845f610eae9361082e565b5f610e94565b6001600160a01b039182168152911660208201526040810191909152606081019190915260a0608082018190526108af9391019161085e565b604080513081523460208201527fd35467972d1fda5b63c735f59d3974fa51785a41a92aa3ed1b70832836f8dba69190a1565b5f5160206112505f395f51905f525c6001600160a01b031680151580610f7e575b80610f74575b610f5e5750335f5160206112505f395f51905f525d565b63200991eb60e21b5f526004523360245260445ffd5b5030331415610f47565b5033811415610f41565b5f5f5160206112505f395f51905f525d565b60105f604492602095829560145260345263a9059cbb60601b82525af13d1560015f5114171615610fcb575f603452565b6390b8ec185f526004601cfd5b6001600160401b03811161084f5760051b60200190565b90610ff982610fd8565b611006604051918261082e565b8281528092611017601f1991610fd8565b015f5b81811061102657505050565b6040519060408201918083106001600160401b0384111761084f576020926040525f81526060838201528282860101520161101a565b8051821015610af65760209160051b010190565b9190811015610af65760051b81013590607e1981360301821215610195570190565b356108af81610b5d565b949392916040926110c29260018060a01b0316875260606020880152606087019161085e565b930152565b9190916110d383610fef565b925f5b8181106110e257505050565b6110ec818661105c565b516110f8828486611070565b60408101359061110781610afb565b925f8060608401958561111a8887610b05565b919061112b604051809481936108bd565b03925af161114861113a6108ca565b602084019081529115158352565b61115b61115760208501611092565b1590565b806111d6575b6111cd5750516001949392919061117c575b505050016110d6565b6111c26111b37f93485dcd31a905e3ffd7b012abe3438fa8fa77f98ddc9f50e879d3fa7ccdc324946111ad84610afb565b93610b05565b6040949194519485948561109c565b0390a15f8080611173565b51602081519101fd5b506111e46111578351151590565b611161565b5f5160206112105f395f51905f5280546001600160a01b03161561120c575f9055565b5056fe72dc4effd7d159affb1f4d451190a65a842cb9499f45eb1ae60b404ca68ad9d8afbab204e8271965231d37baed9b1abca8725b7409c70314455f68bc89142b919b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00

Deployed Bytecode

0x60806040526004361015610022575b3615610018575f80fd5b610020610eed565b005b5f3560e01c8063150b7a02146100a15780635d1fe6a21461009c57806373b7bb2f146100975780639bb4371814610092578063a6bd8c961461008d578063bc197c8114610088578063cd6e13f7146100835763f23a6e610361000e57610739565b610621565b6104e5565b61040c565b61036f565b6102d2565b610225565b34610195576080366003190112610195576100bd6004356101a8565b6100c86024356101a8565b6044356064356001600160401b038111610195576100ea9036906004016101b9565b5f5160206112105f395f51905f525491929091610117906001600160a01b03165b6001600160a01b031690565b6001600160a01b0381161561019957333b156101955761014e5f936040519586948594635c46a7ef60e11b8652306004870161087e565b038183335af1801561019057610176575b604051630a85bd0160e11b815280602081015b0390f35b806101845f61018a9361082e565b80610854565b8061015f565b6108b2565b5f80fd5b63f36675c360e01b5f5260045ffd5b6001600160a01b0381160361019557565b9181601f84011215610195578235916001600160401b038311610195576020838186019501011161019557565b60606003198201126101955760043591602435610202816101a8565b91604435906001600160401b03821161019557610221916004016101b9565b9091565b3461019557610233366101e6565b9261023f929192610f20565b8061029c575047925b83610260575b5f5f5160206112505f395f51905f525d005b5f938493826040519384928337810185815203925af161027e6108ca565b501561028d575f80808061024e565b633204506f60e01b5f5260045ffd5b92610248565b9181601f84011215610195578235916001600160401b038311610195576020808501948460051b01011161019557565b34610195576080366003190112610195576004356001600160401b038111610195576103029036906004016102a2565b6024356001600160401b038111610195576103219036906004016102a2565b6044939193356001600160401b038111610195576103439036906004016102a2565b91606435956001600160401b038711610195576103676100209736906004016102a2565b969095610908565b34610195576080366003190112610195576004356001600160401b0381116101955761039f9036906004016102a2565b6024356001600160401b038111610195576103be9036906004016102a2565b6044939193356001600160401b038111610195576103e09036906004016102a2565b91606435956001600160401b038711610195576104046100209736906004016101b9565b969095610b7c565b346101955761041a366101e6565b929091610425610f20565b6001600160a01b0381166104df575033905b806104d9575047915b8261044e575b610020610f88565b5f38818086865af1156104cc57604080516001600160a01b0384168152602081018590525f5160206112305f395f51905f52956104c093909290917fd35467972d1fda5b63c735f59d3974fa51785a41a92aa3ed1b70832836f8dba691819081015b0390a16040519485943086610ca5565b0390a15f808080610446565b63b12d13eb5f526004601cfd5b91610440565b90610437565b346101955760a0366003190112610195576105016004356101a8565b61050c6024356101a8565b6044356001600160401b0381116101955761052b9036906004016102a2565b6064356001600160401b0381116101955761054a9036906004016102a2565b919092608435926001600160401b038411610195576101729461057461057c9536906004016101b9565b949093610de8565b6040516001600160e01b031990911681529081906020820190565b602081016020825282518091526040820191602060408360051b8301019401925f915b8383106105c957505050505090565b90919293946020806060600193603f1986820301875282808b5180511515845201516040828401528051918291826040860152018484015e5f828201840152601f01601f1916010197019594919091019201906105ba565b6080366003190112610195576004356001600160401b0381116101955761064c9036906004016102a2565b906024359061065a826101a8565b604435610666816101a8565b6064356001600160401b038111610195576106859036906004016101b9565b929091610690610f20565b34610711575b6001600160a01b0316806106da575b50906106b8610172956106c694936110c7565b936106c16111e9565b610d16565b6106ce610f88565b60405191829182610597565b929190923081146106fe575f5160206112105f395f51905f525590916106b86106a5565b630bc2c5df60e11b5f523060045260245ffd5b5f5160206112305f395f51905f5260405180610731878734303386610ca5565b0390a1610696565b346101955760a0366003190112610195576107556004356101a8565b6107606024356101a8565b6064356044356084356001600160401b038111610195576107859036906004016101b9565b5f5160206112105f395f51905f5254909291906107aa906001600160a01b031661010b565b906001600160a01b0382161561019957333b15610195575f936107e3916040519687958695637921219560e11b87523060048801610eb4565b038183335af1801561019057610806575b60405163f23a6e6160e01b8152602090f35b806101845f6108149361082e565b5f6107f4565b634e487b7160e01b5f52604160045260245ffd5b90601f801991011681019081106001600160401b0382111761084f57604052565b61081a565b5f91031261019557565b908060209392818452848401375f828201840152601f01601f1916010190565b6001600160a01b0391821681529116602082015260408101919091526080606082018190526108af9391019161085e565b90565b6040513d5f823e3d90fd5b908092918237015f815290565b3d15610903573d906001600160401b03821161084f57604051916108f8601f8201601f19166020018461082e565b82523d5f602084013e565b606090565b9695929094919394610918610f20565b868114801590610ac8575b8015610abe575b610aaf575f5b81811061094a57505050505050505050610948610f88565b565b61095d61095882848c610ae6565b610afb565b61096b61095883868a610ae6565b61097683878b610b37565b9092610983858d8b610ae6565b35610a9e576040516370a0823160e01b81523060048201526020816024816001600160a01b0386165afa908115610190575f91610a70575b505b806109d0575b5050505050600101610930565b60405163095ea7b360e01b81526001600160a01b0385811660048301526024820192909252939291602091859160449183915f91165af18015610190575f9485948592610a44575b50610a28604051809481936108bd565b03925af1610a346108ca565b501561028d575f808080806109c3565b610a649060203d8111610a69575b610a5c818361082e565b810190610b67565b610a18565b503d610a52565b610a91915060203d8111610a97575b610a89818361082e565b810190610b4e565b5f6109bb565b503d610a7f565b610aa9858d8b610ae6565b356109bd565b631dc0052360e11b5f5260045ffd5b508282141561092a565b5081871415610923565b634e487b7160e01b5f52603260045260245ffd5b9190811015610af65760051b0190565b610ad2565b356108af816101a8565b903590601e198136030182121561019557018035906001600160401b0382116101955760200191813603831361019557565b90821015610af6576102219160051b810190610b05565b90816020910312610195575190565b8015150361019557565b9081602091031261019557516108af81610b5d565b959491939290610b8a610f20565b828114801590610c9b575b610aaf575f5b818110610bb357505050505050505050610948610f88565b610bc161095882848b610ae6565b90610bd061095882868a610ae6565b9188610bdd83888a610ae6565b35610c8657506040516370a0823160e01b8152306004820152906020826024816001600160a01b0385165afa938415610190576001948b935f91610c68575b505b8d81610c30575b505050505001610b9b565b5f5160206112305f395f51905f529482610c4e610c5b948688610f9a565b6040519586953087610cdc565b0390a1875f80808d610c25565b610c80915060203d8111610a9757610a89818361082e565b5f610c1c565b90600193610c9584898b610ae6565b35610c1e565b5081831415610b95565b6001600160a01b039182168152911660208201525f6040820152606081019190915260a0608082018190526108af9391019161085e565b6001600160a01b03918216815291811660208301529091166040820152606081019190915260a0608082018190526108af9391019161085e565b610d1e610f20565b6001600160a01b038116610dbf5750335b479182610d4d575b505050505f5f5160206112505f395f51905f525d565b5f38818086865af1156104cc57604080516001600160a01b0384168152602081018590525f5160206112305f395f51905f5295610db393909290917fd35467972d1fda5b63c735f59d3974fa51785a41a92aa3ed1b70832836f8dba691819081016104b0565b0390a15f808080610d37565b610d2f565b81835290916001600160fb1b0383116101955760209260051b809284830137010190565b5f5160206112105f395f51905f52549495939490939192916001600160a01b0390911690811561019957333b1561019557604051631759616b60e11b815230600482019081526001600160a01b03909316602482015260a06044820152965f9688968796610e8396610e759390929091610e679160a48b019190610dc4565b918683036060880152610dc4565b92608081850391015261085e565b038183335af1801561019057610ea0575b5063bc197c8160e01b90565b806101845f610eae9361082e565b5f610e94565b6001600160a01b039182168152911660208201526040810191909152606081019190915260a0608082018190526108af9391019161085e565b604080513081523460208201527fd35467972d1fda5b63c735f59d3974fa51785a41a92aa3ed1b70832836f8dba69190a1565b5f5160206112505f395f51905f525c6001600160a01b031680151580610f7e575b80610f74575b610f5e5750335f5160206112505f395f51905f525d565b63200991eb60e21b5f526004523360245260445ffd5b5030331415610f47565b5033811415610f41565b5f5f5160206112505f395f51905f525d565b60105f604492602095829560145260345263a9059cbb60601b82525af13d1560015f5114171615610fcb575f603452565b6390b8ec185f526004601cfd5b6001600160401b03811161084f5760051b60200190565b90610ff982610fd8565b611006604051918261082e565b8281528092611017601f1991610fd8565b015f5b81811061102657505050565b6040519060408201918083106001600160401b0384111761084f576020926040525f81526060838201528282860101520161101a565b8051821015610af65760209160051b010190565b9190811015610af65760051b81013590607e1981360301821215610195570190565b356108af81610b5d565b949392916040926110c29260018060a01b0316875260606020880152606087019161085e565b930152565b9190916110d383610fef565b925f5b8181106110e257505050565b6110ec818661105c565b516110f8828486611070565b60408101359061110781610afb565b925f8060608401958561111a8887610b05565b919061112b604051809481936108bd565b03925af161114861113a6108ca565b602084019081529115158352565b61115b61115760208501611092565b1590565b806111d6575b6111cd5750516001949392919061117c575b505050016110d6565b6111c26111b37f93485dcd31a905e3ffd7b012abe3438fa8fa77f98ddc9f50e879d3fa7ccdc324946111ad84610afb565b93610b05565b6040949194519485948561109c565b0390a15f8080611173565b51602081519101fd5b506111e46111578351151590565b611161565b5f5160206112105f395f51905f5280546001600160a01b03161561120c575f9055565b5056fe72dc4effd7d159affb1f4d451190a65a842cb9499f45eb1ae60b404ca68ad9d8afbab204e8271965231d37baed9b1abca8725b7409c70314455f68bc89142b919b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
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.