Contract Overview
My Name Tag:
Not Available, login to update
[ Download CSV Export ]
Latest 25 internal transaction
[ Download CSV Export ]
Contract Name:
ReservoirV6_0_1
Compiler Version
v0.8.17+commit.8df45f5f
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol) pragma solidity ^0.8.0; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor() { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { _nonReentrantBefore(); _; _nonReentrantAfter(); } function _nonReentrantBefore() private { // On the first call to nonReentrant, _status will be _NOT_ENTERED require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; } function _nonReentrantAfter() private { // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } /** * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a * `nonReentrant` function in the call stack. */ function _reentrancyGuardEntered() internal view returns (bool) { return _status == _ENTERED; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * * Furthermore, `isContract` will also return true if the target contract within * the same transaction is already scheduled for destruction by `SELFDESTRUCT`, * which only has an effect at the end of a transaction. * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.9; import {ReentrancyGuard} from "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import {Address} from "@openzeppelin/contracts/utils/Address.sol"; contract ReservoirV6_0_1 is ReentrancyGuard { using Address for address; // --- Structs --- struct ExecutionInfo { address module; bytes data; uint256 value; } struct AmountCheckInfo { address target; bytes data; uint256 threshold; } // --- Errors --- error UnsuccessfulExecution(); error UnsuccessfulPayment(); // --- Modifiers --- modifier refundETH() { _; uint256 leftover = address(this).balance; if (leftover > 0) { (bool success, ) = payable(msg.sender).call{value: leftover}(""); if (!success) { revert UnsuccessfulPayment(); } } } // --- Fallback --- receive() external payable {} // --- Public --- // Trigger a set of executions atomically function execute( ExecutionInfo[] calldata executionInfos ) external payable nonReentrant refundETH { uint256 length = executionInfos.length; for (uint256 i = 0; i < length; ) { _executeInternal(executionInfos[i]); unchecked { ++i; } } } // Trigger a set of executions with amount checking. As opposed to the regular // `execute` method, `executeWithAmountCheck` supports stopping the executions // once the provided amount check reaches a certain value. This is useful when // trying to fill orders with slippage (eg. provide multiple orders and try to // fill until a certain balance is reached). In order to be flexible, checking // the amount is done generically by calling the `target` contract with `data`. // For example, this could be used to check the ERC721 total owned balance (by // using `balanceOf(owner)`), the ERC1155 total owned balance per token id (by // using `balanceOf(owner, tokenId)`), but also for checking the ERC1155 total // owned balance per multiple token ids (by using a custom contract that wraps // `balanceOfBatch(owners, tokenIds)`). function executeWithAmountCheck( ExecutionInfo[] calldata executionInfos, AmountCheckInfo calldata amountCheckInfo ) external payable nonReentrant refundETH { // Cache some data for efficiency address target = amountCheckInfo.target; bytes calldata data = amountCheckInfo.data; uint256 threshold = amountCheckInfo.threshold; uint256 length = executionInfos.length; for (uint256 i = 0; i < length; ) { // Check the amount and break if it exceeds the threshold uint256 amount = _getAmount(target, data); if (amount >= threshold) { break; } _executeInternal(executionInfos[i]); unchecked { ++i; } } } // --- Internal --- function _executeInternal(ExecutionInfo calldata executionInfo) internal { address module = executionInfo.module; // Ensure the target is a contract if (!module.isContract()) { revert UnsuccessfulExecution(); } (bool success, ) = module.call{value: executionInfo.value}(executionInfo.data); if (!success) { revert UnsuccessfulExecution(); } } function _getAmount(address target, bytes calldata data) internal view returns (uint256 amount) { // Ensure the target is a contract if (!target.isContract()) { revert UnsuccessfulExecution(); } (bool success, bytes memory result) = target.staticcall(data); if (!success) { revert UnsuccessfulExecution(); } amount = abi.decode(result, (uint256)); } }
{ "viaIR": true, "optimizer": { "enabled": true, "runs": 200 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[],"name":"UnsuccessfulExecution","type":"error"},{"inputs":[],"name":"UnsuccessfulPayment","type":"error"},{"inputs":[{"components":[{"internalType":"address","name":"module","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"},{"internalType":"uint256","name":"value","type":"uint256"}],"internalType":"struct ReservoirV6_0_1.ExecutionInfo[]","name":"executionInfos","type":"tuple[]"}],"name":"execute","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"module","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"},{"internalType":"uint256","name":"value","type":"uint256"}],"internalType":"struct ReservoirV6_0_1.ExecutionInfo[]","name":"executionInfos","type":"tuple[]"},{"components":[{"internalType":"address","name":"target","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"},{"internalType":"uint256","name":"threshold","type":"uint256"}],"internalType":"struct ReservoirV6_0_1.AmountCheckInfo","name":"amountCheckInfo","type":"tuple"}],"name":"executeWithAmountCheck","outputs":[],"stateMutability":"payable","type":"function"},{"stateMutability":"payable","type":"receive"}]
Contract Creation Code
6080806040523461001b5760016000556103f390816100218239f35b600080fdfe60406080815260048036101561001f575b5050361561001d57600080fd5b005b600091823560e01c806304871891146100dd5763760f2a0b146100425750610010565b60203660031901126100d957813567ffffffffffffffff81116100d55761006c90369084016101f4565b6100746102c3565b845b8181106100b957505050824780610090575b506001815580f35b81808092335af161009f61022a565b50156100ac578281610088565b5163d2dcf4f360e01b8152fd5b806100cf6100ca600193858761028b565b610360565b01610076565b8380fd5b8280fd5b5060031981813601126100d55767ffffffffffffffff83358181116101f05761010990369086016101f4565b926024359283116101ec5760608387019184360301126101ec5760449061012e6102c3565b61014561013a82610319565b91602486019061032d565b929094013591885b86811061016b575b5050505050505082478061009057506001815580f35b823b156101dc578980895184898237808581018381520390865afa61018e61022a565b90156101cc57602080828051810103126101c8578591015110156101c357806101bd6100ca6001938a8961028b565b0161014d565b610155565b8b80fd5b8851635589343b60e11b81528a90fd5b8751635589343b60e11b81528990fd5b8680fd5b8580fd5b9181601f840112156102255782359167ffffffffffffffff8311610225576020808501948460051b01011161022557565b600080fd5b3d156102865767ffffffffffffffff903d8281116102705760405192601f8201601f19908116603f01168401908111848210176102705760405282523d6000602084013e565b634e487b7160e01b600052604160045260246000fd5b606090565b91908110156102ad5760051b81013590605e1981360301821215610225570190565b634e487b7160e01b600052603260045260246000fd5b6002600054146102d4576002600055565b60405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606490fd5b356001600160a01b03811681036102255790565b903590601e1981360301821215610225570180359067ffffffffffffffff82116102255760200191813603831361022557565b61036981610319565b803b156103ab578160406000939261038560208695018461032d565b92908382519485928337810186815203930135905af16103a361022a565b50156103ab57565b604051635589343b60e11b8152600490fdfea2646970667358221220ce1d7e58645bc5b9b56d7d97491dc6b1dac67f3bc9bc72e2cd48e0f078f3392764736f6c63430008110033
Deployed Bytecode
0x60406080815260048036101561001f575b5050361561001d57600080fd5b005b600091823560e01c806304871891146100dd5763760f2a0b146100425750610010565b60203660031901126100d957813567ffffffffffffffff81116100d55761006c90369084016101f4565b6100746102c3565b845b8181106100b957505050824780610090575b506001815580f35b81808092335af161009f61022a565b50156100ac578281610088565b5163d2dcf4f360e01b8152fd5b806100cf6100ca600193858761028b565b610360565b01610076565b8380fd5b8280fd5b5060031981813601126100d55767ffffffffffffffff83358181116101f05761010990369086016101f4565b926024359283116101ec5760608387019184360301126101ec5760449061012e6102c3565b61014561013a82610319565b91602486019061032d565b929094013591885b86811061016b575b5050505050505082478061009057506001815580f35b823b156101dc578980895184898237808581018381520390865afa61018e61022a565b90156101cc57602080828051810103126101c8578591015110156101c357806101bd6100ca6001938a8961028b565b0161014d565b610155565b8b80fd5b8851635589343b60e11b81528a90fd5b8751635589343b60e11b81528990fd5b8680fd5b8580fd5b9181601f840112156102255782359167ffffffffffffffff8311610225576020808501948460051b01011161022557565b600080fd5b3d156102865767ffffffffffffffff903d8281116102705760405192601f8201601f19908116603f01168401908111848210176102705760405282523d6000602084013e565b634e487b7160e01b600052604160045260246000fd5b606090565b91908110156102ad5760051b81013590605e1981360301821215610225570190565b634e487b7160e01b600052603260045260246000fd5b6002600054146102d4576002600055565b60405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606490fd5b356001600160a01b03811681036102255790565b903590601e1981360301821215610225570180359067ffffffffffffffff82116102255760200191813603831361022557565b61036981610319565b803b156103ab578160406000939261038560208695018461032d565b92908382519485928337810186815203930135905af16103a361022a565b50156103ab57565b604051635589343b60e11b8152600490fdfea2646970667358221220ce1d7e58645bc5b9b56d7d97491dc6b1dac67f3bc9bc72e2cd48e0f078f3392764736f6c63430008110033
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.