Coinbase Exchange operates a continuous first-come, first-serve order book. Orders are executed in price-time priority as received by the matching engine.
When a market order using decrement and cancel (dc ) self-trade prevention encounters an open limit order, the behavior depends on which fields were specified for the market order.
If funds and size are specified:
For a market buy order, size is decremented internally within the matching engine and funds remain unchanged. The intent is to offset your target size without limiting your buying power.
If funds is specified (and not size):
For a market buy order, funds are decremented.
For a market sell order, size is decremented when encountering existing limit orders.
Orders are matched against existing order book orders at the price of the order on the book, not at the price of the taker order.ExampleUser A places a buy order for 1 BTC at 100 USD. Then User B places a sell order for 1 BTC at 80 USD. The result is that the trade occurs at 100 USD because User A’s order was first to the trading engine and User A has price priority.