How Arbitrage Is Done On DeFiChain DEXThe following article does not really fit into this ANN thread, yet I would like to place the educational intention over coherence and do hope that it may help some of you in exploiting arbitrage opportunities on the DeFiChain DEX.
Before we jump into this hot topic, we have to make sure that the basic principles of a DEX are understood. Most importantly, we have to get familiar with the price finding/setting mechanism of a centralized (CEX) vs. a decentraliced exchange (DEX).
A CEX uses a so-called market maker and an order book, in which supply and demand gets matched. The market maker ensures the required liquidity through automated trading; the trading fees are then handed over to the CEX. On the other hand, a DEX does not use an order book; the price is set by so-called liquidity pools (LPs) – no oracles are used. Each user can be a market maker by simply providing liquidity to the pool and ultimately getting rewarded by receiving a percentage amount of the total fees collected by the LP. The price setting between two trading pairs is done by a so-called automated market maker (AMM), a deterministic price setting algorithm also known as product market maker algorithm. Mathematically speaking, it looks like this: x * y = k, wherein x and y represent the number of tokens of the two trading pairs and k is a constant. Most LPs use a constant product market maker algorithm, which always keeps a balance between the two trading pairs. No matter how big the desired trade is, the LP can execute it by using the underlaying asymptotically rising curve, which increases the price when demand for the token increases.
The size of the arbitrage opportunity ultimately depends on the imbalance of the amount of tokens in the LP. Referring to the AMM, if a lot of BTC, for instance, gets removed from the BTC-DFI LP, then „a lot more“ DFI tokens have to be transferred in. Since a DEX does not receive any external data feeds via oracles, the two trading pairs cannot rebalance themselves without new outside liquidity. Hence a LP sets the price of a trading pair by simply comparing the amount of tokens. In an isolated world, these LPs can, in the worst case, tip to one side and form advantageous or disadvantageous trading pair ratios for different trader types. To prevent this, the imbalance either has to be manually rebalanced or by using a bot.
And that’s exactly what we are going to do now; we will manually balance out the LPs of the DeFiChain DEX and on top of it make some money.
Do note, it is currently only possible to transfer USDT, ETH and BTC from or via Cake Defi into the DefiChain DEX. Hence you have to make sure, that you have an account with them in the first place.
To be able to take advantage of arbitrage, we have to first find price discrepancies of respective trading pairs on the CEX (I am using Bittrex here) compared to the DeFiChain DEX. The following chart shows some of the trial and error approaches I have conducted.
As you can see in the table above, I was able to make 600 DFI, or roughly 230 USD, by executing the following strategy: I first exchanged 2500 DFI on Bittrex for 940 USDT. These 940 USDT I then sent over to Cake Defi (3 USD fee); from there I transferred it further into the DeFiChain DEX (1 USD fee). At the last step, I exchanged those 940 USD for a total of 2899 DFI – a net profit of 399 DFI tokens before fees.
Simultaneously, I did the same with the DFI/BTC trading pair. I sold 2000 DFI for 0.040083 BTC on Bittrex and transferred those BTC via Cake Defi into the DeFiChain DEX. There, I then exchanged them for 2301 DFI token – a net profit of 301 DFI tokens before fees.
This (rather huge) arbitrage opportunity is gone, yet it can change within seconds and even bigger ones can appear.
Generally speaking, it seems like the best approach in finding arbitrage opportunities is by focusing on the USDT to DFI and BTC to DFI trading pairs on the DeFiChain DEX. Also do note, since we are trading on the asymptotically rising curve of the product market maker algorithm, it could be profitable taking advantage of arbitrage for smaller amounts, but not for bigger amounts. In the chart above, you can see, that it is not profitable to exchange 2500 DFI on Bittrex into USDT and then exchange it back on DeFi DEX, yet on the other hand, though, 250 DFI exchanged into USDT on Bittrex and exchanged back on DeFiChain DEX is indeed profitable.
Hence my recommendation, to always check for smaller arbitrage opportunities first, especially when the LPs are still not well funded. Over time, this may change and bigger arbitrage opportunities may appear.
A side node to Cake DeFi:Before you now jump onto this bandwagon, you should first get familiar with Cake Defi. Sending USDT and any other alt coin into Cake Defi is totally easy and fast; just make sure to use the Ethereum network to send in your coins. If you then for instance would like to send USDT to the DeFiChain DEX, you have to send those as so called wrapped USDT by using the DeFiChain blockchain network (see picture below). Simply copy the wallet address of your DeFiChain wallet, choose the DeFiChain network and send your USDT to the DeFiChain DEX. The wrapped USDT are basicially nothing else than what any ERC20 token is to Ethereum.