ETH Price: $3,043.76 (-8.64%)
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Approve ERC20173284242023-05-24 10:22:35613 days ago1684923755IN
0x2c47c71B...9ab6bA862
0 ETH0.002091931.74028047
Approve ERC20173284232023-05-24 10:22:23613 days ago1684923743IN
0x2c47c71B...9ab6bA862
0 ETH0.001680732.28768131
Add Market173284232023-05-24 10:22:23613 days ago1684923743IN
0x2c47c71B...9ab6bA862
0 ETH0.0018266732.28768131
Batch Buy With E...171076902023-04-23 8:00:59645 days ago1682236859IN
0x2c47c71B...9ab6bA862
0.0012 ETH0.0123841334.32809989
Add Market170797192023-04-19 9:18:59648 days ago1681895939IN
0x2c47c71B...9ab6bA862
0 ETH0.004301575.9995999
Add Market170797182023-04-19 9:18:47648 days ago1681895927IN
0x2c47c71B...9ab6bA862
0 ETH0.0044847779.17062144
Batch Buy With E...170451682023-04-14 11:37:35653 days ago1681472255IN
0x2c47c71B...9ab6bA862
0.001 ETH0.0072367425.54392572
Batch Buy With E...170450662023-04-14 11:16:47653 days ago1681471007IN
0x2c47c71B...9ab6bA862
0 ETH0.008650625.45517371
Batch Buy With E...170450302023-04-14 11:09:11653 days ago1681470551IN
0x2c47c71B...9ab6bA862
0.0089 ETH0.0071751126.377146
Approve ERC20170444612023-04-14 9:12:23653 days ago1681463543IN
0x2c47c71B...9ab6bA862
0 ETH0.0016798825.48415303
Approve ERC20170444612023-04-14 9:12:23653 days ago1681463543IN
0x2c47c71B...9ab6bA862
0 ETH0.0016801925.48415303
Approve ERC20170444612023-04-14 9:12:23653 days ago1681463543IN
0x2c47c71B...9ab6bA862
0 ETH0.0013268525.48415303
Approve ERC20170444612023-04-14 9:12:23653 days ago1681463543IN
0x2c47c71B...9ab6bA862
0 ETH0.0013235325.41447663
Add Market170444612023-04-14 9:12:23653 days ago1681463543IN
0x2c47c71B...9ab6bA862
0 ETH0.0014381225.41447663
Add Market170444602023-04-14 9:12:11653 days ago1681463531IN
0x2c47c71B...9ab6bA862
0 ETH0.001344623.75671148
Add Market170444602023-04-14 9:12:11653 days ago1681463531IN
0x2c47c71B...9ab6bA862
0 ETH0.0017522723.75671148
Register Feature170442832023-04-14 8:36:11654 days ago1681461371IN
0x2c47c71B...9ab6bA862
0 ETH0.0185835130.75106331

Latest 4 internal transactions

Advanced mode:
Parent Transaction Hash Block
From
To
171076902023-04-23 8:00:59645 days ago1682236859
0x2c47c71B...9ab6bA862
0.0012 ETH
170451682023-04-14 11:37:35653 days ago1681472255
0x2c47c71B...9ab6bA862
0.001 ETH
170450302023-04-14 11:09:11653 days ago1681470551
0x2c47c71B...9ab6bA862
0.008 ETH
170450302023-04-14 11:09:11653 days ago1681470551
0x2c47c71B...9ab6bA862
0.0009 ETH
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
Name3SwapV2

Compiler Version
v0.8.15+commit.e14f2714

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 11 : Name3SwapV2.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.15;

import "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";
import "./storage/LibFeatureStorage.sol";
import "./Aggregator.sol";
import "./libs/Ownable.sol";


contract Name3SwapV2 is Aggregator, Ownable {

    struct Method {
        bytes4 methodID;
        string methodName;
    }

    struct Feature {
        address feature;
        string name;
        Method[] methods;
    }

    event FeatureFunctionUpdated(
        bytes4 indexed methodID,
        address oldFeature,
        address newFeature
    );

    function registerFeatures(Feature[] calldata features) external onlyOwner {
        unchecked {
            for (uint256 i = 0; i < features.length; ++i) {
                registerFeature(features[i]);
            }
        }
    }

    function registerFeature(Feature calldata feature) public onlyOwner {
        unchecked {
            address impl = feature.feature;
            require(impl != address(0), "registerFeature: invalid feature address.");

            LibFeatureStorage.Storage storage stor = LibFeatureStorage.getStorage();
            stor.featureNames[impl] = feature.name;

            Method[] calldata methods = feature.methods;
            for (uint256 i = 0; i < methods.length; ++i) {
                bytes4 methodID = methods[i].methodID;
                address oldFeature = stor.featureImpls[methodID];
                if (oldFeature == address(0)) {
                    stor.methodIDs.push(methodID);
                }
                stor.featureImpls[methodID] = impl;
                stor.methodNames[methodID] = methods[i].methodName;
                emit FeatureFunctionUpdated(methodID, oldFeature, impl);
            }
        }
    }

    function unregister(bytes4[] calldata methodIDs) external onlyOwner {
        unchecked {
            uint256 removedFeatureCount;
            LibFeatureStorage.Storage storage stor = LibFeatureStorage.getStorage();

            // Update storage.featureImpls
            for (uint256 i = 0; i < methodIDs.length; ++i) {
                bytes4 methodID = methodIDs[i];
                address impl = stor.featureImpls[methodID];
                if (impl != address(0)) {
                    removedFeatureCount++;
                    stor.featureImpls[methodID] = address(0);
                }
                emit FeatureFunctionUpdated(methodID, impl, address(0));
            }
            if (removedFeatureCount == 0) {
                return;
            }

            // Remove methodIDs from storage.methodIDs
            bytes4[] storage storMethodIDs = stor.methodIDs;
            for (uint256 i = storMethodIDs.length; i > 0; --i) {
                bytes4 methodID = storMethodIDs[i - 1];
                if (stor.featureImpls[methodID] == address(0)) {
                    if (i != storMethodIDs.length) {
                        storMethodIDs[i - 1] = storMethodIDs[storMethodIDs.length - 1];
                    }
                    delete storMethodIDs[storMethodIDs.length - 1];
                    storMethodIDs.pop();

                    if (removedFeatureCount == 1) { // Finished
                        return;
                    }
                    --removedFeatureCount;
                }
            }
        }
    }

    /// @dev Fallback for just receiving ether.
    receive() external payable {}

    /// @dev Forwards calls to the appropriate implementation contract.
    uint256 private constant STORAGE_ID_FEATURE = 1 << 128;
    fallback() external payable {
        assembly {
            // Copy methodID to memory 0x00~0x04
            calldatacopy(0, 0, 4)

            // Store LibFeatureStorage.slot to memory 0x20~0x3F
            mstore(0x20, STORAGE_ID_FEATURE)

            // Calculate impl.slot and load impl from storage
            let impl := sload(keccak256(0, 0x40))
            if iszero(impl) {
                // revert("Not implemented method.")
                mstore(0, 0x08c379a000000000000000000000000000000000000000000000000000000000)
                mstore(0x20, 0x0000002000000000000000000000000000000000000000000000000000000000)
                mstore(0x40, 0x000000174e6f7420696d706c656d656e746564206d6574686f642e0000000000)
                mstore(0x60, 0)
                revert(0, 0x64)
            }

            calldatacopy(0, 0, calldatasize())
            if iszero(delegatecall(gas(), impl, 0, calldatasize(), 0, 0)) {
                // Failed, copy the returned data and revert.
                returndatacopy(0, 0, returndatasize())
                revert(0, returndatasize())
            }

            // Success, copy the returned data and return.
            returndatacopy(0, 0, returndatasize())
            return(0, returndatasize())
        }
    }

    function approveERC20(IERC20 token, address operator, uint256 amount) external onlyOwner {
        token.approve(operator, amount);
    }

    function rescueETH(address recipient) external onlyOwner {
        address to = (recipient != address(0)) ? recipient : msg.sender;
        _transferEth(to, address(this).balance);
    }

    function rescueERC20(address asset, address recipient) external onlyOwner {
        address to = (recipient != address(0)) ? recipient : msg.sender;
        _transferERC20(asset, to, IERC20(asset).balanceOf(address(this)));
    }

    function rescueERC721(address asset, uint256[] calldata ids , address recipient) external onlyOwner {
        assembly {
            // selector for transferFrom(address,address,uint256)
            mstore(0, 0x23b872dd00000000000000000000000000000000000000000000000000000000)
            mstore(0x4, address())

            switch recipient
            case 0 { mstore(0x24, caller()) }
            default { mstore(0x24, recipient) }

            for { let offset := ids.offset } lt(offset, calldatasize()) { offset := add(offset, 0x20) } {
                // tokenID
                mstore(0x44, calldataload(offset))
                if iszero(call(gas(), asset, 0, 0, 0x64, 0, 0)) {
                    returndatacopy(0, 0, returndatasize())
                    revert(0, returndatasize())
                }
            }
        }
    }

    function onERC1155Received(address, address, uint256, uint256, bytes calldata) external virtual returns (bytes4) {
        return this.onERC1155Received.selector;
    }

    function onERC1155BatchReceived(address, address, uint256[] calldata, uint256[] calldata, bytes calldata) external virtual returns (bytes4) {
        return this.onERC1155BatchReceived.selector;
    }

    function onERC721Received(address, address, uint256, bytes calldata) external virtual returns (bytes4) {
        return 0x150b7a02;
    }

    function onERC721Received(address, uint256, bytes calldata) external virtual returns (bytes4) {
        return 0xf0b9e5ba;
    }

    function supportsInterface(bytes4 interfaceId) external virtual returns (bool) {
        return interfaceId == this.supportsInterface.selector;
    }
}

File 2 of 11 : IERC1155.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC1155/IERC1155.sol)

pragma solidity ^0.8.0;

import "../../utils/introspection/IERC165.sol";

/**
 * @dev Required interface of an ERC1155 compliant contract, as defined in the
 * https://eips.ethereum.org/EIPS/eip-1155[EIP].
 *
 * _Available since v3.1._
 */
interface IERC1155 is IERC165 {
    /**
     * @dev Emitted when `value` tokens of token 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 amount 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 `amount` tokens of token type `id` from `from` to `to`.
     *
     * 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 `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 amount,
        bytes calldata data
    ) external;

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.
     *
     * Emits a {TransferBatch} event.
     *
     * Requirements:
     *
     * - `ids` and `amounts` 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 amounts,
        bytes calldata data
    ) external;
}

File 3 of 11 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @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 amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

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

    /**
     * @dev Moves `amount` 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 amount) 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 `amount` 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 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `from` to `to` using the
     * allowance mechanism. `amount` 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 amount
    ) external returns (bool);
}

File 4 of 11 : IERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)

pragma solidity ^0.8.0;

/**
 * @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);
}

File 5 of 11 : Aggregator.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.15;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "./interfaces/IAggregator.sol";
import "./libs/FixinTokenSpender.sol";
import "./libs/ReentrancyGuard.sol";


abstract contract Aggregator is IAggregator, ReentrancyGuard, FixinTokenSpender {

    uint256 private constant SEAPORT_MARKET_ID = 1;
    address private constant SEAPORT = 0x00000000006c3852cbEf3e08E8dF289169EdE581;

    uint256 private constant WETH_MARKET_ID = 999;
    address private constant WETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;

    // markets.slot == 0
    // markets.data.slot == keccak256(markets.slot) == 0x290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563
    uint256 private constant MARKETS_DATA_SLOT = 0x290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563;

    // 168 bits(ethValue)
    uint256 private constant ETH_VALUE_MASK = (1 << 168) - 1;
    // 160 bits(proxy)
    uint256 private constant PROXY_MASK = (1 << 160) - 1;

    function batchBuyWithETH(bytes calldata tradeBytes) external override payable {
        uint256 ethBalanceBefore;
        assembly { ethBalanceBefore := sub(selfbalance(), callvalue()) }

        // trade
        _trade(tradeBytes);

        // return remaining ETH (if any)
        assembly {
            if eq(selfbalance(), ethBalanceBefore) {
                return(0, 0)
            }
            if gt(selfbalance(), ethBalanceBefore) {
                let success := call(gas(), caller(), sub(selfbalance(), ethBalanceBefore), 0, 0, 0, 0)
                return(0, 0)
            }
        }
        revert("Failed to return ETH.");
    }

    function batchBuyWithERC20s(
        ERC20Pair[] calldata erc20Pairs,
        bytes calldata tradeBytes,
        address[] calldata dustTokens
    ) external override payable nonReentrant {
        // transfer ERC20 tokens from the sender to this contract
        _transferERC20Pairs(erc20Pairs);

        // trade
        _trade(tradeBytes);

        // return dust tokens (if any)
        _returnDust(dustTokens);

        // return remaining ETH (if any)
        assembly {
            if gt(selfbalance(), 0) {
                let success := call(gas(), caller(), selfbalance(), 0, 0, 0, 0)
            }
        }
    }

    function _trade(bytes calldata tradeBytes) internal {
        assembly {
            let anySuccess
            let itemLength
            let end := add(tradeBytes.offset, tradeBytes.length)
            let ptr := mload(0x40) // free memory pointer

            // nextOffset == offset + 28bytes[2 + 1 + 21 + 4] + itemLength
            for { let offset := tradeBytes.offset } lt(offset, end) { offset := add(add(offset, 28), itemLength) } {
                // head == [2 bytes(marketId) + 1 bytes(continueIfFailed) + 21 bytes(ethValue) + 4 bytes(itemLength) + 4 bytes(item)]
                // head == [16 bits(marketId) + 8 bits(continueIfFailed) + 168 bits(ethValue) + 32 bits(itemLength) + 32 bits(item)]
                let head := calldataload(offset)

                // itemLength = (head >> 32) & 0xffffffff
                itemLength := and(shr(32, head), 0xffffffff)

                // itemOffset == offset + 28
                // copy item.data to memory ptr
                calldatacopy(ptr, add(offset, 28), itemLength)

                // marketId = head >> (8 + 168 + 32 + 32) = head >> 240
                let marketId := shr(240, head)

                // Seaport
                if eq(marketId, SEAPORT_MARKET_ID) {
                    // ethValue = (head >> 64) & ETH_VALUE_MASK
                    // SEAPORT.call{value: ethValue}(item)
                    if iszero(call(gas(), SEAPORT, and(shr(64, head), ETH_VALUE_MASK), ptr, itemLength, 0, 0)) {
                        _revertOrContinue(head)
                        continue
                    }
                    anySuccess := 1
                    continue
                }

                // WETH
                if eq(marketId, WETH_MARKET_ID) {
                    let methodId := and(head, 0xffffffff)

                    // WETH.deposit();
                    if eq(methodId, 0xd0e30db0) {
                        if iszero(call(gas(), WETH, and(shr(64, head), ETH_VALUE_MASK), ptr, itemLength, 0, 0)) {
                            _revertOrContinue(head)
                            continue
                        }
                        anySuccess := 1
                        continue
                    }

                    // WETH.withdraw();
                    if eq(methodId, 0x2e1a7d4d) {
                        if iszero(call(gas(), WETH, 0, ptr, itemLength, 0, 0)) {
                            _revertOrContinue(head)
                            continue
                        }
                        anySuccess := 1
                        continue
                    }

                    // Do not support other methods.
                    _revertOrContinue(head)
                    continue
                }

                // Others
                // struct Market {
                //        address proxy;
                //        bool isLibrary;
                //        bool isActive;
                //  }
                // [80 bits(unused) + 8 bits(isActive) + 8 bits(isLibrary) + 160 bits(proxy)]
                // [10 bytes(unused) + 1 bytes(isActive) + 1 bytes(isLibrary) + 20 bytes(proxy)]

                // market.slot = markets.data.slot + marketId
                // market = sload(market.slot)
                let market := sload(add(MARKETS_DATA_SLOT, marketId))

                // if (!market.isActive)
                if iszero(byte(10, market)) {
                    // if (!continueIfFailed)
                    if iszero(byte(2, head)) {
                         // revert("Inactive market.")
                        mstore(0, 0x08c379a000000000000000000000000000000000000000000000000000000000)
                        mstore(0x20, 0x0000002000000000000000000000000000000000000000000000000000000000)
                        mstore(0x40, 0x00000010496e616374697665206d61726b65742e000000000000000000000000)
                        mstore(0x60, 0)
                        revert(0, 0x64)
                    }
                    continue
                }

                // if (!market.isLibrary)
                if iszero(byte(11, market)) {
                    // ethValue = (head >> 64) & ETH_VALUE_MASK
                    // market.proxy.call{value: ethValue}(item)
                    if iszero(call(gas(), and(market, PROXY_MASK), and(shr(64, head), ETH_VALUE_MASK), ptr, itemLength, 0, 0)) {
                        _revertOrContinue(head)
                        continue
                    }
                    anySuccess := 1
                    continue
                }

                // market.proxy.delegatecall(item)
                if iszero(delegatecall(gas(), and(market, PROXY_MASK), ptr, itemLength, 0, 0)) {
                    _revertOrContinue(head)
                    continue
                }
                anySuccess := 1
            }

            // if (!anySuccess)
            if iszero(anySuccess) {
                if gt(tradeBytes.length, 0) {
                    if iszero(returndatasize()) {
                        // revert("No order succeeded.")
                        mstore(0, 0x08c379a000000000000000000000000000000000000000000000000000000000)
                        mstore(0x20, 0x0000002000000000000000000000000000000000000000000000000000000000)
                        mstore(0x40, 0x000000134e6f206f72646572207375636365656465642e000000000000000000)
                        mstore(0x60, 0)
                        revert(0, 0x64)
                    }
                    // revert(returnData)
                    returndatacopy(0, 0, returndatasize())
                    revert(0, returndatasize())
                }
            }

            function _revertOrContinue(head) {
                // head == [2 bytes(marketId) + 1 bytes(continueIfFailed) + 21 bytes(ethValue) + 4 bytes(itemLength) + 4 bytes(item)]
                // if (!continueIfFailed)
                if iszero(byte(2, head)) {
                    if iszero(returndatasize()) {
                        mstore(0, head)
                        revert(0, 0x20)
                    }
                    returndatacopy(0, 0, returndatasize())
                    revert(0, returndatasize())
                }
            }
        }
    }

    function _transferERC20Pairs(ERC20Pair[] calldata erc20Pairs) internal {
        // transfer ERC20 tokens from the sender to this contract
        if (erc20Pairs.length > 0) {
            assembly {
                let ptr := mload(0x40)
                let end := add(erc20Pairs.offset, mul(erc20Pairs.length, 0x40))

                // selector for transferFrom(address,address,uint256)
                mstore(ptr, 0x23b872dd00000000000000000000000000000000000000000000000000000000)
                mstore(add(ptr, 0x04), caller())
                mstore(add(ptr, 0x24), address())
                for { let offset := erc20Pairs.offset } lt(offset, end) { offset := add(offset, 0x40) } {
                    let amount := calldataload(add(offset, 0x20))
                    if gt(amount, 0) {
                        mstore(add(ptr, 0x44), amount)
                        let success := call(gas(), calldataload(offset), 0, ptr, 0x64, 0, 0)
                    }
                }
            }
        }
    }

    function _returnDust(address[] calldata tokens) internal {
        // return remaining tokens (if any)
        for (uint256 i; i < tokens.length; ) {
            _transferERC20WithoutCheck(tokens[i], msg.sender, IERC20(tokens[i]).balanceOf(address(this)));
            unchecked { ++i; }
        }
    }
}

File 6 of 11 : IAggregator.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.15;


interface IAggregator {

    struct ERC20Pair {
        address token;
        uint256 amount;
    }

    function batchBuyWithETH(bytes calldata tradeBytes) external payable;

    function batchBuyWithERC20s(
        ERC20Pair[] calldata erc20Pairs,
        bytes calldata tradeBytes,
        address[] calldata dustTokens
    ) external payable;
}

File 7 of 11 : FixinTokenSpender.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.15;


/// @dev Helpers for moving tokens around.
abstract contract FixinTokenSpender {

    // Mask of the lower 20 bytes of a bytes32.
    uint256 constant private ADDRESS_MASK = (1 << 160) - 1;

    /// @dev Transfers ERC20 tokens from `owner` to `to`.
    /// @param token The token to spend.
    /// @param owner The owner of the tokens.
    /// @param to The recipient of the tokens.
    /// @param amount The amount of `token` to transfer.
    function _transferERC20From(address token, address owner, address to, uint256 amount) internal {
        uint256 success;
        assembly {
            let ptr := mload(0x40) // free memory pointer

            // selector for transferFrom(address,address,uint256)
            mstore(ptr, 0x23b872dd00000000000000000000000000000000000000000000000000000000)
            mstore(add(ptr, 0x04), and(owner, ADDRESS_MASK))
            mstore(add(ptr, 0x24), and(to, ADDRESS_MASK))
            mstore(add(ptr, 0x44), amount)

            success := call(gas(), and(token, ADDRESS_MASK), 0, ptr, 0x64, ptr, 32)

            let rdsize := returndatasize()

            // Check for ERC20 success. ERC20 tokens should return a boolean,
            // but some don't. We accept 0-length return data as success, or at
            // least 32 bytes that starts with a 32-byte boolean true.
            success := and(
                success,                             // call itself succeeded
                or(
                    iszero(rdsize),                  // no return data, or
                    and(
                        iszero(lt(rdsize, 32)),      // at least 32 bytes
                        eq(mload(ptr), 1)            // starts with uint256(1)
                    )
                )
            )
        }
        require(success != 0, "_transferERC20/TRANSFER_FAILED");
    }

    /// @dev Transfers ERC20 tokens from ourselves to `to`.
    /// @param token The token to spend.
    /// @param to The recipient of the tokens.
    /// @param amount The amount of `token` to transfer.
    function _transferERC20(address token, address to, uint256 amount) internal {
        uint256 success;
        assembly {
            let ptr := mload(0x40) // free memory pointer

            // selector for transfer(address,uint256)
            mstore(ptr, 0xa9059cbb00000000000000000000000000000000000000000000000000000000)
            mstore(add(ptr, 0x04), and(to, ADDRESS_MASK))
            mstore(add(ptr, 0x24), amount)

            success := call(gas(), and(token, ADDRESS_MASK), 0, ptr, 0x44, ptr, 32)

            let rdsize := returndatasize()

            // Check for ERC20 success. ERC20 tokens should return a boolean,
            // but some don't. We accept 0-length return data as success, or at
            // least 32 bytes that starts with a 32-byte boolean true.
            success := and(
                success,                             // call itself succeeded
                or(
                    iszero(rdsize),                  // no return data, or
                    and(
                        iszero(lt(rdsize, 32)),      // at least 32 bytes
                        eq(mload(ptr), 1)            // starts with uint256(1)
                    )
                )
            )
        }
        require(success != 0, "_transferERC20/TRANSFER_FAILED");
    }

    function _transferERC20FromWithoutCheck(address token, address owner, address to, uint256 amount) internal {
        assembly {
            if gt(amount, 0) {
                let ptr := mload(0x40) // free memory pointer

                // selector for transferFrom(address,address,uint256)
                mstore(ptr, 0x23b872dd00000000000000000000000000000000000000000000000000000000)
                mstore(add(ptr, 0x04), and(owner, ADDRESS_MASK))
                mstore(add(ptr, 0x24), and(to, ADDRESS_MASK))
                mstore(add(ptr, 0x44), amount)

                let success := call(gas(), and(token, ADDRESS_MASK), 0, ptr, 0x64, 0, 0)
            }
        }
    }

    function _transferERC20WithoutCheck(address token, address to, uint256 amount) internal {
        assembly {
            if gt(amount, 0) {
                let ptr := mload(0x40) // free memory pointer

                // selector for transfer(address,uint256)
                mstore(ptr, 0xa9059cbb00000000000000000000000000000000000000000000000000000000)
                mstore(add(ptr, 0x04), and(to, ADDRESS_MASK))
                mstore(add(ptr, 0x24), amount)

                let success := call(gas(), and(token, ADDRESS_MASK), 0, ptr, 0x44, 0, 0)
            }
        }
    }

    /// @dev Transfers some amount of ETH to the given recipient and
    ///      reverts if the transfer fails.
    /// @param recipient The recipient of the ETH.
    /// @param amount The amount of ETH to transfer.
    function _transferEth(address recipient, uint256 amount) internal {
        assembly {
            if gt(amount, 0) {
                if iszero(call(gas(), recipient, amount, 0, 0, 0, 0)) {
                    // revert("_transferEth/TRANSFER_FAILED")
                    mstore(0, 0x08c379a000000000000000000000000000000000000000000000000000000000)
                    mstore(0x20, 0x0000002000000000000000000000000000000000000000000000000000000000)
                    mstore(0x40, 0x0000001c5f7472616e736665724574682f5452414e534645525f4641494c4544)
                    mstore(0x60, 0)
                    revert(0, 0x64)
                }
            }
        }
    }
}

File 8 of 11 : Ownable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.15;

import "../storage/LibOwnableStorage.sol";


/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable {

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor() {
        if (owner() == address(0)) {
            _transferOwnership(msg.sender);
        }
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return LibOwnableStorage.getStorage().owner;
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        require(owner() == msg.sender, "Ownable: caller is not the owner");
        _;
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) private {
        LibOwnableStorage.Storage storage stor = LibOwnableStorage.getStorage();
        address oldOwner = stor.owner;
        stor.owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}

File 9 of 11 : ReentrancyGuard.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.15;

import "../storage/LibOwnableStorage.sol";


abstract contract ReentrancyGuard {

    constructor() {
        LibOwnableStorage.Storage storage stor = LibOwnableStorage.getStorage();
        if (stor.reentrancyStatus == 0) {
            stor.reentrancyStatus = 1;
        }
    }

    modifier nonReentrant() {
        LibOwnableStorage.Storage storage stor = LibOwnableStorage.getStorage();
        require(stor.reentrancyStatus == 1, "ReentrancyGuard: reentrant call");
        stor.reentrancyStatus = 2;
        _;
        stor.reentrancyStatus = 1;
    }
}

File 10 of 11 : LibFeatureStorage.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.15;


library LibFeatureStorage {

    uint256 constant STORAGE_ID_FEATURE = 1 << 128;

    struct Storage {
        // Mapping of methodID -> feature implementation
        mapping(bytes4 => address) featureImpls;
        // Mapping of feature implementation -> feature name
        mapping(address => string) featureNames;
        // Record methodIDs
        bytes4[] methodIDs;
        // Mapping of methodID -> method name
        mapping(bytes4 => string) methodNames;
    }

    /// @dev Get the storage bucket for this contract.
    function getStorage() internal pure returns (Storage storage stor) {
        // Dip into assembly to change the slot pointed to by the local
        // variable `stor`.
        // See https://solidity.readthedocs.io/en/v0.6.8/assembly.html?highlight=slot#access-to-external-variables-functions-and-libraries
        assembly { stor.slot := STORAGE_ID_FEATURE }
    }
}

File 11 of 11 : LibOwnableStorage.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.15;


library LibOwnableStorage {

    uint256 constant STORAGE_ID_OWNABLE = 2 << 128;

    struct Storage {
        uint256 reentrancyStatus;
        address owner;
    }

    /// @dev Get the storage bucket for this contract.
    function getStorage() internal pure returns (Storage storage stor) {
        assembly { stor.slot := STORAGE_ID_OWNABLE }
    }
}

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "libraries": {}
}

Contract Security Audit

Contract ABI

[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes4","name":"methodID","type":"bytes4"},{"indexed":false,"internalType":"address","name":"oldFeature","type":"address"},{"indexed":false,"internalType":"address","name":"newFeature","type":"address"}],"name":"FeatureFunctionUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"stateMutability":"payable","type":"fallback"},{"inputs":[{"internalType":"contract IERC20","name":"token","type":"address"},{"internalType":"address","name":"operator","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approveERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct IAggregator.ERC20Pair[]","name":"erc20Pairs","type":"tuple[]"},{"internalType":"bytes","name":"tradeBytes","type":"bytes"},{"internalType":"address[]","name":"dustTokens","type":"address[]"}],"name":"batchBuyWithERC20s","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes","name":"tradeBytes","type":"bytes"}],"name":"batchBuyWithETH","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"bytes","name":"","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":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","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":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC721Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC721Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"feature","type":"address"},{"internalType":"string","name":"name","type":"string"},{"components":[{"internalType":"bytes4","name":"methodID","type":"bytes4"},{"internalType":"string","name":"methodName","type":"string"}],"internalType":"struct Name3SwapV2.Method[]","name":"methods","type":"tuple[]"}],"internalType":"struct Name3SwapV2.Feature","name":"feature","type":"tuple"}],"name":"registerFeature","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"feature","type":"address"},{"internalType":"string","name":"name","type":"string"},{"components":[{"internalType":"bytes4","name":"methodID","type":"bytes4"},{"internalType":"string","name":"methodName","type":"string"}],"internalType":"struct Name3SwapV2.Method[]","name":"methods","type":"tuple[]"}],"internalType":"struct Name3SwapV2.Feature[]","name":"features","type":"tuple[]"}],"name":"registerFeatures","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"},{"internalType":"address","name":"recipient","type":"address"}],"name":"rescueERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"internalType":"address","name":"recipient","type":"address"}],"name":"rescueERC721","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"}],"name":"rescueETH","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4[]","name":"methodIDs","type":"bytes4[]"}],"name":"unregister","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]

60806040523480156200001157600080fd5b506000620000296200006860201b62000dab1760201c565b80549091506000036200003b57600181555b5060006200004862000070565b6001600160a01b0316036200006257620000623362000099565b62000106565b600160811b90565b6000620000876200006860201b62000dab1760201c565b600101546001600160a01b0316919050565b6000620000b06200006860201b62000dab1760201c565b6001810180546001600160a01b038581166001600160a01b031983168117909355604051939450169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3505050565b611af380620001166000396000f3fe6080604052600436106100f75760003560e01c8063a8e5e4aa1161008a578063d750e2a511610059578063d750e2a51461034b578063f0b9e5ba1461036b578063f23a6e6114610396578063f2fde38b146103c3576100fe565b8063a8e5e4aa146102bc578063ab65a1f7146102dc578063bc197c81146102fc578063c12e5d541461032b576100fe565b80634c674c2d116100c65780634c674c2d146102495780635d5788161461025c5780635d799f871461026f5780638da5cb5b1461028f576100fe565b806301ffc9a71461017c57806304824e70146101c2578063150b7a02146101e457806326e2dca214610229576100fe565b366100fe57005b600460008037600160801b602052604060002054806101555762461bcd60e51b600052600160e51b6020527c174e6f7420696d706c656d656e746564206d6574686f642e0000000000604052600060605260646000fd5b3660008037600080366000845af4610171573d6000803e3d6000fd5b503d6000803e3d6000f35b34801561018857600080fd5b506101ad6101973660046112cc565b6001600160e01b0319166301ffc9a760e01b1490565b60405190151581526020015b60405180910390f35b3480156101ce57600080fd5b506101e26101dd366004611312565b6103e3565b005b3480156101f057600080fd5b506102106101ff366004611377565b630a85bd0160e11b95945050505050565b6040516001600160e01b031990911681526020016101b9565b34801561023557600080fd5b506101e261024436600461142d565b610443565b6101e2610257366004611494565b6104ce565b6101e261026a3660046114d5565b61053a565b34801561027b57600080fd5b506101e261028a36600461159c565b6105d0565b34801561029b57600080fd5b506102a4610694565b6040516001600160a01b0390911681526020016101b9565b3480156102c857600080fd5b506101e26102d73660046115d5565b6106a9565b3480156102e857600080fd5b506101e26102f7366004611616565b610751565b34801561030857600080fd5b5061021061031736600461164b565b63bc197c8160e01b98975050505050505050565b34801561033757600080fd5b506101e2610346366004611709565b610a1b565b34801561035757600080fd5b506101e2610366366004611616565b610ca2565b34801561037757600080fd5b50610210610386366004611743565b63785cf2dd60e11b949350505050565b3480156103a257600080fd5b506102106103b136600461179e565b63f23a6e6160e01b9695505050505050565b3480156103cf57600080fd5b506101e26103de366004611312565b610d0b565b336103ec610694565b6001600160a01b03161461041b5760405162461bcd60e51b815260040161041290611807565b60405180910390fd5b60006001600160a01b0382166104315733610433565b815b905061043f8147610db3565b5050565b3361044c610694565b6001600160a01b0316146104725760405162461bcd60e51b815260040161041290611807565b6323b872dd60e01b600052306004528080156104915781602452610496565b336024525b50825b368110156104c75780356044526000806064600080895af16104bf573d6000803e3d6000fd5b602001610499565b5050505050565b3447036104db8383610e05565b8047036104e457005b804711156104fa57600080600080844703335af1005b60405162461bcd60e51b81526020600482015260156024820152742330b4b632b2103a37903932ba3ab9371022aa241760591b6044820152606401610412565b600160811b80546001146105905760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610412565b6002815561059e878761105f565b6105a88585610e05565b6105b283836110b6565b47156105c45760008060008047335af1505b60019055505050505050565b336105d9610694565b6001600160a01b0316146105ff5760405162461bcd60e51b815260040161041290611807565b60006001600160a01b0382166106155733610617565b815b6040516370a0823160e01b815230600482015290915061068f90849083906001600160a01b038316906370a0823190602401602060405180830381865afa158015610666573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061068a919061183c565b61118a565b505050565b6001600160811b01546001600160a01b031690565b336106b2610694565b6001600160a01b0316146106d85760405162461bcd60e51b815260040161041290611807565b60405163095ea7b360e01b81526001600160a01b0383811660048301526024820183905284169063095ea7b3906044016020604051808303816000875af1158015610727573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061074b9190611855565b50505050565b3361075a610694565b6001600160a01b0316146107805760405162461bcd60e51b815260040161041290611807565b6000600160801b815b8381101561086c5760008585838181106107a5576107a5611877565b90506020020160208101906107ba91906112cc565b6001600160e01b031981166000908152602085905260409020549091506001600160a01b03168015610814576001600160e01b03198216600090815260208590526040902080546001600160a01b03191690556001909401935b604080516001600160a01b0383168152600060208201526001600160e01b03198416917ff05686f2e12debc00665cd81463f2ae8ae5b4f167ea8dead964a3235a7d2a767910160405180910390a25050600101610789565b508160000361087b5750505050565b6002810180545b8015610a1357600082600183038154811061089f5761089f611877565b6000918252602080832060088304015460079092166004026101000a90910460e01b6001600160e01b031981168352908690526040909120549091506001600160a01b0316610a0957825482146109715782548390600019810190811061090857610908611877565b90600052602060002090600891828204019190066004029054906101000a900460e01b83600184038154811061094057610940611877565b90600052602060002090600891828204019190066004026101000a81548163ffffffff021916908360e01c02179055505b82548390600019810190811061098957610989611877565b90600052602060002090600891828204019190066004026101000a81549063ffffffff0219169055828054806109c1576109c161188d565b600082815260209020600860001990920191820401805463ffffffff600460078516026101000a021916905590556001859003610a015750505050505050565b600019909401935b5060001901610882565b505050505050565b33610a24610694565b6001600160a01b031614610a4a5760405162461bcd60e51b815260040161041290611807565b6000610a596020830183611312565b90506001600160a01b038116610ac35760405162461bcd60e51b815260206004820152602960248201527f7265676973746572466561747572653a20696e76616c696420666561747572656044820152681030b2323932b9b99760b91b6064820152608401610412565b600160801b610ad560208401846118a3565b6001600160a01b0384166000908152600184016020526040902091610afb91908361197f565b50366000610b0c6040860186611a3e565b9150915060005b81811015610a13576000838383818110610b2f57610b2f611877565b9050602002810190610b419190611a87565b610b4f9060208101906112cc565b6001600160e01b031981166000908152602087905260409020549091506001600160a01b031680610bbd57600286018054600181018255600091825260209091206008820401805463ffffffff60079093166004026101000a928302191660e085901c929092029190911790555b6001600160e01b03198216600090815260208790526040902080546001600160a01b0319166001600160a01b038916179055848484818110610c0157610c01611877565b9050602002810190610c139190611a87565b610c219060208101906118a3565b6001600160e01b031984166000908152600389016020526040902091610c4891908361197f565b50604080516001600160a01b038084168252891660208201526001600160e01b03198416917ff05686f2e12debc00665cd81463f2ae8ae5b4f167ea8dead964a3235a7d2a767910160405180910390a25050600101610b13565b33610cab610694565b6001600160a01b031614610cd15760405162461bcd60e51b815260040161041290611807565b60005b8181101561068f57610d03838383818110610cf157610cf1611877565b90506020028101906103469190611aa7565b600101610cd4565b33610d14610694565b6001600160a01b031614610d3a5760405162461bcd60e51b815260040161041290611807565b6001600160a01b038116610d9f5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610412565b610da881611229565b50565b600160811b90565b801561043f5760008060008084865af161043f5762461bcd60e51b600052600160e51b6020527c1c5f7472616e736665724574682f5452414e534645525f4641494c4544604052600060605260646000fd5b600080828401604051855b82811015610fec57803563ffffffff8160201c16945084601c830184378060f01c60018103610e7c5760008087866001600160a81b038660401c166e6c3852cbef3e08e8df289169ede5815af1610e7157610e6a82611048565b5050610fe2565b600196505050610fe2565b6103e78103610f215763ffffffff821663d0e30db08103610ee15760008088876001600160a81b038760401c1673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc25af1610ed557610ecd83611048565b505050610fe2565b60019750505050610fe2565b632e1a7d4d8103610f17576000808887600073c02aaa39b223fe8d0a0e5c4f27ead9083c756cc25af1610ed557610ecd83611048565b50610e6a82611048565b7f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e5630154600a81901a610f8a578160021a610e6a5762461bcd60e51b600052600160e51b602052700824b730b1ba34bb329036b0b935b2ba1760611b604052600060605260646000fd5b80600b1a610fbd5760008087866001600160a81b038660401c166001600160a01b0386165af1610e7157610e6a82611048565b60008087866001600160a01b0385165af4610fdb57610e6a82611048565b5050600194505b8301601c01610e10565b505050508061068f57811561068f573d61103e5762461bcd60e51b600052600160e51b6020527c134e6f206f72646572207375636365656465642e000000000000000000604052600060605260646000fd5b3d6000803e3d6000fd5b8060021a610da8573d61103e578060005260206000fd5b801561043f576040516040820283016323b872dd60e01b8252336004830152306024830152835b818110156104c757602081013580156110ad57806044850152600080606486600086355af1505b50604001611086565b60005b8181101561068f576111828383838181106110d6576110d6611877565b90506020020160208101906110eb9190611312565b338585858181106110fe576110fe611877565b90506020020160208101906111139190611312565b6040516370a0823160e01b81523060048201526001600160a01b0391909116906370a0823190602401602060405180830381865afa158015611159573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061117d919061183c565b611289565b6001016110b9565b600060405163a9059cbb60e01b81526001600160a01b038416600482015282602482015260208160448360006001600160a01b038a165af191503d60018251146020821015168115178316925050508060000361074b5760405162461bcd60e51b815260206004820152601e60248201527f5f7472616e7366657245524332302f5452414e534645525f4641494c454400006044820152606401610412565b6001600160811b0180546001600160a01b031981166001600160a01b03848116918217909355604051600160811b939092169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3505050565b801561068f5760405163a9059cbb60e01b81526001600160a01b038316600482015281602482015260008060448360006001600160a01b0389165af15050505050565b6000602082840312156112de57600080fd5b81356001600160e01b0319811681146112f657600080fd5b9392505050565b6001600160a01b0381168114610da857600080fd5b60006020828403121561132457600080fd5b81356112f6816112fd565b60008083601f84011261134157600080fd5b5081356001600160401b0381111561135857600080fd5b60208301915083602082850101111561137057600080fd5b9250929050565b60008060008060006080868803121561138f57600080fd5b853561139a816112fd565b945060208601356113aa816112fd565b93506040860135925060608601356001600160401b038111156113cc57600080fd5b6113d88882890161132f565b969995985093965092949392505050565b60008083601f8401126113fb57600080fd5b5081356001600160401b0381111561141257600080fd5b6020830191508360208260051b850101111561137057600080fd5b6000806000806060858703121561144357600080fd5b843561144e816112fd565b935060208501356001600160401b0381111561146957600080fd5b611475878288016113e9565b9094509250506040850135611489816112fd565b939692955090935050565b600080602083850312156114a757600080fd5b82356001600160401b038111156114bd57600080fd5b6114c98582860161132f565b90969095509350505050565b600080600080600080606087890312156114ee57600080fd5b86356001600160401b038082111561150557600080fd5b818901915089601f83011261151957600080fd5b81358181111561152857600080fd5b8a60208260061b850101111561153d57600080fd5b60209283019850965090880135908082111561155857600080fd5b6115648a838b0161132f565b9096509450604089013591508082111561157d57600080fd5b5061158a89828a016113e9565b979a9699509497509295939492505050565b600080604083850312156115af57600080fd5b82356115ba816112fd565b915060208301356115ca816112fd565b809150509250929050565b6000806000606084860312156115ea57600080fd5b83356115f5816112fd565b92506020840135611605816112fd565b929592945050506040919091013590565b6000806020838503121561162957600080fd5b82356001600160401b0381111561163f57600080fd5b6114c9858286016113e9565b60008060008060008060008060a0898b03121561166757600080fd5b8835611672816112fd565b97506020890135611682816112fd565b965060408901356001600160401b038082111561169e57600080fd5b6116aa8c838d016113e9565b909850965060608b01359150808211156116c357600080fd5b6116cf8c838d016113e9565b909650945060808b01359150808211156116e857600080fd5b506116f58b828c0161132f565b999c989b5096995094979396929594505050565b60006020828403121561171b57600080fd5b81356001600160401b0381111561173157600080fd5b8201606081850312156112f657600080fd5b6000806000806060858703121561175957600080fd5b8435611764816112fd565b93506020850135925060408501356001600160401b0381111561178657600080fd5b6117928782880161132f565b95989497509550505050565b60008060008060008060a087890312156117b757600080fd5b86356117c2816112fd565b955060208701356117d2816112fd565b9450604087013593506060870135925060808701356001600160401b038111156117fb57600080fd5b61158a89828a0161132f565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60006020828403121561184e57600080fd5b5051919050565b60006020828403121561186757600080fd5b815180151581146112f657600080fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052603160045260246000fd5b6000808335601e198436030181126118ba57600080fd5b8301803591506001600160401b038211156118d457600080fd5b60200191503681900382131561137057600080fd5b634e487b7160e01b600052604160045260246000fd5b600181811c9082168061191357607f821691505b60208210810361193357634e487b7160e01b600052602260045260246000fd5b50919050565b601f82111561068f57600081815260208120601f850160051c810160208610156119605750805b601f850160051c820191505b81811015610a135782815560010161196c565b6001600160401b03831115611996576119966118e9565b6119aa836119a483546118ff565b83611939565b6000601f8411600181146119de57600085156119c65750838201355b600019600387901b1c1916600186901b1783556104c7565b600083815260209020601f19861690835b82811015611a0f57868501358255602094850194600190920191016119ef565b5086821015611a2c5760001960f88860031b161c19848701351681555b505060018560011b0183555050505050565b6000808335601e19843603018112611a5557600080fd5b8301803591506001600160401b03821115611a6f57600080fd5b6020019150600581901b360382131561137057600080fd5b60008235603e19833603018112611a9d57600080fd5b9190910192915050565b60008235605e19833603018112611a9d57600080fdfea26469706673582212204fb1f70fae3d70ef3d074f37ff996ed4fe0fce2f3f2d8d9765dfed0541b50f2f64736f6c634300080f0033

Deployed Bytecode

0x6080604052600436106100f75760003560e01c8063a8e5e4aa1161008a578063d750e2a511610059578063d750e2a51461034b578063f0b9e5ba1461036b578063f23a6e6114610396578063f2fde38b146103c3576100fe565b8063a8e5e4aa146102bc578063ab65a1f7146102dc578063bc197c81146102fc578063c12e5d541461032b576100fe565b80634c674c2d116100c65780634c674c2d146102495780635d5788161461025c5780635d799f871461026f5780638da5cb5b1461028f576100fe565b806301ffc9a71461017c57806304824e70146101c2578063150b7a02146101e457806326e2dca214610229576100fe565b366100fe57005b600460008037600160801b602052604060002054806101555762461bcd60e51b600052600160e51b6020527c174e6f7420696d706c656d656e746564206d6574686f642e0000000000604052600060605260646000fd5b3660008037600080366000845af4610171573d6000803e3d6000fd5b503d6000803e3d6000f35b34801561018857600080fd5b506101ad6101973660046112cc565b6001600160e01b0319166301ffc9a760e01b1490565b60405190151581526020015b60405180910390f35b3480156101ce57600080fd5b506101e26101dd366004611312565b6103e3565b005b3480156101f057600080fd5b506102106101ff366004611377565b630a85bd0160e11b95945050505050565b6040516001600160e01b031990911681526020016101b9565b34801561023557600080fd5b506101e261024436600461142d565b610443565b6101e2610257366004611494565b6104ce565b6101e261026a3660046114d5565b61053a565b34801561027b57600080fd5b506101e261028a36600461159c565b6105d0565b34801561029b57600080fd5b506102a4610694565b6040516001600160a01b0390911681526020016101b9565b3480156102c857600080fd5b506101e26102d73660046115d5565b6106a9565b3480156102e857600080fd5b506101e26102f7366004611616565b610751565b34801561030857600080fd5b5061021061031736600461164b565b63bc197c8160e01b98975050505050505050565b34801561033757600080fd5b506101e2610346366004611709565b610a1b565b34801561035757600080fd5b506101e2610366366004611616565b610ca2565b34801561037757600080fd5b50610210610386366004611743565b63785cf2dd60e11b949350505050565b3480156103a257600080fd5b506102106103b136600461179e565b63f23a6e6160e01b9695505050505050565b3480156103cf57600080fd5b506101e26103de366004611312565b610d0b565b336103ec610694565b6001600160a01b03161461041b5760405162461bcd60e51b815260040161041290611807565b60405180910390fd5b60006001600160a01b0382166104315733610433565b815b905061043f8147610db3565b5050565b3361044c610694565b6001600160a01b0316146104725760405162461bcd60e51b815260040161041290611807565b6323b872dd60e01b600052306004528080156104915781602452610496565b336024525b50825b368110156104c75780356044526000806064600080895af16104bf573d6000803e3d6000fd5b602001610499565b5050505050565b3447036104db8383610e05565b8047036104e457005b804711156104fa57600080600080844703335af1005b60405162461bcd60e51b81526020600482015260156024820152742330b4b632b2103a37903932ba3ab9371022aa241760591b6044820152606401610412565b600160811b80546001146105905760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610412565b6002815561059e878761105f565b6105a88585610e05565b6105b283836110b6565b47156105c45760008060008047335af1505b60019055505050505050565b336105d9610694565b6001600160a01b0316146105ff5760405162461bcd60e51b815260040161041290611807565b60006001600160a01b0382166106155733610617565b815b6040516370a0823160e01b815230600482015290915061068f90849083906001600160a01b038316906370a0823190602401602060405180830381865afa158015610666573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061068a919061183c565b61118a565b505050565b6001600160811b01546001600160a01b031690565b336106b2610694565b6001600160a01b0316146106d85760405162461bcd60e51b815260040161041290611807565b60405163095ea7b360e01b81526001600160a01b0383811660048301526024820183905284169063095ea7b3906044016020604051808303816000875af1158015610727573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061074b9190611855565b50505050565b3361075a610694565b6001600160a01b0316146107805760405162461bcd60e51b815260040161041290611807565b6000600160801b815b8381101561086c5760008585838181106107a5576107a5611877565b90506020020160208101906107ba91906112cc565b6001600160e01b031981166000908152602085905260409020549091506001600160a01b03168015610814576001600160e01b03198216600090815260208590526040902080546001600160a01b03191690556001909401935b604080516001600160a01b0383168152600060208201526001600160e01b03198416917ff05686f2e12debc00665cd81463f2ae8ae5b4f167ea8dead964a3235a7d2a767910160405180910390a25050600101610789565b508160000361087b5750505050565b6002810180545b8015610a1357600082600183038154811061089f5761089f611877565b6000918252602080832060088304015460079092166004026101000a90910460e01b6001600160e01b031981168352908690526040909120549091506001600160a01b0316610a0957825482146109715782548390600019810190811061090857610908611877565b90600052602060002090600891828204019190066004029054906101000a900460e01b83600184038154811061094057610940611877565b90600052602060002090600891828204019190066004026101000a81548163ffffffff021916908360e01c02179055505b82548390600019810190811061098957610989611877565b90600052602060002090600891828204019190066004026101000a81549063ffffffff0219169055828054806109c1576109c161188d565b600082815260209020600860001990920191820401805463ffffffff600460078516026101000a021916905590556001859003610a015750505050505050565b600019909401935b5060001901610882565b505050505050565b33610a24610694565b6001600160a01b031614610a4a5760405162461bcd60e51b815260040161041290611807565b6000610a596020830183611312565b90506001600160a01b038116610ac35760405162461bcd60e51b815260206004820152602960248201527f7265676973746572466561747572653a20696e76616c696420666561747572656044820152681030b2323932b9b99760b91b6064820152608401610412565b600160801b610ad560208401846118a3565b6001600160a01b0384166000908152600184016020526040902091610afb91908361197f565b50366000610b0c6040860186611a3e565b9150915060005b81811015610a13576000838383818110610b2f57610b2f611877565b9050602002810190610b419190611a87565b610b4f9060208101906112cc565b6001600160e01b031981166000908152602087905260409020549091506001600160a01b031680610bbd57600286018054600181018255600091825260209091206008820401805463ffffffff60079093166004026101000a928302191660e085901c929092029190911790555b6001600160e01b03198216600090815260208790526040902080546001600160a01b0319166001600160a01b038916179055848484818110610c0157610c01611877565b9050602002810190610c139190611a87565b610c219060208101906118a3565b6001600160e01b031984166000908152600389016020526040902091610c4891908361197f565b50604080516001600160a01b038084168252891660208201526001600160e01b03198416917ff05686f2e12debc00665cd81463f2ae8ae5b4f167ea8dead964a3235a7d2a767910160405180910390a25050600101610b13565b33610cab610694565b6001600160a01b031614610cd15760405162461bcd60e51b815260040161041290611807565b60005b8181101561068f57610d03838383818110610cf157610cf1611877565b90506020028101906103469190611aa7565b600101610cd4565b33610d14610694565b6001600160a01b031614610d3a5760405162461bcd60e51b815260040161041290611807565b6001600160a01b038116610d9f5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610412565b610da881611229565b50565b600160811b90565b801561043f5760008060008084865af161043f5762461bcd60e51b600052600160e51b6020527c1c5f7472616e736665724574682f5452414e534645525f4641494c4544604052600060605260646000fd5b600080828401604051855b82811015610fec57803563ffffffff8160201c16945084601c830184378060f01c60018103610e7c5760008087866001600160a81b038660401c166e6c3852cbef3e08e8df289169ede5815af1610e7157610e6a82611048565b5050610fe2565b600196505050610fe2565b6103e78103610f215763ffffffff821663d0e30db08103610ee15760008088876001600160a81b038760401c1673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc25af1610ed557610ecd83611048565b505050610fe2565b60019750505050610fe2565b632e1a7d4d8103610f17576000808887600073c02aaa39b223fe8d0a0e5c4f27ead9083c756cc25af1610ed557610ecd83611048565b50610e6a82611048565b7f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e5630154600a81901a610f8a578160021a610e6a5762461bcd60e51b600052600160e51b602052700824b730b1ba34bb329036b0b935b2ba1760611b604052600060605260646000fd5b80600b1a610fbd5760008087866001600160a81b038660401c166001600160a01b0386165af1610e7157610e6a82611048565b60008087866001600160a01b0385165af4610fdb57610e6a82611048565b5050600194505b8301601c01610e10565b505050508061068f57811561068f573d61103e5762461bcd60e51b600052600160e51b6020527c134e6f206f72646572207375636365656465642e000000000000000000604052600060605260646000fd5b3d6000803e3d6000fd5b8060021a610da8573d61103e578060005260206000fd5b801561043f576040516040820283016323b872dd60e01b8252336004830152306024830152835b818110156104c757602081013580156110ad57806044850152600080606486600086355af1505b50604001611086565b60005b8181101561068f576111828383838181106110d6576110d6611877565b90506020020160208101906110eb9190611312565b338585858181106110fe576110fe611877565b90506020020160208101906111139190611312565b6040516370a0823160e01b81523060048201526001600160a01b0391909116906370a0823190602401602060405180830381865afa158015611159573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061117d919061183c565b611289565b6001016110b9565b600060405163a9059cbb60e01b81526001600160a01b038416600482015282602482015260208160448360006001600160a01b038a165af191503d60018251146020821015168115178316925050508060000361074b5760405162461bcd60e51b815260206004820152601e60248201527f5f7472616e7366657245524332302f5452414e534645525f4641494c454400006044820152606401610412565b6001600160811b0180546001600160a01b031981166001600160a01b03848116918217909355604051600160811b939092169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3505050565b801561068f5760405163a9059cbb60e01b81526001600160a01b038316600482015281602482015260008060448360006001600160a01b0389165af15050505050565b6000602082840312156112de57600080fd5b81356001600160e01b0319811681146112f657600080fd5b9392505050565b6001600160a01b0381168114610da857600080fd5b60006020828403121561132457600080fd5b81356112f6816112fd565b60008083601f84011261134157600080fd5b5081356001600160401b0381111561135857600080fd5b60208301915083602082850101111561137057600080fd5b9250929050565b60008060008060006080868803121561138f57600080fd5b853561139a816112fd565b945060208601356113aa816112fd565b93506040860135925060608601356001600160401b038111156113cc57600080fd5b6113d88882890161132f565b969995985093965092949392505050565b60008083601f8401126113fb57600080fd5b5081356001600160401b0381111561141257600080fd5b6020830191508360208260051b850101111561137057600080fd5b6000806000806060858703121561144357600080fd5b843561144e816112fd565b935060208501356001600160401b0381111561146957600080fd5b611475878288016113e9565b9094509250506040850135611489816112fd565b939692955090935050565b600080602083850312156114a757600080fd5b82356001600160401b038111156114bd57600080fd5b6114c98582860161132f565b90969095509350505050565b600080600080600080606087890312156114ee57600080fd5b86356001600160401b038082111561150557600080fd5b818901915089601f83011261151957600080fd5b81358181111561152857600080fd5b8a60208260061b850101111561153d57600080fd5b60209283019850965090880135908082111561155857600080fd5b6115648a838b0161132f565b9096509450604089013591508082111561157d57600080fd5b5061158a89828a016113e9565b979a9699509497509295939492505050565b600080604083850312156115af57600080fd5b82356115ba816112fd565b915060208301356115ca816112fd565b809150509250929050565b6000806000606084860312156115ea57600080fd5b83356115f5816112fd565b92506020840135611605816112fd565b929592945050506040919091013590565b6000806020838503121561162957600080fd5b82356001600160401b0381111561163f57600080fd5b6114c9858286016113e9565b60008060008060008060008060a0898b03121561166757600080fd5b8835611672816112fd565b97506020890135611682816112fd565b965060408901356001600160401b038082111561169e57600080fd5b6116aa8c838d016113e9565b909850965060608b01359150808211156116c357600080fd5b6116cf8c838d016113e9565b909650945060808b01359150808211156116e857600080fd5b506116f58b828c0161132f565b999c989b5096995094979396929594505050565b60006020828403121561171b57600080fd5b81356001600160401b0381111561173157600080fd5b8201606081850312156112f657600080fd5b6000806000806060858703121561175957600080fd5b8435611764816112fd565b93506020850135925060408501356001600160401b0381111561178657600080fd5b6117928782880161132f565b95989497509550505050565b60008060008060008060a087890312156117b757600080fd5b86356117c2816112fd565b955060208701356117d2816112fd565b9450604087013593506060870135925060808701356001600160401b038111156117fb57600080fd5b61158a89828a0161132f565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60006020828403121561184e57600080fd5b5051919050565b60006020828403121561186757600080fd5b815180151581146112f657600080fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052603160045260246000fd5b6000808335601e198436030181126118ba57600080fd5b8301803591506001600160401b038211156118d457600080fd5b60200191503681900382131561137057600080fd5b634e487b7160e01b600052604160045260246000fd5b600181811c9082168061191357607f821691505b60208210810361193357634e487b7160e01b600052602260045260246000fd5b50919050565b601f82111561068f57600081815260208120601f850160051c810160208610156119605750805b601f850160051c820191505b81811015610a135782815560010161196c565b6001600160401b03831115611996576119966118e9565b6119aa836119a483546118ff565b83611939565b6000601f8411600181146119de57600085156119c65750838201355b600019600387901b1c1916600186901b1783556104c7565b600083815260209020601f19861690835b82811015611a0f57868501358255602094850194600190920191016119ef565b5086821015611a2c5760001960f88860031b161c19848701351681555b505060018560011b0183555050505050565b6000808335601e19843603018112611a5557600080fd5b8301803591506001600160401b03821115611a6f57600080fd5b6020019150600581901b360382131561137057600080fd5b60008235603e19833603018112611a9d57600080fd5b9190910192915050565b60008235605e19833603018112611a9d57600080fdfea26469706673582212204fb1f70fae3d70ef3d074f37ff996ed4fe0fce2f3f2d8d9765dfed0541b50f2f64736f6c634300080f0033

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
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.