Market maker + order book


This should be the start of a discussion on how to combine market makers with an order book. The most simple solution would be to just have them completely separated.

On chain market maker calculations that includes an order book are most likely infeasible. However - maybe a "valid state" can be defined and checked easily.
(something like: the no current market maker price is allowed to be higher than the highes matching open order) It than would be necessary for the user to full fill an order AND trade with the market maker to result in a valid state (can be done atomic with a transactions that full fills a list of trades). The calculations required can be done off chain.

However - for this validity check a sorted list of the orderbook would be necessary. Even this would stop trades having a fixed gas prices. So very busy markets would become more expensive and could even run out of the block gas limit and therefore create a dead lock.


One workaround I've heard for this sort of problem is to offer bounties for presenting the invalid state. Maintaining a sorted orderbook is hard, but checking a given order against the market maker's price is easy, so if anyone submits an invalid pair to the contract, it can take the appropriate action.


right - the downside of it is that you would have to leave a security deposit with your trade. However - still definitely a solution worth thinking about.

Maybe the trade can be done by a third party that would provide the deposit.