Skip to content
Verified contractExactMIT

TropicalArbBot

Address0xa86378e6f9ee8bb3f50067c623ebbe1311e8b5fa
Balance

0 ETH

 

Transactions

149

 

Compiler

solc 0.8.30

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.30+commit.73712a01
Language
solidity
Optimization
No
License
MIT
Match
Exactcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
23,914,594
Creation transaction
0x18ec63bdc7…816b8de9cf

TropicalArbBot.sol

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

interface IERC20 {
    function totalSupply() external view returns (uint256);
    function balanceOf(address account) external view returns (uint256);
    function transfer(address recipient, uint256 amount)
        external
        returns (bool);
    function allowance(address owner, address spender)
        external
        view
        returns (uint256);
    function approve(address spender, uint256 amount)
        external
        returns (bool);
    function transferFrom(
        address sender,
        address recipient,
        uint256 amount
    ) external returns (bool);
}

/// ---------------------------------------------------------------
///  Router ufficiale Uniswap V2 COMPLETO (FIX PER REMIX)
/// ---------------------------------------------------------------
interface IUniswapV2Router02 {
    function swapExactTokensForTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external returns (uint[] memory amounts);

    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 getAmountsOut(uint amountIn, address[] calldata path)
        external
        view
        returns (uint[] memory amounts);
}

/// ---------------------------------------------------------------
///                TROPICAL ARBITRAGE CONTRACT
/// ---------------------------------------------------------------
contract TropicalArbBot {
    address public owner;

    constructor(address _owner) {
        owner = _owner;
    }

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

    /// -----------------------------------------------------------
    ///  ARBITRAGGIO ATOMICO A DUE DEX
    /// -----------------------------------------------------------
    function executeDualDexArb(
        address routerBuy,
        address routerSell,
        address[] calldata path,
        uint256 amountIn,
        uint256 minProfit
    ) external onlyOwner {
        require(path.length >= 2, "Path too short");

        IERC20 tokenIn = IERC20(path[0]);
        IERC20 tokenOut = IERC20(path[path.length - 1]);

        require(
            tokenIn.balanceOf(address(this)) >= amountIn,
            "Insufficient balance"
        );

        // -------------------------------------------------------
        // 1) BUY su routerBuy (tokenIn → tokenOut)
        // -------------------------------------------------------
        tokenIn.approve(routerBuy, 0);
        tokenIn.approve(routerBuy, amountIn);

        uint256[] memory amountsBuy = IUniswapV2Router02(routerBuy)
            .swapExactTokensForTokens(
                amountIn,
                0,
                path,
                address(this),
                block.timestamp + 60
            );

        uint256 boughtAmount = amountsBuy[amountsBuy.length - 1];

        // -------------------------------------------------------
        // 2) SELL su routerSell (tokenOut → tokenIn)
        // -------------------------------------------------------
        address[] memory reversePath = new address[](path.length);
        for (uint256 i = 0; i < path.length; i++) {
            reversePath[i] = path[path.length - 1 - i];
        }

        tokenOut.approve(routerSell, 0);
        tokenOut.approve(routerSell, boughtAmount);

        uint256[] memory amountsSell = IUniswapV2Router02(routerSell)
            .swapExactTokensForTokens(
                boughtAmount,
                0,
                reversePath,
                address(this),
                block.timestamp + 60
            );

        uint256 finalAmount = amountsSell[amountsSell.length - 1];

        // -------------------------------------------------------
        // 3) PROFITTO ATOMICO — se manca, la transazione REVERTE
        // -------------------------------------------------------
        require(
            finalAmount >= amountIn + minProfit,
            "No profit after round-trip"
        );
    }

    /// -----------------------------------------------------------
    ///  GESTIONE FONDI
    /// -----------------------------------------------------------
    function withdrawToken(address token, uint256 amount)
        external
        onlyOwner
    {
        IERC20(token).transfer(owner, amount);
    }

    function withdrawAll(address token) external onlyOwner {
        IERC20 t = IERC20(token);
        uint256 bal = t.balanceOf(address(this));
        t.transfer(owner, bal);
    }

    function withdrawETH(uint256 amount) external onlyOwner {
        payable(owner).transfer(amount);
    }

    receive() external payable {}
}
Compiler settingsShow
{
  "optimizer": {
    "runs": 200,
    "enabled": false
  },
  "remappings": []
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.