Bots in DeFi: every cryptocurrency’s nemesis
They caused the downfall of many investors, wreaked havoc in blockchains, and made some users rich. They operate in darkness, around the clock. Who are “they”? As you may have guessed, they are DeFi robots.
Decentralized Finance (DeFi) ecosystems operate on blockchains that allow for the use of smart contracts. Therefore, any action can be automated on these highly programmable blockchains.
Most of these blockchains are “EVM compatible”. This means that they operate with the Ethereum Virtual Machine, which is the same environment used by Ethereum (ETH).
It is common knowledge that developers tend to automate as many actions as possible using code. As a consequence, DeFi ecosystems quickly became a lucrative playground where developers strive to optimize their robots or “bots”.
The diversity of services offered by DeFi platforms caused the creation of a wide variety of DeFi bots.
The first kind of bots we’ll talk about is probably the oldest of them all: trading bots. In practice, these bots mainly interact with decentralized exchange platforms (DEX).
Developers create these bots with a built-in trading strategy. Once deployed, the software will follow this strategy and trade certain cryptocurrencies according to predefined parameters and on-chain data.
These bots are probably the riskiest ones to operate. They are highly subjected to the volatility of a market and can get trapped by fluctuations if they become too important.
These bots also operate outside of DeFi ecosystems, on more traditional exchange platforms like Binance, FTX, or Kraken. Numerous investment companies also use bots of this kind.
DeFi liquidation bots
Contrary to trading bots, liquidation bots are considered to be the safest to operate.
These bots operate in lending platforms and monetary markets. To keep things simple, these platforms allow their users to apply for loans in cryptocurrencies by blocking a collateral as a caution for the loan.
However, if the value of the collateral in question were to go lower than the value of the loan, the protocol would result in a deficit.
In order to avoid this, the protocols implement liquidation mechanisms. This is where liquidation bots come into play: they can liquidate a loan if it comes too close to the deficit value.
In practice, the bot will pay off the loan and buy the collateral back with a discount of approximately 5%. Therefore, the loan can be paid off using the sale of the collateral, and the 5% difference serves as a reward for the task accomplished.
Frontrunning bots are without a doubt the ones that caused the most distress on the market. They are significantly less ethical than the bots we presented earlier. In spite of this, they are very prevalent in the Ethereum ecosystem and should be mentioned for this reason.
For starters, frontrunning refers to a practice that consists in publishing a transaction with gigantic fees, with the goal of having it made before another transaction that has lower fees.
In actuality, these bots scan the blockchain for transactions to frontrun. Let us take the example of a big swap on Uniswap.
The bot will place an important buying transaction before the one it has identified. This will cause the price to be inflated artificially. As a consequence, the targeted transaction, which is made later than the one made by the bot, is forced to buy the asset at a much higher price than the one announced on the platform.
This new purchase will once again cause the price of the asset to go up. The bot will then place a second transaction to sell the cryptocurrency it just bought, and make a profit from the price that went up twice in a row.
While the profit is real, it is made at the expense of other users who fall victims to these operations.
If you have development skills, creating a small DeFi bot can be an excellent way to dive into the technical aspect of an ecosystem. However, you should remain reasonable when it comes to the amounts involved and be careful with the safety of the development.