The exchange component is similar to that of top centralized exchanges. This design enables IDEX to match centralized exchanges in latency and throughput-- performance that is unavailable from other DEXs.
IDEX utilizes an off-chain trading engine for trade execution bringing:
Extreme performance, processing tens-of-thousands of orders per second with millisecond latency.
Guaranteed sequencing, executing orders in the precise order that they are received by the server
This is in contrast to the majority of DEXs which execute trades on-chain, leading to:
Low throughput and high latency associated with blockchain transactions
Non-deterministic ordering with miners deciding which transactions are included and in what order
The IDEX trading engine leads to a responsive user experience and insulates users from the failed trades, front-running, and sandwich attacks which plague on-chain DEXs.
Paired with the trading engine is an off-chain order book. This combination both minimizes gas costs and maximizes the benefits of the trading engine.
Orders on IDEX are represented by signed transactions that include the price and amount (among other parameters. See orders). These orders are passed through the trading engine where they are processed; orders are matched and executed as a trade when overlapping with existing liquidity, placed on the order book as a new limit order when not, etc.
When orders match a trade is executed. Both traders' balances update in real time, and they can continue trading immediately using the new balances. Simultaneously the completed trade is sent to the network for settlement.
On-chain transactions only occur during settlement of a matched trade. Users are free to place and cancel orders as frequently as they like, without incurring additional network costs. Order placements/cancelations are processed in real time, enabling more advanced market making and trading strategies.
The use of a high-performance trading engine enables advanced order types typically only found on centralized exchanges. These include stop-loss, post-only, and fill-or-kill. Introducing these order types allows for more sophisticated strategies typically not possible on DEXs. A more comprehensive list of order types is found in the exchange smart contract guide, while the detailed explanations are available in the IDEX API documentation.
IDEX supports trading via a simple swap interface. The swap option can be used regardless of whether funds are already deposited into the platform (see smart contracts overview). If funds are already deposited, the swap will execute instantly. When swapping directly from a wallet, three steps (deposit, trade, and withdrawal) are executed sequentially.