Contract detail
PancakeInterfaceMulticallV2
PancakeInterfaceMulticallV2 is a verified Robinhood Chain smart contract at 0xcf05fc31…490dc985 with 0 indexed transactions.
- Address type
- Smart contract
- Transactions
- 0
- History coverage
- No indexed activity found
- Verification
- Verified
- Compiler
- v0.7.6+commit.7338295f
- Verification match
- partial
- Creation transaction
- 0x6b2169ce…7abf446a
- Created at block
- #537643
- Language
- solidity
- EVM version
- istanbul
- License
- none
- Compiler optimization
- Enabled · 1000000 runs
Verified contract
Contract source code
// SPDX-License-Identifier: MIT
pragma solidity =0.7.6;
pragma abicoder v2;
/// @notice A fork of MultiCall with gas limit
contract PancakeInterfaceMulticallV2 {
struct Call {
address target;
uint256 gasLimit;
bytes callData;
}
struct Result {
bool success;
uint256 gasUsed;
bytes returnData;
}
function multicall(Call[] memory calls) public returns (uint256 blockNumber, Result[] memory returnData) {
blockNumber = block.number;
returnData = new Result[](calls.length);
for (uint256 i = 0; i < calls.length; i++) {
(address target, uint256 gasLimit, bytes memory callData) =
(calls[i].target, calls[i].gasLimit, calls[i].callData);
uint256 gasLeftBefore = gasleft();
(bool success, bytes memory ret) = target.call{gas: gasLimit}(callData);
uint256 gasUsed = gasLeftBefore - gasleft();
returnData[i] = Result(success, gasUsed, ret);
}
}
function multicallWithGasLimitation(Call[] memory calls, uint256 gasBuffer)
public
returns (uint256 blockNumber, Result[] memory returnData, uint256 lastSuccessIndex)
{
blockNumber = block.number;
returnData = new Result[](calls.length);
for (uint256 i = 0; i < calls.length; i++) {
(address target, uint256 gasLimit, bytes memory callData) =
(calls[i].target, calls[i].gasLimit, calls[i].callData);
uint256 gasLeftBefore = gasleft();
(bool success, bytes memory ret) = target.call{gas: gasLimit}(callData);
uint256 gasUsed = gasLeftBefore - gasleft();
returnData[i] = Result(success, gasUsed, ret);
if (gasleft() < gasBuffer) {
return (blockNumber, returnData, i);
}
}
return (blockNumber, returnData, calls.length - 1);
}
function gaslimit() external view returns (uint256) {
return block.gaslimit;
}
function gasLeft() external view returns (uint256) {
return gasleft();
}
}