APE Price: $1.12 (+0.01%)

Contract Diff Checker

Contract Name:
GNSMulticall

Contract Source Code:

// SPDX-License-Identifier: MIT
pragma solidity 0.8.23;

import "../../interfaces/IMulticall.sol";
import "../../interfaces/IGeneralErrors.sol";

/**
 * @dev Facet #12: Multicall
 */
contract GNSMulticall is IMulticall {
    /// @inheritdoc IMulticall
    /// @dev NEVER make this function `payable`! delegatecall forwards msg.value to all calls regardless of it being spent or not
    function multicall(bytes[] calldata data) external returns (bytes[] memory results) {
        if (data.length > 20) {
            revert IGeneralErrors.AboveMax();
        }

        results = new bytes[](data.length);

        for (uint256 i; i < data.length; ++i) {
            (bool success, bytes memory result) = address(this).delegatecall(data[i]);

            if (!success) {
                assembly {
                    returndatacopy(0x00, 0x00, returndatasize())
                    revert(0x00, returndatasize())
                }
            }

            results[i] = result;
        }
    }
}

// SPDX-License-Identifier: MIT
pragma solidity 0.8.23;

/**
 * @dev Interface for errors potentially used in all libraries (general names)
 */
interface IGeneralErrors {
    error InitError();
    error InvalidAddresses();
    error InvalidAddress();
    error InvalidInputLength();
    error InvalidCollateralIndex();
    error WrongParams();
    error WrongLength();
    error WrongOrder();
    error WrongIndex();
    error BlockOrder();
    error Overflow();
    error ZeroAddress();
    error ZeroValue();
    error AlreadyExists();
    error DoesntExist();
    error Paused();
    error BelowMin();
    error AboveMax();
    error NotAuthorized();
    error WrongTradeType();
    error WrongOrderType();
    error InsufficientBalance();
    error UnsupportedChain();
}

// SPDX-License-Identifier: MIT
pragma solidity 0.8.23;

interface IMulticall {
    /**
     * @dev Call multiple functions in a single call.
     * @param data The data for the calls.
     * @return results The results of the calls.
     */
    function multicall(bytes[] calldata data) external returns (bytes[] memory results);
}

Please enter a contract address above to load the contract details and source code.

Context size (optional):