github.com/0xPolygon/supernets2-node@v0.0.0-20230711153321-2fe574524eaa/test/contracts/uniswap/v2/UniswapInterfaceMulticall.sol (about) 1 // SPDX-License-Identifier: MIT 2 pragma solidity =0.7.6; 3 pragma abicoder v2; 4 5 /// @notice A fork of Multicall2 specifically tailored for the Uniswap Interface 6 contract UniswapInterfaceMulticall { 7 struct Call { 8 address target; 9 uint256 gasLimit; 10 bytes callData; 11 } 12 13 struct Result { 14 bool success; 15 uint256 gasUsed; 16 bytes returnData; 17 } 18 19 function getCurrentBlockTimestamp() public view returns (uint256 timestamp) { 20 timestamp = block.timestamp; 21 } 22 23 function getEthBalance(address addr) public view returns (uint256 balance) { 24 balance = addr.balance; 25 } 26 27 function multicall(Call[] memory calls) public returns (uint256 blockNumber, Result[] memory returnData) { 28 blockNumber = block.number; 29 returnData = new Result[](calls.length); 30 for (uint256 i = 0; i < calls.length; i++) { 31 (address target, uint256 gasLimit, bytes memory callData) = 32 (calls[i].target, calls[i].gasLimit, calls[i].callData); 33 uint256 gasLeftBefore = gasleft(); 34 (bool success, bytes memory ret) = target.call{gas: gasLimit}(callData); 35 uint256 gasUsed = gasLeftBefore - gasleft(); 36 returnData[i] = Result(success, gasUsed, ret); 37 } 38 } 39 }