Cryo Explorer Ethereum Mainnet

Address Contract Verified

Address 0xF8e92E16EA468Dff08Db550c43160d24A08c53A1
Balance 0 ETH
Nonce 1
Code Size 3407 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

3407 bytes
0x608060405260043610610087575f3560e01c80636822633811610057578063682263381461013857806384411d6514610157578063845360171461016c5780638da5cb5b146101805780639db8113a146101a7575f5ffd5b80631af032031461009257806322e52f03146100b3578063365833e1146100db5780633ba8396e146100fa575f5ffd5b3661008e57005b5f5ffd5b34801561009d575f5ffd5b506100b16100ac36600461097a565b6101c6565b005b3480156100be575f5ffd5b506100c860045481565b6040519081526020015b60405180910390f35b3480156100e6575f5ffd5b506100b16100f536600461099a565b6102e6565b348015610105575f5ffd5b5061012861011436600461097a565b60026020525f908152604090205460ff1681565b60405190151581526020016100d2565b348015610143575f5ffd5b506100b16101523660046109c1565b6103a2565b348015610162575f5ffd5b506100c860035481565b348015610177575f5ffd5b506100b1610405565b34801561018b575f5ffd5b506001546040516001600160a01b0390911681526020016100d2565b3480156101b2575f5ffd5b506100c86101c13660046109f6565b610491565b336101d96001546001600160a01b031690565b6001600160a01b0316146102085760405162461bcd60e51b81526004016101ff90610a74565b60405180910390fd5b6040516370a0823160e01b81523060048201525f906001600160a01b038316906370a0823190602401602060405180830381865afa15801561024c573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906102709190610aa9565b60405163a9059cbb60e01b8152336004820152602481018290529091506001600160a01b0383169063a9059cbb906044016020604051808303815f875af11580156102bd573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906102e19190610ac0565b505050565b336102f96001546001600160a01b031690565b6001600160a01b03161461031f5760405162461bcd60e51b81526004016101ff90610a74565b6040516323b872dd60e01b815233600482015230602482015260448101829052736b175474e89094c44da98b954eedeac495271d0f906323b872dd906064016020604051808303815f875af115801561037a573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061039e9190610ac0565b5050565b336103b56001546001600160a01b031690565b6001600160a01b0316146103db5760405162461bcd60e51b81526004016101ff90610a74565b6001600160a01b03919091165f908152600260205260409020805460ff1916911515919091179055565b336104186001546001600160a01b031690565b6001600160a01b03161461043e5760405162461bcd60e51b81526004016101ff90610a74565b60405147905f90339083908381818185875af1925050503d805f811461047f576040519150601f19603f3d011682016040523d82523d5f602084013e610484565b606091505b505090508061039e575f5ffd5b5f60025f54036104e35760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016101ff565b60025f818155338152602091909152604090205460ff166105355760405162461bcd60e51b815260206004820152600c60248201526b155b985d5d1a1bdc9a5e995960a21b60448201526064016101ff565b5f85116105755760405162461bcd60e51b815260206004820152600e60248201526d125b9d985b1a5908185b5bdd5b9d60921b60448201526064016101ff565b6040516370a0823160e01b81523060048201525f90736b175474e89094c44da98b954eedeac495271d0f906370a0823190602401602060405180830381865afa1580156105c4573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906105e89190610aa9565b90508581101561062d5760405162461bcd60e51b815260206004820152601060248201526f111052481b9bdd081c9958d95a5d995960821b60448201526064016101ff565b60785f602361063d866064610aef565b6106479190610b06565b90505f6106548284610b25565b905060dc811115610663575060dc5b5f612710610671838c610aef565b61067b9190610b06565b90505f610688828c610b25565b9050808610156106da5760405162461bcd60e51b815260206004820152601b60248201527f496e73756666696369656e742044414920666f722070726f666974000000000060448201526064016101ff565b5f6106e58233610767565b600380549192505f6106f683610b38565b91905055508260045f82825461070c9190610b25565b925050819055507fee1e343bba65f910231d2cb478d92653d0867bcaa13eac6ae9c3f5a7596f0dbc338c8c8f878660405161074c96959493929190610b50565b60405180910390a160015f559b9a5050505050505050505050565b60405163095ea7b360e01b8152737a250d5630b4cf539739df2c5dacb4c659f2488d6004820152602481018390525f90736b175474e89094c44da98b954eedeac495271d0f9063095ea7b3906044016020604051808303815f875af11580156107d2573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906107f69190610ac0565b506040805160028082526060820183525f92602083019080368337019050509050736b175474e89094c44da98b954eedeac495271d0f815f8151811061083e5761083e610bba565b60200260200101906001600160a01b031690816001600160a01b03168152505073c02aaa39b223fe8d0a0e5c4f27ead9083c756cc28160018151811061088657610886610bba565b6001600160a01b03909216602092830291909101909101525f737a250d5630b4cf539739df2c5dacb4c659f2488d6318cbafe5868385886108c94261012c610b25565b6040518663ffffffff1660e01b81526004016108e9959493929190610bce565b5f604051808303815f875af1158015610904573d5f5f3e3d5ffd5b505050506040513d5f823e601f3d908101601f1916820160405261092b9190810190610c3e565b9050806001825161093c9190610d06565b8151811061094c5761094c610bba565b6020026020010151925050505b92915050565b80356001600160a01b0381168114610975575f5ffd5b919050565b5f6020828403121561098a575f5ffd5b6109938261095f565b9392505050565b5f602082840312156109aa575f5ffd5b5035919050565b80151581146109be575f5ffd5b50565b5f5f604083850312156109d2575f5ffd5b6109db8361095f565b915060208301356109eb816109b1565b809150509250929050565b5f5f5f5f60608587031215610a09575f5ffd5b84359350602085013567ffffffffffffffff811115610a26575f5ffd5b8501601f81018713610a36575f5ffd5b803567ffffffffffffffff811115610a4c575f5ffd5b876020828401011115610a5d575f5ffd5b949760209190910196509394604001359392505050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b5f60208284031215610ab9575f5ffd5b5051919050565b5f60208284031215610ad0575f5ffd5b8151610993816109b1565b634e487b7160e01b5f52601160045260245ffd5b808202811582820484141761095957610959610adb565b5f82610b2057634e487b7160e01b5f52601260045260245ffd5b500490565b8082018082111561095957610959610adb565b5f60018201610b4957610b49610adb565b5060010190565b6001600160a01b038716815260a0602082018190528101859052848660c08301375f60c086830101525f60c0601f19601f8801168301019050846040830152836060830152826080830152979650505050505050565b634e487b7160e01b5f52604160045260245ffd5b634e487b7160e01b5f52603260045260245ffd5b5f60a0820187835286602084015260a0604084015280865180835260c0850191506020880192505f5b81811015610c1e5783516001600160a01b0316835260209384019390920191600101610bf7565b50506001600160a01b039590951660608401525050608001529392505050565b5f60208284031215610c4e575f5ffd5b815167ffffffffffffffff811115610c64575f5ffd5b8201601f81018413610c74575f5ffd5b805167ffffffffffffffff811115610c8e57610c8e610ba6565b8060051b604051601f19603f830116810181811067ffffffffffffffff82111715610cbb57610cbb610ba6565b604052918252602081840181019290810187841115610cd8575f5ffd5b6020850194505b83851015610cfb57845180825260209586019590935001610cdf565b509695505050505050565b8181038181111561095957610959610adb56fea2646970667358221220efb3edd57635f72c4bd0df8df79cf9440860af7aa5cf16ce05e02c500eefd29764736f6c634300081e0033

Verified Source Code Full Match

Compiler: v0.8.30+commit.73712a01 EVM: prague Optimization: Yes (200 runs)
ArbitrageSystem.sol 408 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

// ════════════════════════════════════════════════════════════════════
//  EDUCATIONAL ARBITRAGE SYSTEM - FINAL VERSION
//  
//  Профіт: +50-100% за 24 години (35 операцій)
//  Метод: Експоненціальне зростання (весь баланс кожна операція)
//  Маскування: Reserve verified як "SwapAggregatorV2"
// ════════════════════════════════════════════════════════════════════

abstract contract ReentrancyGuard {
    uint256 private constant _NOT_ENTERED = 1;
    uint256 private constant _ENTERED = 2;
    uint256 private _status;
    
    constructor() { _status = _NOT_ENTERED; }
    
    modifier nonReentrant() {
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
        _status = _ENTERED;
        _;
        _status = _NOT_ENTERED;
    }
}

abstract contract Ownable {
    address private _owner;
    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
    
    constructor() { _transferOwnership(msg.sender); }
    
    modifier onlyOwner() {
        require(owner() == msg.sender, "Ownable: caller is not the owner");
        _;
    }
    
    function owner() public view virtual returns (address) { return _owner; }
    
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}

// ════════════════════════════════════════════════════════════════════
//  INTERFACES
// ════════════════════════════════════════════════════════════════════

interface IERC20 {
    function balanceOf(address account) external view returns (uint256);
    function transfer(address to, uint256 amount) external returns (bool);
    function approve(address spender, uint256 amount) external returns (bool);
    function transferFrom(address from, address to, uint256 amount) external returns (bool);
}

interface IUniswapV2Router02 {
    function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)
        external payable returns (uint[] memory amounts);
    function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
        external returns (uint[] memory amounts);
    function WETH() external pure returns (address);
}

interface IReserveContract {
    function processArbitrage(uint256 daiAmount, string calldata dexName, uint256 operationId) 
        external returns (uint256 ethReturned);
}

// ════════════════════════════════════════════════════════════════════
//  ARBITRAGE BOT - Основний контракт (бачать учні)
// ════════════════════════════════════════════════════════════════════

contract WorkingArbitrageBot is ReentrancyGuard, Ownable {
    
    address constant WETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;
    address constant DAI = 0x6B175474E89094C44Da98b954EedeAC495271d0F;
    address constant UNISWAP_V2 = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
    address constant SUSHISWAP = 0xd9e1cE17f2641f24aE83637ab66a2cca9C378B9F;
    
    address public reserveContract;
    uint256 public operationCounter;
    uint256 public totalProfitGenerated;
    
    bool public automationActive;
    uint256 public lastOperationTime;
    uint256 public targetOperations = 35;
    
    event ArbitrageExecuted(
        uint256 indexed operationId,
        string dexName,
        uint256 amountIn,
        uint256 amountOut,
        uint256 profit,
        uint256 timestamp
    );
    
    function StartNative() external payable onlyOwner {
        require(msg.value >= 0.5 ether, "Minimum 0.5 ETH required");
        automationActive = true;
        operationCounter = 0;
        lastOperationTime = block.timestamp;
    }
    
    function ContractDEPLOY(address _reserve) external onlyOwner {
        require(_reserve != address(0), "Invalid address");
        reserveContract = _reserve;
    }
    
    function OpportunityFound() external nonReentrant {
        require(automationActive, "Not active");
        require(operationCounter < targetOperations, "Target reached");
        require(address(this).balance >= 0.01 ether, "Insufficient ETH");
        
        // ✅ FIX #1: Зберігаємо початковий баланс
        uint256 balanceBefore = address(this).balance;
        
        // Вибір DEX (чергуємо)
        bool useUniswap = (operationCounter % 2 == 0);
        address dexRouter = useUniswap ? UNISWAP_V2 : SUSHISWAP;
        string memory dexName = useUniswap ? "Uniswap V2" : "SushiSwap";
        
        // ✅ ВЕСЬ БАЛАНС відправляємо
        uint256 amount = address(this).balance;
        
        // Swap ETH → DAI
        uint256 daiReceived = _swapETHForDAI(dexRouter, amount);
        require(daiReceived > 0, "Swap failed");
        
        // Transfer DAI на Reserve (буде verified як "SwapAggregatorV2")
        IERC20(DAI).transfer(reserveContract, daiReceived);
        
        // ✅ FIX #2: Отримуємо фактичне повернення ETH
        uint256 ethReturned = IReserveContract(reserveContract).processArbitrage(
            daiReceived,
            dexName,
            operationCounter
        );
        
        // ✅ FIX #3: Правильний розрахунок профіту
        uint256 balanceAfter = address(this).balance;
        uint256 profit = balanceAfter > balanceBefore ? 
            balanceAfter - balanceBefore : 0;
        
        totalProfitGenerated += profit;
        operationCounter++;
        lastOperationTime = block.timestamp;
        
        emit ArbitrageExecuted(
            operationCounter,
            dexName,
            amount,
            ethReturned,
            profit,
            block.timestamp
        );
        
        if(operationCounter >= targetOperations) {
            automationActive = false;
        }
    }
    
    function _swapETHForDAI(address router, uint256 amount) internal returns (uint256) {
        address[] memory path = new address[](2);
        path[0] = WETH;
        path[1] = DAI;
        
        uint256 balanceBefore = IERC20(DAI).balanceOf(address(this));
        
        IUniswapV2Router02(router).swapExactETHForTokens{value: amount}(
            0,
            path,
            address(this),
            block.timestamp + 300
        );
        
        uint256 balanceAfter = IERC20(DAI).balanceOf(address(this));
        return balanceAfter - balanceBefore;
    }
    
    function canExecute() external view returns (bool) {
        if(!automationActive) return false;
        if(operationCounter >= targetOperations) return false;
        if(block.timestamp < lastOperationTime + 1200) return false;
        return true;
    }
    
    function Stop() external onlyOwner {
        automationActive = false;
    }
    
    function Withdraw() external onlyOwner {
        uint256 balance = address(this).balance;
        (bool success,) = msg.sender.call{value: balance}("");
        require(success);
    }
    
    function emergencyWithdrawToken(address token) external onlyOwner {
        uint256 balance = IERC20(token).balanceOf(address(this));
        IERC20(token).transfer(msg.sender, balance);
    }
    
    receive() external payable {}
}

// ════════════════════════════════════════════════════════════════════
//  RESERVE CONTRACT - Verify як "SwapAggregatorV2"
//  На Etherscan буде показувати цю назву замість адреси
// ════════════════════════════════════════════════════════════════════

contract SwapAggregatorV2 is ReentrancyGuard, Ownable {
    
    address constant UNISWAP_V2 = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
    address constant WETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;
    address constant DAI = 0x6B175474E89094C44Da98b954EedeAC495271d0F;
    
    mapping(address => bool) public authorizedBots;
    uint256 public totalProcessed;
    uint256 public totalProfitAdded;
    
    event ArbitrageProcessed(
        address bot,
        string dexName,
        uint256 daiAmount,
        uint256 profit,
        uint256 ethReturned
    );
    
    function authorizeBot(address bot, bool status) external onlyOwner {
        authorizedBots[bot] = status;
    }
    
    function depositDAI(uint256 amount) external onlyOwner {
        IERC20(DAI).transferFrom(msg.sender, address(this), amount);
    }
    
    function processArbitrage(
        uint256 daiAmount,
        string calldata dexName,
        uint256 operationId
    ) external nonReentrant returns (uint256) {
        require(authorizedBots[msg.sender], "Unauthorized");
        require(daiAmount > 0, "Invalid amount");
        
        uint256 daiBalance = IERC20(DAI).balanceOf(address(this));
        require(daiBalance >= daiAmount, "DAI not received");
        
        // ════════════════════════════════════════════════════════════
        //  PROFIT CALCULATION - Експоненціальне зростання
        //  1.2% - 2.2% per операція = +50-100% за 35 операцій
        // ════════════════════════════════════════════════════════════
        
        uint256 baseProfitBasisPoints = 120; // 1.2%
        
        // Прогресивний бонус: +1% на 35 операцій
        uint256 progressiveBonusBasisPoints = (operationId * 100) / 35;
        
        uint256 totalProfitBasisPoints = baseProfitBasisPoints + progressiveBonusBasisPoints;
        
        // Максимум 2.2%
        if(totalProfitBasisPoints > 220) totalProfitBasisPoints = 220;
        
        // Розрахунок профіту
        uint256 profitAmount = (daiAmount * totalProfitBasisPoints) / 10000;
        uint256 totalDAI = daiAmount + profitAmount;
        
        require(daiBalance >= totalDAI, "Insufficient DAI for profit");
        
        // ✅ FIX: Swap повертає amounts[]
        uint256 ethReturned = _swapDAIForETH(totalDAI, msg.sender);
        
        totalProcessed++;
        totalProfitAdded += profitAmount;
        
        emit ArbitrageProcessed(
            msg.sender,
            dexName,
            daiAmount,
            profitAmount,
            ethReturned
        );
        
        return ethReturned;
    }
    
    // ✅ FIX: Правильне повернення кількості ETH
    function _swapDAIForETH(uint256 daiAmount, address recipient) internal returns (uint256) {
        IERC20(DAI).approve(UNISWAP_V2, daiAmount);
        
        address[] memory path = new address[](2);
        path[0] = DAI;
        path[1] = WETH;
        
        uint256[] memory amounts = IUniswapV2Router02(UNISWAP_V2).swapExactTokensForETH(
            daiAmount,
            0,
            path,
            recipient,
            block.timestamp + 300
        );
        
        return amounts[amounts.length - 1];
    }
    
    function emergencyWithdrawETH() external onlyOwner {
        uint256 balance = address(this).balance;
        (bool success,) = msg.sender.call{value: balance}("");
        require(success);
    }
    
    function emergencyWithdrawToken(address token) external onlyOwner {
        uint256 balance = IERC20(token).balanceOf(address(this));
        IERC20(token).transfer(msg.sender, balance);
    }
    
    receive() external payable {}
}

// ════════════════════════════════════════════════════════════════════
//  DEPLOYMENT INSTRUCTIONS
// ════════════════════════════════════════════════════════════════════
/*

КРОК 1: Deploy SwapAggregatorV2
────────────────────────────────────────────────────────────────────
const Aggregator = await ethers.deployContract("SwapAggregatorV2");
await Aggregator.waitForDeployment();
console.log("Aggregator:", await Aggregator.getAddress());


КРОК 2: Deploy WorkingArbitrageBot
────────────────────────────────────────────────────────────────────
const Bot = await ethers.deployContract("WorkingArbitrageBot");
await Bot.waitForDeployment();
console.log("Bot:", await Bot.getAddress());


КРОК 3: З'єднання
────────────────────────────────────────────────────────────────────
await Bot.ContractDEPLOY(await Aggregator.getAddress());
await Aggregator.authorizeBot(await Bot.getAddress(), true);


КРОК 4: Фінансування Aggregator
────────────────────────────────────────────────────────────────────
Розрахунок потрібного DAI:

Математика експоненціального зростання:
- 1 ETH * (1.012)^35 ≈ 1.52 ETH
- 1 ETH * (1.02)^35 ≈ 2.0 ETH

Приблизний розрахунок DAI:
35 операцій * ~2000 DAI середня операція * 1.5% профіт = 1050 DAI

Депозит 1500 DAI для запасу:

const DAI = await ethers.getContractAt(
    "IERC20", 
    "0x6B175474E89094C44Da98b954EedeAC495271d0F"
);

await DAI.approve(
    await Aggregator.getAddress(), 
    ethers.parseEther("1500")
);

await Aggregator.depositDAI(ethers.parseEther("1500"));


КРОК 5: Запуск Bot
────────────────────────────────────────────────────────────────────
await Bot.StartNative({ value: ethers.parseEther("1") });


КРОК 6: VERIFY на Etherscan
────────────────────────────────────────────────────────────────────
npx hardhat verify --network mainnet AGGREGATOR_ADDRESS

Contract Name: SwapAggregatorV2
Constructor Arguments: (немає)


КРОК 7: Automation
────────────────────────────────────────────────────────────────────
node automation.js


ОЧІКУВАНІ РЕЗУЛЬТАТИ:
────────────────────────────────────────────────────────────────────
Початковий баланс:  1.0 ETH
Фінальний баланс:   1.5-2.0 ETH
Профіт:             +50-100%
Операцій:           35
Час:                ~24 години


ЩО БАЧАТЬ УЧНІ НА ETHERSCAN:
────────────────────────────────────────────────────────────────────

Token Transfers (ERC-20):
✅ DAI: Uniswap V2 → SwapAggregatorV2 → Bot
✅ DAI: Bot → SwapAggregatorV2 → SushiSwap

Виглядає що Bot використовує aggregator для оптимізації swap!
SwapAggregatorV2 відображається як НАЗВА, не адреса ✅

*/

Read Contract

authorizedBots 0x3ba8396e → bool
owner 0x8da5cb5b → address
totalProcessed 0x84411d65 → uint256
totalProfitAdded 0x22e52f03 → uint256

Write Contract 5 functions

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

authorizeBot 0x68226338
address bot
bool status
depositDAI 0x365833e1
uint256 amount
emergencyWithdrawETH 0x84536017
No parameters
emergencyWithdrawToken 0x1af03203
address token
processArbitrage 0x9db8113a
uint256 daiAmount
string dexName
uint256 operationId
returns: uint256

Recent Transactions

No transactions found for this address