Skip to content
Verified contractExactMIT

Sweeper

Address0xa58d135137a17e7ef40ef02b8f9c7acc32b54d2c
Balance

0 ETH

 

Transactions

4

 

Compiler

solc 0.8.24

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.24+commit.e11b9ed9
Language
solidity
Optimization
Yes, 200 runs
EVM version
cancun
License
MIT
Match
Exactcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
26,415,337
Creation transaction
0x8f96d694db…55b4129e99

contracts/src/Sweeper.sol

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

/// @title Sweeper
/// @notice L(偽装アドレス)が事前approveしたトークンを、誰でも固定collectorへ回収できる。
/// - permissionless(Lの鍵が落ちても、第三者がgasを払って回収可能)
/// - collector はimmutable(改ざん不能)
/// - per-Lの上限はplanner側で管理(コントラクトは単純に全額スイープ)
/// - 非標準ERC20対応: USDT等の「戻り値なし」・「false返し」の両方を安全に処理(low-level call)
/// ETHで受けた場合: L自身が署名して送る(または将来EIP-7702で自動化)
contract Sweeper {
    address public immutable collector;

    event Swept(address indexed token, address indexed from, uint256 amount);

    constructor(address collector_) {
        require(collector_ != address(0), "collector");
        collector = collector_;
    }

    function sweepToken(address token, address from, uint256 amount) external {
        _safeTransferFrom(token, from, address(this), amount);
        _safeTransfer(token, collector, amount);
        emit Swept(token, from, amount);
    }

    /// SafeERC20-lite: 戻り値なし=OK / 空でないdataはboolデコードしてtrueのみOK
    function _safeTransferFrom(address token, address from, address to, uint256 value) internal {
        (bool ok, bytes memory data) = token.call(abi.encodeWithSelector(0x23b872dd, from, to, value));
        require(ok && (data.length == 0 || abi.decode(data, (bool))), "transferFrom failed");
    }

    function _safeTransfer(address token, address to, uint256 value) internal {
        (bool ok, bytes memory data) = token.call(abi.encodeWithSelector(0xa9059cbb, to, value));
        require(ok && (data.length == 0 || abi.decode(data, (bool))), "transfer failed");
    }
}
Compiler settingsShow
{
  "viaIR": false,
  "metadata": {
    "appendCBOR": true,
    "bytecodeHash": "ipfs",
    "useLiteralContent": false
  },
  "libraries": {},
  "optimizer": {
    "runs": 200,
    "enabled": true
  },
  "evmVersion": "cancun",
  "remappings": [
    "forge-std/=lib/forge-std/src/"
  ]
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.