Comment on page
The IDEX smart contracts bring programatic guarantees to the platform.
Historically, high performance exchanges require users to custody funds with the exchange. IDEX utilizes a series of smart contracts to decentralize fund custody and trade settlement as well as introduce novel DeFi mechanisms.
The off-chain trading engine executes trades in real time before dispatching transactions to the network for settlement. This process creates a delay between when the user signs the order and final settlement. It’s critical that the funds for both the maker and taker do not move on-chain in the time between execution and settlement or else the settlement transaction will fail.
The smart contract solves this by acting as a form of escrow, restricting the movement of funds until all settlements have finished. All trades and withdrawals are sequenced to ensure that on-chain balances are updated in the correct order. Note: a special smart contract function, wallet exit, ensures that funds cannot be restricted indefinitely (see smart contract code).
In centralized order book exchanges, users must trust that the exchange to properly match and settle trades. Even more critically, users trust the exchange to maintain custody and process valid withdrawals.
The IDEX smart contracts cryptographically enforce ownership and authorization. This ensures that all trades are authorized by owner and that withdrawals are legitimate and only sent to the account owner.
The smart contracts are also responsible for enforcing the rules of the AMM liquidity pools, allowing users to market make without a third party or any additional infrastructure.