Проверенный контрактЧастичноеUNLICENSED
DelegatedSweeper
Адрес0xbdf32ab74e9155f02fd1245f449a6f1fac8cfad2
- Баланс
0 ETH
- Транзакций
1
- Компилятор
solc 0.8.28
- Тот же код
Только этот контракт
Подробности
- Компилятор
- solc 0.8.28+commit.7893614a
- Язык
- solidity
- Оптимизация
- Да, 200 прогонов
- Версия EVM
- cancun
- Лицензия
- UNLICENSED
- Совпадение
- Частичноекод создания: да, код в сети: да
- Проверен на Sourcify
- Создан в блоке
- 26 308 321
- Транзакция создания
- 0xe1e70433db…05e07e07a8
DelegatedSweeper.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.28;
/* Reconstructed source, not recovered original source.
* Compiles byte-for-byte to the observed executable runtime of
* 0x63e842B054Bd624a465454D533C33F573e9c6fAe at Ethereum block 26300770.
* Build: solc 0.8.28, viaIR=true, optimizer enabled/runs=200, evmVersion=cancun.
* Strip CBOR metadata using the final two-byte big-endian length, plus those
* two bytes: executable runtime = 1621 bytes; original metadata trailer = 53.
* All function, error, and event selector preimages have been identified.
* Function names confirmed by selector hashing; database matches alone do not
* prove original source spelling. Internal names and contract name are inferred.
*/
contract DelegatedSweeper {
address public constant authorizedCaller =
0x7C8601d4645b93cea45F71e118A729332e6B5CA0;
error NotAuthorized();
error TokenTransferFailed();
error ETHTransferFailed();
error ExecuteCallFailed(address account, bytes reason);
error NoCodeAtExecutor(address executor);
event SweepItemFailed(address indexed token, uint8 reason);
modifier onlyAuthorized() {
if (msg.sender != authorizedCaller) revert NotAuthorized();
_;
}
receive() external payable {}
function withdrawToken(
address token,
address payable to,
uint256 amount
) external onlyAuthorized {
_withdrawToken(token, to, amount);
}
function withdrawETH(address to, uint256 amount) external onlyAuthorized {
_withdrawETH(to, amount);
}
function _withdrawToken(
address token,
address payable to,
uint256 amount
) internal {
if (amount == 0) return;
(bool ok, ) = token.call(
abi.encodeWithSignature("transfer(address,uint256)", to, amount)
);
if (!ok) revert TokenTransferFailed();
}
function _withdrawETH(address to, uint256 amount) internal {
if (amount == 0) return;
(bool ok, ) = payable(to).call{value: amount}("");
if (!ok) revert ETHTransferFailed();
}
function sweep(
address payable to,
address[] calldata tokens
) external onlyAuthorized {
for (uint256 i = 0; i < tokens.length; i++) {
address token = tokens[i];
if (token == address(0)) {
uint256 balance = address(this).balance;
if (balance > 1 ether) {
(bool ok, ) = payable(to).call{value: balance - 1 ether}(
""
);
if (!ok) emit SweepItemFailed(token, 3);
}
} else {
(bool ok, bytes memory ret) = token.staticcall(
abi.encodeWithSignature("balanceOf(address)", address(this))
);
if (!ok || ret.length < 32) {
emit SweepItemFailed(token, 1);
continue;
}
uint256 balance = abi.decode(ret, (uint256));
if (balance > 0) {
(bool success, ) = token.call(
abi.encodeWithSignature(
"transfer(address,uint256)",
address(to),
balance
)
);
if (!success) emit SweepItemFailed(token, 2);
}
}
}
}
function callExecute(
address account,
address to,
uint256 value,
bytes calldata data
) external payable onlyAuthorized returns (bytes memory) {
if (account.code.length == 0) {
revert NoCodeAtExecutor(account);
}
(bool ok, bytes memory result) = account.call{value: msg.value}(
abi.encodeWithSelector(bytes4(0xb61d27f6), to, value, data)
);
if (!ok) revert ExecuteCallFailed(account, result);
return result;
}
}Настройки компилятораПоказать
{
"libraries": {},
"optimizer": {
"runs": 200,
"enabled": true
},
"evmVersion": "cancun"
}Исходный код и метаданные: Sourcify.
Исходный код принадлежит авторам контракта.