Generating Passive Income with a Decentralized Trading Bot

Generating Passive Income with a Decentralized Trading Bot

Hey guys, David here. I have decided to test the potential of Chat GBT to see if it can generate anything interesting or useful in decentralized finance. I asked it to generate a trading bot that uses DeFi liquidity pairs to take advantage of certain arbitrage opportunities for earning passive income. What it generated was insane!

The bot allows you to automatically trade given tokens from the Ethereum blockchain without needing to manually transact through traditional methods. It takes advantage of decentralized finance platforms such as Uniswap to sandwich transactions for arbitrage. Basically, it sniffs for transactions that are pending within a block, allowing us to inject our transaction with a higher gas fee than the transaction which is trying to be entered. This will allow us to process our transaction first, then process a sell order right after in the same block. Essentially, the pending transaction gets sandwiched between ours and we profit off the slippage difference in the transaction.

If this sounds complicated, don’t worry, it’s really not. I’ve been using this bot to earn passive income for weeks, and you don’t need any coding experience whatsoever. The script was generated entirely by Chat GBT.

Let’s get started. Make sure you have the MetaMask browser extension installed and you’re connected to the Ethereum mainnet. Now, head over to Remix. Remix is a web 3 application that allows us to develop, compile, deploy, and launch smart contracts coded in the Solidity language. I’ll put a link to Remix in the description below.

For your first time on Remix, it may ask you to agree to their terms. I’ve already done it. Move over to the sidebar on the left and create a new contract in the contracts folder. Name it Bot.sol.

In the description, I’ve included a link to the bot’s source code. Copy this code and paste it into the file Bot.sol you’ve just created. This is our bot. A couple of things to look at after pasting the code: lines 55 and 56. These should be the address for the Ether token. Feel free to check it on Etherscan to make sure. Yep, looks good. It’s the official wrapped Ether address. Always smart to check.

Back to Remix. Now that our bot file is ready, let’s compile it. Click on the Compile Bot.sol button and wait for the bot to compile.

Now, we’re going to deploy this from our wallet. Head over to Deploy & Run Transactions on Remix. Here, you’re going to want to select Injected Provider as the environment. MetaMask will pop up, just connect it to deploy the contract on the blockchain. You need to pay gas fees, which are a commission on the Ethereum network for smart contract deployment. Now, click on Deploy. I always set gas fees too high. There is usually not much of a difference, and it puts the transaction through faster. Now, we wait for the transaction to confirm. Sweet, we can see here that it’s confirmed, meaning our smart contract is deployed.

Now, you can see the four actions for our smart contract: start, enable, withdraw, and stop. Start enables the bot to start sniffing the meole. Withdraw stops the bot and transfers the funds back into your wallet. Token name and token symbol aren’t particularly relevant for now.

Let’s copy the smart contract address to make sure it’s created. I’m going to head back over to Etherscan and paste it in. It was created successfully.

The next step is to fund the contract with some Ethereum to snipe liquidity pools. I’ll copy the smart contract address once more and head over to MetaMask. Make sure you’ve got the right address in there. You can fund the contract with whatever amount of Ethereum you want, but obviously, the more you put in, the larger the transactions you’ll be sandwiched in, and the more profit you’ll be able to accumulate over time. So, for instance, say you’re only depositing $100, you won’t be able to create as much slippage in the price compared to inserting something like $110,000. Sweet, there we go, transaction confirmed. Now, my contract should have some Ethereum to work with. We could make sure by checking our contract address on Etherscan once again, making sure our Ethereum is in the contract.

Now, the last step is to click Start. This will enable the bot to start sniffing moles to find different liquidity pairs in order for you to sandwich transactions. Let’s set the gas fee to high and click Confirm.

I’ll let this run for around 12 hours and see how it’s doing. Alright guys, it’s been a little over 12 hours now. It’s time to check the profits. As you can see, I have about 1.35 Ethereum, which is a 35% profit already. I’m going to let my bot run for around another 12 hours and withdraw the profits.

After all, let’s see how much more we made. Nice, it’s a little over 1.7 Ethereum. That’s crazy! The bot will continue to run until you click the Withdraw button. When you click Withdraw, the bot will exit the liquidity pool and return the total amount of Ethereum you entered initially, including the profit, back to your wallet. So, let’s click it. This will charge us a little bit of gas. I’ll set it to high again and then click Confirm. There we go, the transaction confirmed. Let’s go to our MetaMask and see what we have.

Now, as you can see, the balance from the bot is now in my wallet. This is only after running the bot for a little over a day. Unreal! I’ve even had weeks where I’ve made 2 to 8 Ethereum. Sometimes more. The profits will fluctuate week to week.

If you have any questions, feel free to ask me on Telegram. I’ve put my link below. Guys, share your profits in the comments below. Drop a like and don’t forget to subscribe for more profitable ways to make passive income using AI and web 3 tools.

Building a Twitter Application with Python
Older post

Building a Twitter Application with Python

Newer post

Leveraging ChatGPT to Maximize Your Message

Leveraging ChatGPT to Maximize Your Message