Matching Engine and Orderbook
Last updated
Last updated
When you place an order on the front end it is immediately pushed through to our Matching Engine. The Matching Engine is responsible for matching trades that come in, checking appropriate balances and trade parameters, and placing orders into the order book if there are no trades that match.
The matching engine is also responsible for additional security checks and procedures.
When an order comes into the matching engine the order parameters will tell the matching engine what side of the book the trade is in (Buy or Sell), what type of trade it is (Market, Limit, or Stop), if the trade is a regular spot trade, if its a short or on margin, the size of the trade and the price of the trade.
Depending on all of the parameters the trade will go through a variety of different checks, balances, and procedures.
On every order, the Matching Engine will check each user's asset balance in the smart contract to ensure that they have the available balance to complete that trade. In the case of , the matching engine will instead check the "Total Portfolio Balance", "Initial Margin Requirement", and "Aggregate Maintenance Margin Requirement" parameters.
Only after all of these parameters pass will a trade be matched. All matched orders will be batched together and subsequently passed to the to execute in one trade.