// File: contracts/common/Multicaller.sol



// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.9;

contract Multicaller {
    struct Call {
        address target;
        bytes data;
    }

    function multicall(Call[] calldata calls) external payable returns (bytes[] memory results) {
        require(msg.value == 0, "Only multicall with 0 value");
        results = new bytes[](calls.length);
        for (uint256 i = 0; i < calls.length; i++) {
            (bool success, bytes memory result) = calls[i].target.call(calls[i].data);

            if (!success) {
                // Next 5 lines from https://ethereum.stackexchange.com/a/83577
                if (result.length < 68) revert();
                assembly {
                    result := add(result, 0x04)
                }
                revert(abi.decode(result, (string)));
            }

            results[i] = result;
        }
    }
}