0

Please I need help here, I am new to flash loans. I want to understand flash loan transactions on ether scan , how to identify them, if the transaction make profit or not.

I am trying to implement a flash loan but i need to see other transactions to know or track flashable coins

1 Answer 1

1

You need to deploy a proxy contract to make the transaction atomically for you. And you need to revert the transaction if there isn't any profit. See my example:

 function arbitrage(address routerA, address routerB, address token) external onlyOwner returns(bool){

        address[] memory path2 = new address[](2);
        path2[0] = WETH;
        path2[1] = token;

        address cttAddress = address(this);

        uint amount = IERC20(WETH).balanceOf(cttAddress);
        IERC20(WETH).approve(routerA, amount);

        IUniswapV2Router02(routerA).swapExactTokensForTokensSupportingFeeOnTransferTokens(
            amount, 
            0, 
            path2, 
            cttAddress, 
            block.timestamp + 1200
        );      

        uint tokenBalance = IERC20(token).balanceOf(cttAddress);
        IERC20(token).approve(routerB, tokenBalance);

        address[] memory path = new address[](2);
        path[0] = token;
        path[1] = WETH;

        IUniswapV2Router02(routerB).swapExactTokensForTokensSupportingFeeOnTransferTokens(
            tokenBalance, 
            0, 
            path, 
            cttAddress, 
            block.timestamp + 1200
        );

        uint finalBalance = IERC20(WETH).balanceOf(cttAddress);
        require(finalBalance >= amount, "No profit");
        return true;
    }

Specifically this part: require(finalBalance >= amount, "No profit");

2
  • Ok thank you so much for the inside, i willl sure implement it. but please can i get a snap shot of a flashloan transaction from etherscan to know what the transaction look like? i will also want know what coins are profitable on flash loan, so i was thinking of knowing flash loan transactions so i can update my strategy from time to time
    – Soyaya
    Commented Jan 12, 2023 at 10:51
  • Go to the FlashLoan contract address on your blockchain of choice and check the event FlashLoan or something. Commented Jan 13, 2023 at 5:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.