Files
smom-dbis-138/verification-sources/chain138-multicall/Multicall.sol
defiQUG df46ede3d8
Some checks failed
CI/CD Pipeline / Solidity Contracts (pull_request) Failing after 1m0s
CI/CD Pipeline / Security Scanning (pull_request) Successful in 2m32s
CI/CD Pipeline / Lint and Format (pull_request) Failing after 48s
CI/CD Pipeline / Terraform Validation (pull_request) Failing after 28s
CI/CD Pipeline / Kubernetes Validation (pull_request) Successful in 38s
HYBX OMNL TypeScript & anchor / token-aggregation build + reconcile artifact (pull_request) Failing after 42s
OMNL reconcile anchor / Run omnl:reconcile and upload artifacts (pull_request) Failing after 34s
Validation / validate-genesis (pull_request) Successful in 31s
Validation / validate-terraform (pull_request) Failing after 28s
Validation / validate-kubernetes (pull_request) Failing after 12s
Validation / validate-smart-contracts (pull_request) Failing after 11s
Validation / validate-security (pull_request) Failing after 1m31s
Validation / validate-documentation (pull_request) Failing after 19s
chore(verification): add Chain 138 verification sources and audit output
2026-07-12 13:20:31 -07:00

131 lines
3.9 KiB
Solidity

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
/**
* @title Multicall
* @notice Aggregate multiple calls in a single transaction
* @dev Based on Uniswap V3 Multicall
*/
contract Multicall {
struct Call {
address target;
bytes callData;
}
struct Result {
bool success;
bytes returnData;
}
/**
* @notice Aggregate multiple calls
* @param calls Array of calls to execute
* @return returnData Array of return data for each call
*/
function aggregate(Call[] memory calls) public returns (bytes[] memory returnData) {
returnData = new bytes[](calls.length);
for (uint256 i = 0; i < calls.length; i++) {
(bool success, bytes memory ret) = calls[i].target.call(calls[i].callData);
require(success, "Multicall: call failed");
returnData[i] = ret;
}
}
/**
* @notice Aggregate multiple calls, allowing failures
* @param requireSuccess If true, require all calls to succeed
* @param calls Array of calls to execute
* @return returnData Array of results with success flags and return data for each call
*/
function tryAggregate(bool requireSuccess, Call[] memory calls)
public
returns (Result[] memory returnData)
{
returnData = new Result[](calls.length);
for (uint256 i = 0; i < calls.length; i++) {
(bool success, bytes memory ret) = calls[i].target.call(calls[i].callData);
if (requireSuccess) {
require(success, "Multicall: call failed");
}
returnData[i] = Result(success, ret);
}
}
/**
* @notice Aggregate multiple calls with gas limit
* @param calls Array of calls to execute
* @param gasLimit Gas limit for each call
* @return returnData Array of return data for each call
*/
function aggregateWithGasLimit(Call[] memory calls, uint256 gasLimit)
public
returns (bytes[] memory returnData)
{
returnData = new bytes[](calls.length);
for (uint256 i = 0; i < calls.length; i++) {
(bool success, bytes memory ret) = calls[i].target.call{gas: gasLimit}(calls[i].callData);
require(success, "Multicall: call failed");
returnData[i] = ret;
}
}
/**
* @notice Get block hash for a specific block
* @param blockNumber Block number
* @return blockHash Block hash
*/
function getBlockHash(uint256 blockNumber) public view returns (bytes32 blockHash) {
blockHash = blockhash(blockNumber);
}
/**
* @notice Get current block timestamp
* @return timestamp Current block timestamp
*/
function getCurrentBlockTimestamp() public view returns (uint256 timestamp) {
timestamp = block.timestamp;
}
/**
* @notice Get current block difficulty
* @return difficulty Current block difficulty
*/
function getCurrentBlockDifficulty() public view returns (uint256 difficulty) {
difficulty = block.difficulty;
}
/**
* @notice Get current block gas limit
* @return gaslimit Current block gas limit
*/
function getCurrentBlockGasLimit() public view returns (uint256 gaslimit) {
gaslimit = block.gaslimit;
}
/**
* @notice Get current block coinbase
* @return coinbase Current block coinbase
*/
function getCurrentBlockCoinbase() public view returns (address coinbase) {
coinbase = block.coinbase;
}
/**
* @notice Get current block number
* @return blockNumber Current block number
*/
function getCurrentBlockNumber() public view returns (uint256 blockNumber) {
blockNumber = block.number;
}
/**
* @notice Get current chain ID
* @return chainid Current chain ID
*/
function getChainId() public view returns (uint256 chainid) {
chainid = block.chainid;
}
}