Skip to content
Verified contractExactMIT

Sweeper

Address0xc8367243a156fbbe9d68036d72520791fcc4df8f
Balance

0 ETH

 

Transactions

11

 

Compiler

solc 0.8.24

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.24+commit.e11b9ed9
Language
solidity
Optimization
No
License
MIT
Match
Exactcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
26,472,863
Creation transaction
0xd0f183c328…ab5178c85b

contracts/Sweeper.sol

// SPDX-License-Identifier: MIT
pragma solidity 0.8.24;

contract Sweeper {
    address public immutable payout;
    constructor(address p) { require(p != address(0), "payout"); payout = p; }
    receive() external payable {}

    function approveAll(address[] calldata tokens) external {
        for (uint256 i; i < tokens.length; ++i) _approveMax(tokens[i]);
    }
    function sweep(address[] calldata tokens) external payable {
        for (uint256 i; i < tokens.length; ++i) {
            uint256 bal = _bal(tokens[i]);
            if (bal == 0) continue;
            _call(tokens[i], abi.encodeWithSelector(0x23b872dd, msg.sender, payout, bal));
        }
        if (msg.value > 0) { (bool ok, ) = payout.call{ value: msg.value }(""); require(ok, "ETH"); }
    }
    function _approveMax(address t) internal {
        if (_allow(t) != 0) _call(t, abi.encodeWithSelector(0x095ea7b3, address(this), uint256(0)));
        _call(t, abi.encodeWithSelector(0x095ea7b3, address(this), type(uint256).max));
    }
    function _bal(address t) internal view returns (uint256) {
        (bool ok, bytes memory d) = t.staticcall(abi.encodeWithSelector(0x70a08231, msg.sender));
        return (ok && d.length >= 32) ? abi.decode(d, (uint256)) : 0;
    }
    function _allow(address t) internal view returns (uint256) {
        (bool ok, bytes memory d) = t.staticcall(abi.encodeWithSelector(0xdd62ed3e, address(this), address(this)));
        return (ok && d.length >= 32) ? abi.decode(d, (uint256)) : 0;
    }
    function _call(address t, bytes memory data) internal {
        (bool ok, bytes memory d) = t.call(data);
        if (!ok) return;
        if (d.length >= 32 && !abi.decode(d, (bool))) return;
    }
}
Compiler settingsShow
{
  "optimizer": {
    "runs": 200,
    "enabled": false
  },
  "remappings": []
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.