0x Decentralized exchange protocol

0x is a permissionless protocol to facilitate trading of Ethereum based tokens including ERC-20, ERC-721, and other Ethereum standards. 0x is not itself a decentralized exchange, but instead a system of smart contracts that connects liquidity providers and market makers in order to provide exchange functionality in a range of applications.

Background

0x is building a protocol to enable the creation of decentralized exchanges for the Ethereum blockchain in order to facilitate permissionless transfers of values. Decentralized exchanges have the potential to offer advantages over centralized systems such as real-time settlement, reduced counterparty risk, censorship-resistant transactions, and transparent technology. Initially, the project will focus on the exchange of ERC20 with plans to build capabilities to allow for the exchange of any Ethereum based asset.

0x is not managing a decentralized exchange itself but is instead building the infrastructure to enable the creation of these platforms. Rather than using on-chain order books, 0x relies on “relayers” to manage order books through off-chain messaging, while transactions are settled on the blockchain based on quotes from the off-chain messaging service. Comparatively, this reduces costs related to updating orders and offers a faster exchange process.

The team has also created a variety of products using 0x. Asset Swapper enables other decentralized finance projects to automatically find liquidity, pass it onto their smart contracts and fill orders at the best prices. 0x Instant offers a simple crypto purchasing experience for any application or website. 0x Launch kit provides tools to launch an exchange or marketplace.

Technology

0x is both a messaging standard and a suite of smart contracts. Market makers can send messages off-chain that include the details around their order such as what tokens are being traded, the price, and expiration date of the order. The proper format for messages is maintained in a token registry, which is a smart contract storing the list of ERC20 tokens available for exchange. The registry serves as the official on-chain reference for settlement of transactions used by market participants to confirm the token addresses and exchange rates trades will settle at once executed. The suite of smart contracts accepts signed messages from takers and executes the trade on-chain. The smart contracts also provide the logic to upgrade the protocol over time.

Third-party relayers build the actual exchange on top of 0x and are responsible for maintaining the order-books that host the signed messages. For providing this service, relayers set a fee-schedule similar to a centralized exchange. The main difference is relayers do not take custody of the user’s assets since trades occur on-chain.

Because the relayer system resides outside of Ethereum’s main chain one of the primary concerns the team is looking to proactively address is the potential for front-running. When transactions are delivered to the Ethereum main chain an order could be observed on-chain and then front-run by adding extra gas to a transaction that could allow a user to have their transaction filled first.