XEMM HIP: Triangular arbitrage

Author: Jelle {Cryptobot} 0xe8f

Original Post Date: 4 Jul 2022

General Description:

This is part of a 4 part HIP consisting of:

  • XEMM triangular arbitrage
  • XEMM automatic rebalancer
  • XEMM Minor Improvements
  • XEMM latency optimization

In the past two months, I have significantly improved the XEMM strategy, which allows me to better manage slippage, run XEMM with triangular arbitrage, significantly scale up campaign exposure, and spend 60% less time on managing my XEMM strategies.

Unfortunately, as I am not a developer, my code is written unprofessionally and is for personal use only. However, as I think all users will benefit from these improvements, I think these ideas should be further developed by a professional programmer. My code can be used as a guide, and I will further assist (if needed) any developer who wants to further develop these ideas.

I have given a brief explanation of the core ideas of these improvements at the end of my AMA: Cross Exchange Market Making with Jelle - YouTube

This proposal will first be published on the commonwealth forum so users can add comments, give their opinions and share ideas. Later, the proposals will be put up for a vote as a HIP.

XEMM Triangular arbitrage:

Hummingbot added the rate oracle feature to XEMM, but currently, this is not working properly as the ‘quote_rate’ is not properly integrated into every function/method. Therefore, running XEMM strategies on pairs with two different quote pairs (e.g. Maker: SHR-BTC, Taker: SHR-USDT) is impossible. A simple solution would be, adding the correct base rates and ‘quote rates’ (from the rate oracle conversion) to the specific functions/methods.

In addition, I have added a function that completes the triangular arbitrage trade by hedging the increased or decreased exposure to the (non USD) quote asset (e.g. BTC/ETH). This idea is explained in my video and in the example below.

Video link: Cross Exchange Market Making with Jelle - YouTube

Based on my experience, I am doubtful whether the rate oracle conversion is accurate enough, but this has not been assessed thoroughly. However, if triangular arbitrage would be added to the strategy, the effective hedging price calculations should be changed, as you also need to take into account the slippage and spread on the BTC/ETH market and the rate oracle would become redundant.

Why adding triangular arbitrage to XEMM:

First, it allows users to make markets on ETH/BTC denominated pairs in a delta-neutral way by hedging on a USD/USDT/USDC etc. denominated pair and subsequently hedging their increased or decreased exposure to ETH/BTC. This is especially great because ETH/BTC-denominated pairs generally have a wider spread than USD-denominated pairs and are therefore excellent markets for the XEMM strategy. I have also observed that the miner campaigns that are denominated in BTC/ETH generally have a higher yield which could boost traders’ profits.

Second, users will have more taker market options as a user can make a market on a USD/USDT/USC etc., denominated pair, and hedge on an ETH/BTC denominated pair. This is great for liquidity mining purposes as the main limitation for XEMM is scalability as you are dependent on the liquidity of the taker exchange.

Third, I think this is not only in the interest of individual market makers but also for professional token issuers that provide liquidity for their own tokens and have, next to a USD market also an ETH or BTC market. It provides them with another tool to keep their markets efficient.

An example of a XEMM triangular arbitrage strategy:

Maker market: BINANCE: AVAX-BTC

Taker market: BINANCE: AVAX-USDT

As your maker and taker exchange have two different quote assets, there is a conversion taking place to convert the AVAX/USDT price to an AVAX/BTC price. This is done by the oracle rate conversion, or in the case of triangular arbitrage, by the effective heding price of a buy/sell order on the BTC market.

If your maker sell order (AVAX-BTC) is filled, you buy AVAX for USDT in the taker market. By doing this, you have just increased your BTC exposure as you sold your AVAX for BTC on the maker market. In theory, you have not increased or decreased your AVAX exposure as you bought AVAX for USDT on the taker market.

In a triangular arbitrage situation, you would also sell the increased BTC amount so you trade completely delta-neutral. In other words, you have not (significantly) increased or decreased your exposure, but you profited from the price difference between pairs.

This feature could also work for AVAX-USDT as the maker market and AVAX-BTC as the taker market. In that case, if a maker sell order is filled, a taker buy order is executed. Which would lead to a decrease in BTC exposure as you buy the AVAX on the taker exchange which is paid with BTC. The third leg of the triangular arbitrage would buy back the BTC to trade delta neutral.

By using this XEMM triangular arbitrage strategy, I have been able to significantly scale up my exposure to some campaigns as you are now able to use BTC or ETH denominated taker markets. This also allows me to market make on many of the ETH or BTC denominated pairs, which generally have a high yield.

I would like to get your opinion on this idea before submitting this as a HIP.

Feel free to DM me on discord: @Jelle {Cryptobot}

Github link: GitHub - jellebuth/Jelle-V2.2