-
Notifications
You must be signed in to change notification settings - Fork 334
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add "IMulticall3" interface and "getTokenBalances" method (#271)
* feat: add "IMulticall3" interface chore: fix typos in comments feat: add "getTokenBalances" util refactor: add header separators in "StdUtils" refactor: order functions alphabetically in "StdUtils" * fix: set pragma to ">=0.6.2 <0.9.0" in IMulticall3 fix: add experimental ABIEncoderV2 pragma style: apply "forge fmt" fixes * test: add header separators in "StdUtils.t.sol" test: organize tests alphabetically in "StdUtils.t.sol" * test: add revert test for "getTokenBalances" * Revert "test: add revert test for "getTokenBalances"" This reverts commit c3bedee. * fix/test: fix multicall fork test * refactor: disallow EOAs in "getTokenBalances" test: write "getTokenBalances" test when address is EOA test: test USDC and SHIB holders with "getTokenBalances" * test: add empty array test for "getTokenBalances" chore: delete "console2" log import in "StdUtils.sol" * chore: fix parentheses direction * fix: backwards compatibility with older solc versions * refactor: pull fork call into setUp * fix: codesize check * chore: add comment Co-authored-by: Matt Solomon <[email protected]>
- Loading branch information
Showing
3 changed files
with
234 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity >=0.6.2 <0.9.0; | ||
|
||
pragma experimental ABIEncoderV2; | ||
|
||
interface IMulticall3 { | ||
struct Call { | ||
address target; | ||
bytes callData; | ||
} | ||
|
||
struct Call3 { | ||
address target; | ||
bool allowFailure; | ||
bytes callData; | ||
} | ||
|
||
struct Call3Value { | ||
address target; | ||
bool allowFailure; | ||
uint256 value; | ||
bytes callData; | ||
} | ||
|
||
struct Result { | ||
bool success; | ||
bytes returnData; | ||
} | ||
|
||
function aggregate(Call[] calldata calls) | ||
external | ||
payable | ||
returns (uint256 blockNumber, bytes[] memory returnData); | ||
|
||
function aggregate3(Call3[] calldata calls) external payable returns (Result[] memory returnData); | ||
|
||
function aggregate3Value(Call3Value[] calldata calls) external payable returns (Result[] memory returnData); | ||
|
||
function blockAndAggregate(Call[] calldata calls) | ||
external | ||
payable | ||
returns (uint256 blockNumber, bytes32 blockHash, Result[] memory returnData); | ||
|
||
function getBasefee() external view returns (uint256 basefee); | ||
|
||
function getBlockHash(uint256 blockNumber) external view returns (bytes32 blockHash); | ||
|
||
function getBlockNumber() external view returns (uint256 blockNumber); | ||
|
||
function getChainId() external view returns (uint256 chainid); | ||
|
||
function getCurrentBlockCoinbase() external view returns (address coinbase); | ||
|
||
function getCurrentBlockDifficulty() external view returns (uint256 difficulty); | ||
|
||
function getCurrentBlockGasLimit() external view returns (uint256 gaslimit); | ||
|
||
function getCurrentBlockTimestamp() external view returns (uint256 timestamp); | ||
|
||
function getEthBalance(address addr) external view returns (uint256 balance); | ||
|
||
function getLastBlockHash() external view returns (bytes32 blockHash); | ||
|
||
function tryAggregate(bool requireSuccess, Call[] calldata calls) | ||
external | ||
payable | ||
returns (Result[] memory returnData); | ||
|
||
function tryBlockAndAggregate(bool requireSuccess, Call[] calldata calls) | ||
external | ||
payable | ||
returns (uint256 blockNumber, bytes32 blockHash, Result[] memory returnData); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters