Introduction to 0x
This documentation describes the public infrastructure we are building - 0x Protocol, API, DAO - to make assets more accessible and liquid and empower teams around the world to build a new financial system. Learn more about our mission and values.
0x is an open-source, decentralized exchange infrastructure that enables the exchange of tokenized assets on multiple blockchains. The 0x protocol is, at its core, a set of secure smart contracts that facilitate the peer-to-peer exchange of Ethereum-based assets. The protocol serves as an open standard and common building block for any developer needing exchange functionality. In addition to the externally-audited smart contracts, 0x also offers developer tools tailored to the ecosystem and open-access to a pool of shared liquidity.
Developers can integrate with 0x at the smart contract or application layer. The diagram below shows an overview of the 0x ecosystem, which includes applications who provide liquidity (supply), applications who consume liquidity (demand), and the multiple supported blockchains.
0x is an open-source, decentralized exchange infrastructure that enables the exchange of tokenized assets on multiple blockchains.
Within the 0x ecosystem, there are two sides - Makers and Takers:
This is the entity who creates 0x orders and provides liquidity into the system for the Demand side (Takers) to consume. 0x aggregates liquidity from multiple sources including:
- On-chain liquidity - DEXs, AMMs (e.g. Uniswap, Curve, Bancor)
- Off-chain liquidity - Professional Market Makers, 0x's Open Orderbook network
This is the entity who wants the Maker's asset. The Takers agree to trade their asset for the Maker's asset; in other words, they consume the 0x liquidity. Examples include projects such as MetaMask, Coinbase, and dydx.
In addition to Makers and Takers is the 0x Community DAO, which is the collective governing voice of the 0x protocol and the ZRX token.
The 0x API allows applications to tap into the 0x protocol for ERC20<>ERC20 swaps. The NFT Swap SDK is a developer tool that enables ERC20<>ERC721 and ERC20<>ERC1155 swaps in just a few lines of code.
The 0x API is the interface that allows DeFi developers to tap into the 0x Protocol and trade ERC20 assets. It has 2 major endpoints - /swap and /orderbook. The /swap endpoint allows users to fetch available quotes across the liquidity supply. The API aggregates liquidity from on-chain and off-chain networks and uses smart order routing to split up a transaction across decentralized exchange networks to be filled with the lowest slippage possible while minimizing transaction costs. The /orderbook endpoint lets applications and users access 0x's open orderbook liquidity, and post limit orders making them publicly available immediately. Orderbook API replaces the 'SRA' API, without introducing breaking changes as all endpoints are backward compatible. NFT Swap SDK
Applications, which includes both Makers and Takers, integrate with the 0x API or NFT Swap SDK or directly access the protocol’s smart contracts to take action on the best prices.
Let’s look into how a 0x order is executed.
- 1.A Maker creates a 0x order which is a json object that adheres to a standard order message format (see list of all 0x order types here). It indicates what kind of asset the Maker is committed to trade. Assets could include fungible tokens (ERC20), non-fungible tokens (ERC721), or bundles of assets (ERC1155).
- 2.The order is hashed, and the Maker signs the order to cryptographically commit to the order they authored.
- 3.The order is shared with counter-parties.
- If the Maker of the 0x order already knows their desired counter-party, they can send the order directly (via email, chat, or over-the-counter platform)
- If the Maker doesn’t know a counter-party willing to take the trade, they can submit the order to orderbook.
- 4.0x API aggregates liquidity across all the sources to surface the best price for the order to the Taker. 0x helps traders create, find, and fill the 0x orders through the paradigm of off-chain relay and on-chain settlement. This means that 0x does not store orders on the blockchain; instead, orders are stored off-chain, and trade settlement only occurs on-chain. This unique feature makes 0x a flexible and gas-efficient DEX protocol for developers to build on.
- 5.The Taker fills the 0x order by submitting the order and the amount they will fill it for to the blockchain.
- 6.The 0x protocol’s settlement logic verifies the Maker’s digital signature and that all the conditions of the trade are satisfied. If so, the assets involved are atomically swapped between Maker and Taker. If not, the trade is reverted.
0x is an open-source project, which opens it up for anyone to freely use it as a liquidity lego in their product.
Projects can be built on 0x. In addition, 0x can also be integrated into any existing application where exchange is not the core purpose of the application. Below are some project ideas. For more examples, see The "comprehensive" list of projects section in this article.
- A decentralized exchange for X asset on Y market
- An Ebay-style marketplace for digital goods
- An over-the-counter (OTC) trading desk
- Digital wallets whose users want to exchange tokens
- Options and derivatives
- A DeFi protocol that needs liquidity and exchange to function (e.g. a derivatives, lending, or options protocol)
- Portfolio managers
- Prediction markets
- Non-fungible tokens (NFT)
- NFT marketplace
- Games with in-game currencies or items
- Investment strategies (e.g. DeFi index funds, DCA apps)
- 0x multi-chain analytics portal
- Real-time trades panel w/ GraphQL wrappers
- Counter/twitter bot of positive slippage returned to users
- Orderbook models
- Automatic Market Makers (AMM) models
- Market Makers
- A market making or arbitrage trading bot