Introducing IDEX

Alex Wearn
IDEX
Published in
8 min readAug 30, 2017

We are excited to announce the alpha launch of the next iteration of IDEX, the most advanced Ethereum smart contract based exchange to date! The alpha is live on the testnet and open to all users.

IDEX provides a trustless, real-time, high-throughput trading experience in conjunction with blockchain based settlement. By centrally managing trade matching and Ethereum transaction dispatch, IDEX enables users to trade continuously without waiting for transactions to mine, fill multiple orders at once, and cancel orders immediately without any gas costs.

IDEX Demo

IDEX consists of a smart contract, a trading engine, and a transaction processing arbiter. The smart contract is responsible for trustlessly storing all assets and executing trade settlement, and all trades must be authorized by the user’s private keys.

However, unlike other decentralized exchanges, the IDEX smart contract is designed such that only the exchange is authorized to submit signed trades to Ethereum. This enables IDEX to control the order in which transactions are processed, separating the act of trading from final settlement. As users trade their exchange balances update in real-time, while simultaneously their private keys are used to authorize the trade in the contract. This authorization prevents users from rescinding any completed trades, and prevents IDEX from initiating any unauthorized trades.

Authorized transactions are passed to the arbiter which manages the queue of pending transactions, dispatching them in sequence to ensure that each trade is mined in the correct order and that the smart contract balances stay in sync with the exchange balances. By controlling the transaction sequence, IDEX provides the speed and user experience of a centralized exchange combined with the security and auditability of a decentralized exchange.

Detailed specs

IDEX Transaction Process
  1. Maker and taker deposit their tokens into the IDEX smart contract.
  2. IDEX database is updated to include the customer addresses and associated token balances.
  3. Maker creates and submits a new order, signing a transaction that includes the trade data and authorizes the smart contract to execute the future trade.
  4. IDEX reviews the order and confirms that the maker account has sufficient funds and that all info in the signed transaction matches what was submitted to IDEX.
  5. If all checks in part 4 pass, the order is added to the orderbook.
  6. Taker sees an order on the order book and submits a trade to fill it, signing a transaction with this same trade data and authorizing the smart contract to execute the trade.
  7. IDEX reviews the order and confirms that the taker account has sufficient funds and that all info in the signed transaction matches what was submitted to IDEX.
  8. If all checks in part seven pass then the trade is marked as matched and the orderbook is updated to indicate a filled order.
  9. The IDEX database is updated to reflect the new balances of both traders after this recent trade. Traders can continue to make new trades based on these updated balances. Simultaneously the market maker’s and taker’s signed orders are added to the queue to be broadcast to the Ethereum network for processing.
  10. After the trade has been reached in the queue, the maker’s transaction is dispatched to the ethereum blockchain.
  11. The maker’s transaction is mined and the order is added to the internal order book in the smart contract.
  12. After the maker’s order has been mined, the taker’s transaction is dispatched to the ethereum blockchain.
  13. The taker’s trade is mined and the balances in the ethereum contract are updated to reflect the trade.

DEX Comparison

The table below highlights the differences between IDEX and other existing Ethereum-based decentralized exchanges.

DEX Comparison

Concept: With the ED/0x approach, the market maker cryptographically signs a message that contains their order parameters. This message with the order details is hosted off-blockchain in a centralized database. The taker uses the signed message to construct the full trade and submit the complete order to Ethereum for mining. The taker pays the associated gas fees, and may also be competing with other takers for the same order to have theirs mined first.

Oasis trading is entirely on-chain. When creating a limit order, makers must also submit this order to Ethereum to be mined. This costs gas to do so and also slows down the process, as their order isn’t available until after a block is mined. Once mined the taker uses the order info and submits a tx to fill the trade. Like the ED approach, takers may be competing against others for the same order where the winner is decided by the miners.

Trustless: On all three exchanges it is not possible for the exchange developers to steal their user’s funds. On EtherDelta and Oasis customers initiate their own withdrawals, while on IDEX withdrawals are submitted via the central server’s transaction arbiter. This is necessary to ensure that customers cannot withdraw until all on-chain transfers have completed. To prevent IDEX from indefinitely blocking user’s access to their funds there is an “escape hatch” in the smart contract that allows customers to interact directly with the contract and withdraw their funds after a certain period of inactivity.

Trade speed: IDEX acts as an arbiter and is the only entity authorized to submit transactions to Ethereum for processing. With new orders the signed transactions are first analyzed to verify the legitimacy of the trade. If the authorization is valid then IDEX is 100% certain that the trade will succeed. This allows IDEX to match trades and update balances off-chain before the transactions have been mined, creating a trading environment with speeds comparable to centralized exchanges. EtherDelta hosts the limit orders off-chain, but each market taker must take the parameters, construct a trade, and submit it to the blockchain. Order processing is limited by the speed in which transactions are mined. Oasis is the slowest of the three, requiring that users wait for both resting limit orders and taker orders to be mined.

Order book update speed: After orders are matched, the IDEX order book updates within seconds. Traders who attempt to fill a matched order before it is removed from the UI will simply place a new limit order. On EtherDelta and Oasis the orderbook is updated only after the blocks are mined, creating a situation where many traders are competing for the same order. One lucky trader will match the order while everyone else wastes gas and is left with a “bad jump destination” error. Unsuccessful traders will not have their order placed as a new limit order and must find a new resting order and try again.

Time to cancel order: On IDEX cancellations are instantaneous and many orders can be cancelled at once. On EtherDelta and Oasis each cancellation requires a mined transaction, limiting users to one cancelled transaction per block. This can lead to situations where market makers are racing to cancel their transaction before another user fills the order, forcing them to pay higher gas fees without the guarantee that they can cancel their order before it is matched.

Automatic trade matching: IDEX is the only exchange that supports automatic trade matching, ensuring that any mispriced “fat finger” orders are matched with the best price resting order. If a user on EtherDelta or Oasis creates a mispriced order it will still be added to the order book.

Fill many orders at once: EtherDelta and Oasis require that the taker submit the order to the smart contract from their own address. To ensure that old transactions cannot be “replayed,” Ethereum is designed to increment a number known as the nonce after every transaction. If a user submits three orders at once with nonce values of 1, 2, and 3, there is a risk that the third order is mined first and the first two orders are invalidated. This effectively limits each address and trader to one transaction per block. On IDEX transactions are submitted by the arbiter using multiple approved addresses, negating the nonce issue and allowing users to fill multiple transactions at once.

Gas cost to place limit orders: Oasis hosts the orderbook on chain which requires that every limit order is mined before it can be matched. This is cost prohibitive and limits the use of trading bots as bots are constantly placing and cancelling orders in response to price changes. Both IDEX and EtherDelta do not require gas to place limit orders.

Gas cost to cancel orders: On EtherDelta and Oasis resting limit orders are publicly available. In order to invalidate existing orders, traders must dispatch a cancel transaction to the blockchain for mining. This prevents a bad actor from harvesting and using old trades at a later date. These cancel transactions cost gas and make the operation of trading bots cost prohibitive. On IDEX only approved addresses can submit transactions, eliminating the need to mine cancels into the blockchain.

Gas amount per trade: Gas fees on IDEX are currently ~4x higher than those of ED. However, this higher price supports the design which ensures no one wastes gas attempting to fill already matched orders. This design also allows for a lower gas price as there is no urgency to claim orders with on chain matching. As EtherDelta and Oasis grow in popularity the user experience will degrade, with more people competing for the same orders. Gas prices are likely to rise and eventually become more inline with or even exceed those on IDEX.

Race conditions: Race conditions occur when many people compete for the same order and miners decide which trade is successful. In an attempt to have their transaction mined before their competitors, users will pay higher gas fees. As EtherDelta and Oasis grow in popularity the race conditions become more problematic, while the IDEX design ensures that users are never competing for the same order.

Scaling: All three exchanges depend on Ethereum to scale, however in the interim IDEX fairs better than EtherDelta and Oasis. Traders on IDEX will only encounter issues when trying to withdraw their funds while the Ethereum network is backlogged with pending transactions. All other trade functions will continue to operate as normal. On EtherDelta and Oasis network, backlogs will make the exchanges unusable as many traders increase gas prices in a race to fill existing orders.

Alpha Testing

IDEX is immediately available on the Ropsten nework for testing. Please click here for more information on how to participate.

The end of Decentralized Capital

We are closing down Decentralized Capital in order to focus 100% on IDEX and our new project, Aurora. More information will be released shortly about the change in service. We will also be sharing information on how those who hold DC Assets can redeem them back into ether or bitcoin.

DVIP memberships are still valid. Holders are eligible for free trades on IDEX until the end of 2019 as well as other benefits on our new product, which will be announced shortly.

Join us on Telegram or follow us on Twitter to stay up to date with Aurora and IDEX development.

-Alex

Thanks to Philip Wearn and Brian Fernalld for their help in writing this post.

--

--