econia-labs / econia

Hyper-parallelized on-chain order book for the Aptos blockchain

Home Page:https://econia.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Remove place market order entry function

bogberry opened this issue · comments

Description

The current implementation of the entry functions used for placing market orders include arguments such as:

  • limit_price
  • min_base
  • max_base
  • min_quote
  • max_quote

which do not conform to industry standards and a commonly accepted definition of a market order. Typically, only a size will be specified for a market order, and there should be no guarantees on what price it fills at or what amount of coins will be available after it has been filled.

For example, the definition given on the introductory article on investor.gov states

A market order is an order to buy or sell a security immediately. This type of order guarantees that the order will be executed, but does not guarantee the execution price.

By definition, any order which has a limit price above or below it will not execute is a limit order, not a market order. It does not make sense to provide this sort of granularity in a market order, since this is not the purpose a market order is intended to serve.

Possible solutions

To avoid confusion, we should either

  • remove the market order functions entirely, or
  • replace them with function that does not take in the above arguments.

If we remove the market order functions entirely, users would submit immediate-or-cancel limit orders with either a size of 0 or a size of U64_MAX, depending on whether it is a bid or an ask. This would allow us to make this fix purely by removing code, not adding anything, and it may allow us to make this change without any additional audits.

Alternatively, we could replace these functions with updated versions that do not take in these arguments. This is fairly simple to implement, and if we are going to audit the diff between the audited version and a fix for #143 anyways, we might as well for convenience's sake.

commented

If we remove the market order functions entirely, users would submit immediate-or-cancel limit orders with either a size of 0 or a size of U64_MAX, depending on whether it is a bid or an ask. This would allow us to make this fix purely by removing code, not adding anything, and it may allow us to make this change without any additional audits.

Agreed that this is the simplest solution, and as @qdrs has indicated the core functionality necessary for trading purposes may be supported by the limit order functions alone. We will just want to assure that no existing integrators are using the place_market_order Move APIs.

Alternatively, we could replace these functions with updated versions that do not take in these arguments. This is fairly simple to implement, and if we are going to audit the diff between the audited version and a fix for #143 anyways, we might as well for convenience's sake.

Can you elaborate on proposed modifications per this approach? E.g. would place_market_order functions in this schema just act as a wrapper around IMMEDIATE_OR_CANCEL limit orders?

Can you elaborate on proposed modifications per this approach? E.g. would place_market_order functions in this schema just act as a wrapper around IMMEDIATE_OR_CANCEL limit orders?

Yes, with this approach the place_market_order functions would be calling their corresponding place_limit_order functions either with a price of U64_MAX (bids), or a price of 0 (asks), so it will be trivial to implement.

commented

@bogberry @qdrs #151 Refactors place_market_order functions to accept a size argument only (instead of min/max base/quote + limit price) with minimal source code modifications.

commented

Note that the new market order APIs ensure consistency with traditional standards (size/direction only), even though they eliminate slippage control.

When people place market orders on a CEX they accept slippage risk too, otherwise they'd just place a limit order.

If people want slippage control in Econia they always have the swap APIs.