90% Fill Market Buy Orders

Why Are Market Buy Orders Only Being 90% Filled? 


In some cases DeversiFi executes approximately only 90% of your market buy order. This article will explain why this is the case, and detail two of the potential remedies that the DeversiFi team is exploring.


Background

Traders on self-custodial Ethereum exchanges (including DeversiFi) sign each order that they place with their Ethereum key (on DeversiFi this links to the trader’s unique DeversiFi trading key). Each message contains a price, quantity and signature for the order the trader would like to submit to the exchange.

In this article, we refer to the numerator in a currency pair as the ‘base’ currency and the denominator as the ‘quote currency’ For example, in an ETH/USD(t) order, ETH is the base currency and USD(t) is the quote currency.


Market Sell Orders

In the case of a market sell order on DeversiFi the trader simply signs a message specifying they would like to sell X quantity of token at up to a 10% worse price than the best bid. This is easy for the exchange to process as provided that each subsequent partial taker fill is within the specified price parameters of the original message, the order will continue to be processed until the full quantity of the order is filled. There is no danger of the order being overfilled as the max quantity is specified in the original message and the trader can only sell the maximum quantity of the token that they hold in their exchange account.


Market Buy Orders

In the case of a market buy order on DeversiFi or another self-custodial exchange, specifying a quantity, as well as a price in the signed order message makes handling a true market buy order more challenging.

On a centralised exchange, instead of specifying the quantity of token that a trader would like to buy, the trader instead specifies the quantity in terms of the quote currency (eg 100 USDT worth of ETH/USDT). The centralised exchange matching engine then just keeps filling the order until the quantity (in terms of the quote currency, eg 100 USDT) has been bought. This loop of increasingly smaller and smaller orders is easy for the centralised exchange to process since it does not require permission from the user.

However, when a trader signs for a market buy order on DeversiFi, they are signing only one message for X quantity worth of token at a price that is 10% worse than the best offer. What this equates to in practice, is that they are signing an order for a 10% lower quantity than they originally intended because DeversiFi takes the specified original quantity and calculates the same equivalent quantity at a 10% worse price. This new quantity is then submitted to the order book and is matched until the new full quantity is reached.

DeversiFi uses the above logic to process market buy orders, as otherwise the trader could end up signing one order for a total order value that is greater than their account balance. For example, signing one order message to buy 100 USDT worth of ETH at a 10% worse price could result in the total value of the signed message being greater than their quote currency account balance - for example if they only had 100 USDT in their account at the time.

Allowing traders to sign for orders that are greater than the total amount of their account balance is not currently possible on DeversiFi as this would be against the trustless concept of the system. 


Potential Resolutions


1) Multiple Signing

A centralised exchange can simply keep submitting orders in line with the trader’s original request until the full quantity of token (in terms of the quote currency) is bought. However, on DeversiFi, the trader would have to keep submitting smaller and smaller separate order messages until close to the full total quantity (in terms of quote currency) was filled. This is not something that is practical at speed using private wallets where each order needs to be manually and individually confirmed.


2) Market Order ‘Plus’

A more viable alternative would be to ask the trader to sign for an amount of token X that is worth 10% more than the equivalent worth of the denominator.For example, if the trader would like to buy 100 USDT worth of ETH then DeversiFi asks them to sign for 110USDT worth of ETH

This is a relatively easy feature to implement, but would only rely on the trader having 10% more balance of the base pair currency. For example, if the trader wished to buy 100 USDT of ETH, they would need to have 110 USDT in their DeversiFi exchange wallet.


Did this solve your problem?