Cryo Explorer Ethereum Mainnet

Address Contract Verified

Address 0xA76Af27Bd7C6C0fa129b39aB61938f3Ca7273d0c
Balance 0 ETH
Nonce 1
Code Size 2644 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

2644 bytes
0x608060405234801561000f575f5ffd5b5060043610610055575f3560e01c80631d8557d7146100595780632c3bbd391461006357806390a79be21461007f5780639e87d27b1461009b578063bae5c3da146100b7575b5f5ffd5b6100616100d3565b005b61007d600480360381019061007891906106be565b610152565b005b61009960048036038101906100949190610743565b6101f0565b005b6100b560048036038101906100b091906107a7565b610277565b005b6100d160048036038101906100cc91906107f7565b61046a565b005b7f0000000000000000000000001b7bc083290bc24eda9a24ff44ab974da44c752a73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461012a575f5ffd5b5f5f9054906101000a900460ff16155f5f6101000a81548160ff021916908315150217905550565b7f0000000000000000000000001b7bc083290bc24eda9a24ff44ab974da44c752a73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146101a9575f5ffd5b4173ffffffffffffffffffffffffffffffffffffffff166108fc8290811502906040515f60405180830381858888f193505050501580156101ec573d5f5f3e3d5ffd5b5050565b7f0000000000000000000000001b7bc083290bc24eda9a24ff44ab974da44c752a73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610247575f5ffd5b61026673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc285836104de565b61027184848461051f565b50505050565b7f0000000000000000000000001b7bc083290bc24eda9a24ff44ab974da44c752a73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146102ce575f5ffd5b808373ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401610308919061087d565b6020604051808303815f875af1158015610324573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061034891906108aa565b1015610389576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103809061092f565b60405180910390fd5b73c02aaa39b223fe8d0a0e5c4f27ead9083c756cc273ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16036104595773c02aaa39b223fe8d0a0e5c4f27ead9083c756cc273ffffffffffffffffffffffffffffffffffffffff16632e1a7d4d826040518263ffffffff1660e01b815260040161041d919061095c565b5f604051808303815f87803b158015610434575f5ffd5b505af1158015610446573d5f5f3e3d5ffd5b505050506104548282610579565b610465565b610464838383610626565b5b505050565b7f0000000000000000000000001b7bc083290bc24eda9a24ff44ab974da44c752a73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146104c1575f5ffd5b6104cc8486836104de565b6104d785848461051f565b5050505050565b7fa9059cbb000000000000000000000000000000000000000000000000000000005f5281600452806024525f5f60445f5f875af161051a575f5ffd5b505050565b5f7f022c0d9f000000000000000000000000000000000000000000000000000000008152826004820152816024820152306044820152608060648201525f60848201525f5f60a4835f885af1610573575f5ffd5b50505050565b5f8273ffffffffffffffffffffffffffffffffffffffff168260405161059e906109a2565b5f6040518083038185875af1925050503d805f81146105d8576040519150601f19603f3d011682016040523d82523d5f602084013e6105dd565b606091505b5050905080610621576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161061890610a00565b60405180910390fd5b505050565b6040517ea9059cbb000000000000000000000000000000000000000000000000000000815282600482015281602482015260205f6044835f885af18061066a575f5ffd5b3d156106805760205f833e815161067f575f5ffd5b5b5050505050565b5f5ffd5b5f819050919050565b61069d8161068b565b81146106a7575f5ffd5b50565b5f813590506106b881610694565b92915050565b5f602082840312156106d3576106d2610687565b5b5f6106e0848285016106aa565b91505092915050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f610712826106e9565b9050919050565b61072281610708565b811461072c575f5ffd5b50565b5f8135905061073d81610719565b92915050565b5f5f5f5f6080858703121561075b5761075a610687565b5b5f6107688782880161072f565b9450506020610779878288016106aa565b935050604061078a878288016106aa565b925050606061079b878288016106aa565b91505092959194509250565b5f5f5f606084860312156107be576107bd610687565b5b5f6107cb8682870161072f565b93505060206107dc8682870161072f565b92505060406107ed868287016106aa565b9150509250925092565b5f5f5f5f5f60a086880312156108105761080f610687565b5b5f61081d8882890161072f565b955050602061082e8882890161072f565b945050604061083f888289016106aa565b9350506060610850888289016106aa565b9250506080610861888289016106aa565b9150509295509295909350565b61087781610708565b82525050565b5f6020820190506108905f83018461086e565b92915050565b5f815190506108a481610694565b92915050565b5f602082840312156108bf576108be610687565b5b5f6108cc84828501610896565b91505092915050565b5f82825260208201905092915050565b7f62616c00000000000000000000000000000000000000000000000000000000005f82015250565b5f6109196003836108d5565b9150610924826108e5565b602082019050919050565b5f6020820190508181035f8301526109468161090d565b9050919050565b6109568161068b565b82525050565b5f60208201905061096f5f83018461094d565b92915050565b5f81905092915050565b50565b5f61098d5f83610975565b91506109988261097f565b5f82019050919050565b5f6109ac82610982565b9150819050919050565b7f65746800000000000000000000000000000000000000000000000000000000005f82015250565b5f6109ea6003836108d5565b91506109f5826109b6565b602082019050919050565b5f6020820190508181035f830152610a17816109de565b905091905056fea2646970667358221220b5b13d546f5f48603161cd121a3ea543431b7f728d5e07762d0704c3992d634c64736f6c634300081e0033

Verified Source Code Full Match

Compiler: v0.8.30+commit.73712a01 EVM: prague Optimization: No
Agent.sol 190 lines
// SPDX-License-Identifier: GPL-3.0

pragma solidity >=0.7.0 <0.9.0;

import "contracts/SafeERC20.sol";
import "contracts/IERC20.sol";
import "contracts/IUniswapV2Pair.sol";
import "contracts/IUniswapV2Router.sol";

library GasOptimize {
    // function selector for swap(uint,uint,address,bytes)
    bytes4 constant SWAP_SELECTOR = 0x022c0d9f;

    // selector for transfer(address,uint256)
    bytes4 constant TRANSFER_SELECTOR = 0xa9059cbb;

    function swap(address pair, uint amount0Out, uint amount1Out) internal {
        assembly {
             // use scratch space; we don't read returndata
            let ptr := 0x00
            // function selector: 0x022c0d9f
            mstore(ptr, 0x022c0d9f00000000000000000000000000000000000000000000000000000000)
            mstore(add(ptr,  4), amount0Out)              // arg0
            mstore(add(ptr, 36), amount1Out)              // arg1
            mstore(add(ptr, 68), address())               // arg2: to = this
            mstore(add(ptr,100), 0x80)                    // arg3: offset to bytes tail (128)
            mstore(add(ptr,132), 0)                       // bytes length = 0

            // call(pair, value=0, input=164 bytes, expect no return)
            if iszero(call(gas(), pair, 0, ptr, 164, 0, 0)) {
                revert(0, 0)
            }
        }
    }

    function transfer(address token, address to, uint256 amount) internal {
        assembly {
            // calldata: 0xa9059cbb | to | amount
            mstore(0x00, 0xa9059cbb00000000000000000000000000000000000000000000000000000000)
            mstore(0x04, to)
            mstore(0x24, amount)
            if iszero(call(gas(), token, 0, 0x00, 0x44, 0, 0)) {
                revert(0, 0)
            }
        }
    }
}

// This contract simply calls multiple targets sequentially, ensuring WETH balance before and after

contract Agent {
    // using SafeERC20 for IERC20;

    address private immutable owner;
    address private immutable executor;

    address private constant WETH_ADDR = address(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);
    IERC20 private constant WETH = IERC20(WETH_ADDR);
    // bytes4 private constant TRANSFER_SELECTOR = 0xa9059cbb;
    // bytes4 private constant SWAP_SELECTOR = 0x022c0d9f;
    bool state = false;

    modifier onlyExecutor() {
        require(msg.sender == executor);
        _;
    }

    modifier onlyOwner() {
        require(msg.sender == owner);
        _;
    }

    constructor() {
        executor = msg.sender;
        owner = address(0x1b7BC083290bc24EdA9a24ff44aB974Da44c752a);
    }

    // WETH -> token via pair, send WETH then swap
    function sB(address pairAddress, uint256 amount0Out, uint256 amount1Out, uint256 amountIn) external onlyExecutor {
        // WETH_ADDR.call(abi.encodeWithSelector(0xa9059cbb, pairAddress, amountIn));
        // _safeTransfer(WETH_ADDR, pairAddress, amountIn);
        // IUniswapV2Pair(pairAddress).swap(amount0Out, amount1Out, address(this), bytes(""));

        GasOptimize.transfer(WETH_ADDR, pairAddress, amountIn);
        GasOptimize.swap(pairAddress, amount0Out, amount1Out);
    }

    // token -> token via pair; forwards provided token amount then swap; tips miner with any ETH balance
    function sS(address pairAddress, address tokenAddress, uint256 amount0Out, uint256 amount1Out, uint256 amountIn) external onlyExecutor {
        // tokenAddress.call(abi.encodeWithSelector(0xa9059cbb, pairAddress, amountIn));
        // _safeTransfer(tokenAddress, pairAddress, amountIn);
        // IUniswapV2Pair(pairAddress).swap(amount0Out, amount1Out, address(this), bytes(""));

        GasOptimize.transfer(tokenAddress, pairAddress, amountIn);
        GasOptimize.swap(pairAddress, amount0Out, amount1Out);
    }

    // function sB_Ex(address _router, address _pair, address _token, uint256 amountIn, uint256 amountOutMin, bool token0) external onlyExecutor {
    //     IUniswapV2Pair pair = IUniswapV2Pair(_pair);
    //     IUniswapV2Router router = IUniswapV2Router(_router);
    //     address[] memory path =  new address[](2);
    //     path[0] = WETH_ADDR;
    //     path[1] = _token;
    //     uint256[] memory amounts = router.getAmountsOut(amountIn, path);
    //     require(amounts[1] >= amountOutMin, '!amountOutMin');
    //     WETH.transfer(_pair, amountIn);
    //     pair.swap(token0 ? 0 : amounts[1], token0 ? amounts[1] : 0, address(this), new bytes(0));
    // }

    // function sS_Ex(address _router, address _pair, address _token, uint256 amountOutMin, bool token0) external onlyExecutor payable {
    //     IUniswapV2Pair pair = IUniswapV2Pair(_pair);
    //     IERC20 token = IERC20(_token);
    //     uint256 balance = token.balanceOf(address(this));
    //     token.transfer(_pair, balance);
    //     IUniswapV2Router router = IUniswapV2Router(_router);
    //     address[] memory path =  new address[](2);
    //     path[0] = _token;
    //     path[1] = WETH_ADDR;
    //     uint256[] memory amounts = router.getAmountsOut(balance, path);
    //     require(amounts[1] >= amountOutMin, '!amountOutMin');
    //     pair.swap(token0 ? amounts[1] : 0, token0 ? 0 : amounts[1], address(this), new bytes(0));
    //     if (address(this).balance > 0) {
    //         block.coinbase.transfer(address(this).balance);
    //     }
    // }

    function sendBribe(uint256 amount) external onlyExecutor {
        block.coinbase.transfer(amount);
    }

    function updateState() external onlyExecutor {
        state = !state;
    }

    function sW(address _token, address _to, uint256 _amount) external onlyOwner {
        require(IERC20(_token).balanceOf(address(this)) >= _amount, "bal");
        if (_token == WETH_ADDR) {
            WETH.withdraw(_amount);
            _safeTransferETH(_to, _amount);
        } else {
            _safeTransfer(_token, _to, _amount); // works with USDT-style tokens
        }
    }

    // receive() external payable {
    // }

    // function call(address payable _to, uint256 _value, bytes calldata _data) external onlyOwner payable returns (bytes memory) {
    //     require(_to != address(0));
    //     (bool _success, bytes memory _result) = _to.call{value: _value}(_data);
    //     require(_success);
    //     return _result;
    // }

    // ===== internal helpers =====

    function _safeTransfer(address token, address to, uint256 value) internal {
        // (bool success, bytes memory data) = token.call(abi.encodeWithSelector(IERC20.transfer.selector, to, value));
        // (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0xa9059cbb, to, value));
        // require(success && (data.length == 0 || abi.decode(data, (bool))), "xfer");

        assembly {
            // Get free memory pointer
            let ptr := mload(0x40)
            // function selector for transfer(address,uint256) = 0xa9059cbb
            mstore(ptr, 0xa9059cbb000000000000000000000000000000000000000000000000000000)
            mstore(add(ptr, 4), to)      // arg1: to
            mstore(add(ptr, 36), value)  // arg2: value

            // call ERC20 token
            let result := call(gas(), token, 0, ptr, 68, 0, 32)

            // if call failed or (returndata present and not true) then revert
            if iszero(result) {
                revert(0, 0)
            }
            if returndatasize() {
                returndatacopy(ptr, 0, 32)
                if iszero(mload(ptr)) {
                    revert(0, 0)
                }
            }
        }
    }

    function _safeTransferETH(address to, uint256 value) internal {
        (bool ok, ) = to.call{value: value}("");
        require(ok, "eth");
    }
}
IUniswapV2Router.sol 23 lines
// SPDX-License-Identifier: GPL-3.0

pragma solidity >=0.7.0 <0.9.0;

interface IUniswapV2Router {
    function swapExactTokensForTokens(
        uint256 amountIn,
        uint256 amountOutMin,
        address[] calldata path,
        address to,
        uint256 deadline
    ) external returns (uint256[] memory amounts);

     function swapTokensForExactTokens(
        uint256 amountOut,
        uint256 amountInMax,
        address[] calldata path,
        address to,
        uint256 deadline
    ) external returns (uint256[] memory amounts);

    function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);
}
IUniswapV2Pair.sol 9 lines
// SPDX-License-Identifier: GPL-3.0

pragma solidity >=0.7.0 <0.9.0;

interface IUniswapV2Pair {
    function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;
    function token0() external view returns (address);
    function token1() external view returns (address);
}
IERC20.sol 10 lines
// SPDX-License-Identifier: GPL-3.0

pragma solidity >=0.7.0 <0.9.0;

interface IERC20 {
    function transfer(address to, uint value) external returns (bool);
    function balanceOf(address) external returns (uint256);
    function deposit() external payable;
    function withdraw(uint256 amount) external;
}
SafeERC20.sol 28 lines
// SPDX-License-Identifier: GPL-3.0

pragma solidity >=0.7.0 <0.9.0;

library SafeERC20 {
    function safeTransfer(address token, address to, uint256 amount) internal {
        (bool success, bytes memory data) = token.call(
            abi.encodeWithSelector(bytes4(keccak256("transfer(address,uint256)")), to, amount)
        );
        require(success, "Transfer failed");

        // If the token returns data, it should be true; if not, assume success
        if (data.length > 0) {
            require(abi.decode(data, (bool)), "Transfer returned false");
        }
    }

    function safeApprove(address token, address spender, uint256 amount) internal {
        (bool success, bytes memory data) = token.call(
            abi.encodeWithSelector(bytes4(keccak256("approve(address,uint256)")), spender, amount)
        );
        require(success, "Approve failed");

        if (data.length > 0) {
            require(abi.decode(data, (bool)), "Approve returned false");
        }
    }
}

Write Contract 5 functions

These functions modify contract state and require a wallet transaction to execute.

sB 0x90a79be2
address pairAddress
uint256 amount0Out
uint256 amount1Out
uint256 amountIn
sS 0xbae5c3da
address pairAddress
address tokenAddress
uint256 amount0Out
uint256 amount1Out
uint256 amountIn
sW 0x9e87d27b
address _token
address _to
uint256 _amount
sendBribe 0x2c3bbd39
uint256 amount
updateState 0x1d8557d7
No parameters

Token Balances (1)

View Transfers →
WETH 0

Recent Transactions

No transactions found for this address