false
false
0

Contract Address Details

0x3E6A3EbbC9D88ACC192221797ad90BF72d391778

Contract Name
MulticallRouter
Creator
0x6dcb5e–32be33 at 0xea009a–7a723b
Balance
0 FTN ( )
Tokens
Fetching tokens...
Transactions
0 Transactions
Transfers
0 Transfers
Gas Used
Fetching gas used...
Last Balance Update
3872540
Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
Contract name:
MulticallRouter




Optimization enabled
true
Compiler version
v0.8.7+commit.e28d00a7




Optimization runs
2000
EVM Version
default




Verified at
2024-05-20T14:34:29.570556Z

contracts/periphery/MulticallRouter.sol

// SPDX-License-Identifier: GPL-3.0

pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/utils/Context.sol";
import "@uniswap/lib/contracts/libraries/TransferHelper.sol";
import "../utils/RevertMessageParser.sol";

/**
 * @title A contract that implements the chain of the calls on different contracts
 * @dev All function calls are currently implemented without side effects
 */
contract MulticallRouter is Context {
    /**
     * @notice Implements a chain of external calls
     * @param _amountIn input amount
     * @param _calldata array of encoded methods
     * @param _receiveSides array of contracts on which methods executions will take place
     * @param _path path of tokens
     * @param _offset array of shifts to patch the amount to calldata
     * @param _to address to send the dest token
     */
    function multicall(
        uint256 _amountIn,
        bytes[] memory _calldata,
        address[] memory _receiveSides,
        address[] memory _path,
        uint256[] memory _offset,
        address _to
    ) external {
        TransferHelper.safeTransferFrom(_path[0], _msgSender(), address(this), _amountIn);

        for (uint256 i = 0; i < _calldata.length; i++) {
            uint256 currentAmountIn = IERC20(_path[i]).balanceOf(address(this));
            bytes memory currentCalldata = _calldata[i];

            uint256 offset = _offset[i];
            assembly {
                mstore(add(currentCalldata, offset), currentAmountIn)
            }

            _lazyApprove(_path[i], _receiveSides[i], currentAmountIn);
            (bool success, bytes memory data) = _receiveSides[i].call(currentCalldata);
            if (!success) {
                revert(RevertMessageParser.getRevertMessage(data, "MulticallRouter: call failed"));
            }
        }

        uint256 finalAmountOut = IERC20(_path[_path.length - 1]).balanceOf(address(this));
        if (finalAmountOut != 0) {
            TransferHelper.safeTransfer(_path[_path.length - 1], _to, finalAmountOut);
        }
    }

    /**
     * @notice Implements approve
     * @dev Internal function used to approve the token spending
     * @param _token token address
     * @param _to address to approve
     * @param _amount amount for which approve will be given
     */
    function _lazyApprove(address _token, address _to, uint256 _amount) internal {
        if (IERC20(_token).allowance(address(this), _to) < _amount) {
            TransferHelper.safeApprove(_token, _to, type(uint256).max);
        }
    }
}
        

@openzeppelin/contracts/token/ERC20/IERC20.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @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 `recipient`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address recipient, 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 `sender` to `recipient` 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 sender,
        address recipient,
        uint256 amount
    ) external returns (bool);

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

@openzeppelin/contracts/utils/Context.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
}
          

@uniswap/lib/contracts/libraries/TransferHelper.sol

// SPDX-License-Identifier: GPL-3.0-or-later

pragma solidity >=0.6.0;

// helper methods for interacting with ERC20 tokens and sending ETH that do not consistently return true/false
library TransferHelper {
    function safeApprove(
        address token,
        address to,
        uint256 value
    ) internal {
        // bytes4(keccak256(bytes('approve(address,uint256)')));
        (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x095ea7b3, to, value));
        require(
            success && (data.length == 0 || abi.decode(data, (bool))),
            'TransferHelper::safeApprove: approve failed'
        );
    }

    function safeTransfer(
        address token,
        address to,
        uint256 value
    ) internal {
        // bytes4(keccak256(bytes('transfer(address,uint256)')));
        (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0xa9059cbb, to, value));
        require(
            success && (data.length == 0 || abi.decode(data, (bool))),
            'TransferHelper::safeTransfer: transfer failed'
        );
    }

    function safeTransferFrom(
        address token,
        address from,
        address to,
        uint256 value
    ) internal {
        // bytes4(keccak256(bytes('transferFrom(address,address,uint256)')));
        (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x23b872dd, from, to, value));
        require(
            success && (data.length == 0 || abi.decode(data, (bool))),
            'TransferHelper::transferFrom: transferFrom failed'
        );
    }

    function safeTransferETH(address to, uint256 value) internal {
        (bool success, ) = to.call{value: value}(new bytes(0));
        require(success, 'TransferHelper::safeTransferETH: ETH transfer failed');
    }
}
          

contracts/utils/RevertMessageParser.sol

// SPDX-License-Identifier: GPL-3.0

pragma solidity ^0.8.0;

library RevertMessageParser {
    function getRevertMessage(bytes memory _data, string memory _defaultMessage) internal pure returns (string memory) {
        // If the _data length is less than 68, then the transaction failed silently (without a revert message)
        if (_data.length < 68) return _defaultMessage;

        assembly {
            // Slice the sighash
            _data := add(_data, 0x04)
        }
        return abi.decode(_data, (string));
    }
}
          

Compiler Settings

{"outputSelection":{"*":{"*":["*"],"":["*"]}},"optimizer":{"runs":2000,"enabled":true},"libraries":{}}
              

Contract ABI

[{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"multicall","inputs":[{"type":"uint256","name":"_amountIn","internalType":"uint256"},{"type":"bytes[]","name":"_calldata","internalType":"bytes[]"},{"type":"address[]","name":"_receiveSides","internalType":"address[]"},{"type":"address[]","name":"_path","internalType":"address[]"},{"type":"uint256[]","name":"_offset","internalType":"uint256[]"},{"type":"address","name":"_to","internalType":"address"}]}]
              

Contract Creation Code

0x608060405234801561001057600080fd5b50610e21806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c80631e859a0514610030575b600080fd5b61004361003e366004610bb5565b610045565b005b6100718360008151811061005b5761005b610dbf565b602002602001015161006a3390565b30896103cd565b60005b85518110156102c057600084828151811061009157610091610dbf565b60209081029190910101516040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff909116906370a082319060240160206040518083038186803b15801561010257600080fd5b505afa158015610116573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061013a9190610b9c565b9050600087838151811061015057610150610dbf565b60200260200101519050600085848151811061016e5761016e610dbf565b6020026020010151905082818301526101ba87858151811061019257610192610dbf565b60200260200101518986815181106101ac576101ac610dbf565b602002602001015185610552565b6000808986815181106101cf576101cf610dbf565b602002602001015173ffffffffffffffffffffffffffffffffffffffff16846040516101fb9190610c7b565b6000604051808303816000865af19150503d8060008114610238576040519150601f19603f3d011682016040523d82523d6000602084013e61023d565b606091505b5091509150816102a857610286816040518060400160405280601c81526020017f4d756c746963616c6c526f757465723a2063616c6c206661696c656400000000815250610612565b60405162461bcd60e51b815260040161029f9190610c97565b60405180910390fd5b505050505080806102b890610d8e565b915050610074565b50600083600185516102d29190610d47565b815181106102e2576102e2610dbf565b60209081029190910101516040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff909116906370a082319060240160206040518083038186803b15801561035357600080fd5b505afa158015610367573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061038b9190610b9c565b905080156103c4576103c484600186516103a59190610d47565b815181106103b5576103b5610dbf565b60200260200101518383610648565b50505050505050565b6040805173ffffffffffffffffffffffffffffffffffffffff85811660248301528481166044830152606480830185905283518084039091018152608490920183526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f23b872dd00000000000000000000000000000000000000000000000000000000179052915160009283929088169161046c9190610c7b565b6000604051808303816000865af19150503d80600081146104a9576040519150601f19603f3d011682016040523d82523d6000602084013e6104ae565b606091505b50915091508180156104d85750805115806104d85750808060200190518101906104d89190610afc565b61054a5760405162461bcd60e51b815260206004820152603160248201527f5472616e7366657248656c7065723a3a7472616e7366657246726f6d3a20747260448201527f616e7366657246726f6d206661696c6564000000000000000000000000000000606482015260840161029f565b505050505050565b6040517fdd62ed3e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff838116602483015282919085169063dd62ed3e9060440160206040518083038186803b1580156105c257600080fd5b505afa1580156105d6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105fa9190610b9c565b101561060d5761060d83836000196107c4565b505050565b6060604483511015610625575080610642565b6004830192508280602001905181019061063f9190610b25565b90505b92915050565b6040805173ffffffffffffffffffffffffffffffffffffffff8481166024830152604480830185905283518084039091018152606490920183526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb0000000000000000000000000000000000000000000000000000000017905291516000928392908716916106df9190610c7b565b6000604051808303816000865af19150503d806000811461071c576040519150601f19603f3d011682016040523d82523d6000602084013e610721565b606091505b509150915081801561074b57508051158061074b57508080602001905181019061074b9190610afc565b6107bd5760405162461bcd60e51b815260206004820152602d60248201527f5472616e7366657248656c7065723a3a736166655472616e736665723a20747260448201527f616e73666572206661696c656400000000000000000000000000000000000000606482015260840161029f565b5050505050565b6040805173ffffffffffffffffffffffffffffffffffffffff8481166024830152604480830185905283518084039091018152606490920183526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f095ea7b300000000000000000000000000000000000000000000000000000000179052915160009283929087169161085b9190610c7b565b6000604051808303816000865af19150503d8060008114610898576040519150601f19603f3d011682016040523d82523d6000602084013e61089d565b606091505b50915091508180156108c75750805115806108c75750808060200190518101906108c79190610afc565b6107bd5760405162461bcd60e51b815260206004820152602b60248201527f5472616e7366657248656c7065723a3a73616665417070726f76653a2061707060448201527f726f7665206661696c6564000000000000000000000000000000000000000000606482015260840161029f565b803573ffffffffffffffffffffffffffffffffffffffff8116811461095d57600080fd5b919050565b600082601f83011261097357600080fd5b8135602061098861098383610cfb565b610cca565b80838252828201915082860187848660051b89010111156109a857600080fd5b60005b858110156109ce576109bc82610939565b845292840192908401906001016109ab565b5090979650505050505050565b600082601f8301126109ec57600080fd5b813560206109fc61098383610cfb565b80838252828201915082860187848660051b8901011115610a1c57600080fd5b60005b858110156109ce57813567ffffffffffffffff811115610a3e57600080fd5b8801603f81018a13610a4f57600080fd5b858101356040610a6161098383610d1f565b8281528c82848601011115610a7557600080fd5b828285018a8301376000928101890192909252508552509284019290840190600101610a1f565b600082601f830112610aad57600080fd5b81356020610abd61098383610cfb565b80838252828201915082860187848660051b8901011115610add57600080fd5b60005b858110156109ce57813584529284019290840190600101610ae0565b600060208284031215610b0e57600080fd5b81518015158114610b1e57600080fd5b9392505050565b600060208284031215610b3757600080fd5b815167ffffffffffffffff811115610b4e57600080fd5b8201601f81018413610b5f57600080fd5b8051610b6d61098382610d1f565b818152856020838501011115610b8257600080fd5b610b93826020830160208601610d5e565b95945050505050565b600060208284031215610bae57600080fd5b5051919050565b60008060008060008060c08789031215610bce57600080fd5b86359550602087013567ffffffffffffffff80821115610bed57600080fd5b610bf98a838b016109db565b96506040890135915080821115610c0f57600080fd5b610c1b8a838b01610962565b95506060890135915080821115610c3157600080fd5b610c3d8a838b01610962565b94506080890135915080821115610c5357600080fd5b50610c6089828a01610a9c565b925050610c6f60a08801610939565b90509295509295509295565b60008251610c8d818460208701610d5e565b9190910192915050565b6020815260008251806020840152610cb6816040850160208701610d5e565b601f01601f19169190910160400192915050565b604051601f8201601f1916810167ffffffffffffffff81118282101715610cf357610cf3610dd5565b604052919050565b600067ffffffffffffffff821115610d1557610d15610dd5565b5060051b60200190565b600067ffffffffffffffff821115610d3957610d39610dd5565b50601f01601f191660200190565b600082821015610d5957610d59610da9565b500390565b60005b83811015610d79578181015183820152602001610d61565b83811115610d88576000848401525b50505050565b6000600019821415610da257610da2610da9565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fdfea2646970667358221220d7a45fc4c18b696fc211688fb31d81bcf33c95afd6a104110b945e5a230dfef064736f6c63430008070033

Deployed ByteCode

0x608060405234801561001057600080fd5b506004361061002b5760003560e01c80631e859a0514610030575b600080fd5b61004361003e366004610bb5565b610045565b005b6100718360008151811061005b5761005b610dbf565b602002602001015161006a3390565b30896103cd565b60005b85518110156102c057600084828151811061009157610091610dbf565b60209081029190910101516040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff909116906370a082319060240160206040518083038186803b15801561010257600080fd5b505afa158015610116573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061013a9190610b9c565b9050600087838151811061015057610150610dbf565b60200260200101519050600085848151811061016e5761016e610dbf565b6020026020010151905082818301526101ba87858151811061019257610192610dbf565b60200260200101518986815181106101ac576101ac610dbf565b602002602001015185610552565b6000808986815181106101cf576101cf610dbf565b602002602001015173ffffffffffffffffffffffffffffffffffffffff16846040516101fb9190610c7b565b6000604051808303816000865af19150503d8060008114610238576040519150601f19603f3d011682016040523d82523d6000602084013e61023d565b606091505b5091509150816102a857610286816040518060400160405280601c81526020017f4d756c746963616c6c526f757465723a2063616c6c206661696c656400000000815250610612565b60405162461bcd60e51b815260040161029f9190610c97565b60405180910390fd5b505050505080806102b890610d8e565b915050610074565b50600083600185516102d29190610d47565b815181106102e2576102e2610dbf565b60209081029190910101516040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff909116906370a082319060240160206040518083038186803b15801561035357600080fd5b505afa158015610367573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061038b9190610b9c565b905080156103c4576103c484600186516103a59190610d47565b815181106103b5576103b5610dbf565b60200260200101518383610648565b50505050505050565b6040805173ffffffffffffffffffffffffffffffffffffffff85811660248301528481166044830152606480830185905283518084039091018152608490920183526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f23b872dd00000000000000000000000000000000000000000000000000000000179052915160009283929088169161046c9190610c7b565b6000604051808303816000865af19150503d80600081146104a9576040519150601f19603f3d011682016040523d82523d6000602084013e6104ae565b606091505b50915091508180156104d85750805115806104d85750808060200190518101906104d89190610afc565b61054a5760405162461bcd60e51b815260206004820152603160248201527f5472616e7366657248656c7065723a3a7472616e7366657246726f6d3a20747260448201527f616e7366657246726f6d206661696c6564000000000000000000000000000000606482015260840161029f565b505050505050565b6040517fdd62ed3e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff838116602483015282919085169063dd62ed3e9060440160206040518083038186803b1580156105c257600080fd5b505afa1580156105d6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105fa9190610b9c565b101561060d5761060d83836000196107c4565b505050565b6060604483511015610625575080610642565b6004830192508280602001905181019061063f9190610b25565b90505b92915050565b6040805173ffffffffffffffffffffffffffffffffffffffff8481166024830152604480830185905283518084039091018152606490920183526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb0000000000000000000000000000000000000000000000000000000017905291516000928392908716916106df9190610c7b565b6000604051808303816000865af19150503d806000811461071c576040519150601f19603f3d011682016040523d82523d6000602084013e610721565b606091505b509150915081801561074b57508051158061074b57508080602001905181019061074b9190610afc565b6107bd5760405162461bcd60e51b815260206004820152602d60248201527f5472616e7366657248656c7065723a3a736166655472616e736665723a20747260448201527f616e73666572206661696c656400000000000000000000000000000000000000606482015260840161029f565b5050505050565b6040805173ffffffffffffffffffffffffffffffffffffffff8481166024830152604480830185905283518084039091018152606490920183526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f095ea7b300000000000000000000000000000000000000000000000000000000179052915160009283929087169161085b9190610c7b565b6000604051808303816000865af19150503d8060008114610898576040519150601f19603f3d011682016040523d82523d6000602084013e61089d565b606091505b50915091508180156108c75750805115806108c75750808060200190518101906108c79190610afc565b6107bd5760405162461bcd60e51b815260206004820152602b60248201527f5472616e7366657248656c7065723a3a73616665417070726f76653a2061707060448201527f726f7665206661696c6564000000000000000000000000000000000000000000606482015260840161029f565b803573ffffffffffffffffffffffffffffffffffffffff8116811461095d57600080fd5b919050565b600082601f83011261097357600080fd5b8135602061098861098383610cfb565b610cca565b80838252828201915082860187848660051b89010111156109a857600080fd5b60005b858110156109ce576109bc82610939565b845292840192908401906001016109ab565b5090979650505050505050565b600082601f8301126109ec57600080fd5b813560206109fc61098383610cfb565b80838252828201915082860187848660051b8901011115610a1c57600080fd5b60005b858110156109ce57813567ffffffffffffffff811115610a3e57600080fd5b8801603f81018a13610a4f57600080fd5b858101356040610a6161098383610d1f565b8281528c82848601011115610a7557600080fd5b828285018a8301376000928101890192909252508552509284019290840190600101610a1f565b600082601f830112610aad57600080fd5b81356020610abd61098383610cfb565b80838252828201915082860187848660051b8901011115610add57600080fd5b60005b858110156109ce57813584529284019290840190600101610ae0565b600060208284031215610b0e57600080fd5b81518015158114610b1e57600080fd5b9392505050565b600060208284031215610b3757600080fd5b815167ffffffffffffffff811115610b4e57600080fd5b8201601f81018413610b5f57600080fd5b8051610b6d61098382610d1f565b818152856020838501011115610b8257600080fd5b610b93826020830160208601610d5e565b95945050505050565b600060208284031215610bae57600080fd5b5051919050565b60008060008060008060c08789031215610bce57600080fd5b86359550602087013567ffffffffffffffff80821115610bed57600080fd5b610bf98a838b016109db565b96506040890135915080821115610c0f57600080fd5b610c1b8a838b01610962565b95506060890135915080821115610c3157600080fd5b610c3d8a838b01610962565b94506080890135915080821115610c5357600080fd5b50610c6089828a01610a9c565b925050610c6f60a08801610939565b90509295509295509295565b60008251610c8d818460208701610d5e565b9190910192915050565b6020815260008251806020840152610cb6816040850160208701610d5e565b601f01601f19169190910160400192915050565b604051601f8201601f1916810167ffffffffffffffff81118282101715610cf357610cf3610dd5565b604052919050565b600067ffffffffffffffff821115610d1557610d15610dd5565b5060051b60200190565b600067ffffffffffffffff821115610d3957610d39610dd5565b50601f01601f191660200190565b600082821015610d5957610d59610da9565b500390565b60005b83811015610d79578181015183820152602001610d61565b83811115610d88576000848401525b50505050565b6000600019821415610da257610da2610da9565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fdfea2646970667358221220d7a45fc4c18b696fc211688fb31d81bcf33c95afd6a104110b945e5a230dfef064736f6c63430008070033