Whitepaper In Four Minutes - 0x

Whitepaper In Four Minutes - 0x




Introduction:

The blockchain has made it possible to own or exchange digital assets in an open financial network without needing to trust third-party services. With the rise of digital tokens, there was an increasing need to exchange them.

The conventional method to trade assets has been through a central exchange, a trusted third party. These exchanges make it easier for users to trade their tokens, but they risk being a single point of attack for hackers or government regulators. Hackers have made headlines by stealing user data and funds from these centralized exchanges.

A decentralized exchange eliminates that risk by making it possible to exchange blockchain assets directly between users. 0x is an open, permissionless protocol for decentralized exchange on the Ethereum blockchain.

The 0x protocol provides the basic building blocks for exchanging assets with the help of smart contracts. The smart contracts are open and shared infrastructures which can be used by any dApps. It combined with other protocols can be used to create sophisticated dApps.

Limitation of other decentralized exchanges:

Other decentralized exchanges have failed mostly because of their inefficient architecture and high friction costs on market makers. The exchanges put the order book directly on the blockchain (also called on-chain) and impose a gas cost to market makers to post, modify or cancel orders. More importantly, this also results in consuming the network bandwidth without necessarily exchanging value.

AMM (Automated market maker) smart contracts are alternatives to on-chain order book. They replace the order book with a price-adjustment model in which assets spot price deterministically responds to market forces and market participants on either side of the market trade with the AMM rather than with each other. The deterministic nature of price-adjustment models makes them insensitive to market liquidity and easy to integrate with other smart contracts.

State channels are a method to scale the Ethereum blockchain and reducing the cost for dAaps. It can be thought of as a "bar tab", where numerous intermediary state changes are accumulated off-chain before settling the outcome to the main Ethereum blockchain (on-chain).

How 0x works under the hood:

A hybrid implementation, "off-chain order relay with on-chain settlement" combines the best of both worlds. In this method, a user broadcasts a cryptographically signed order off the blockchain. Interested parties can then take the order and directly execute the trade on the blockchain. The intent is captured off-chain, and the value is transferred on-chain.

The flow:

0x-maker-taker-flow
off-chain order relay with on-chain settlement diagram

Order:

Each order has order parameters and an associated signature. The parameters are hashed via the Keccak SHA3 function. The order creator signs the order hash with their private key to produce an ECDSA signature.

Point-to-point order:

Point-to-point allows two parties to directly exchange tokens by using any communication medium to relay the message. The medium can be either through text, email or any other service. Only the taker can fill the order, making it useless for other users.

point-to-point-order
Point-to-point order message

Broadcast order:

An exchange aggregates orders from buyers and sellers in an order book. The broadcast orders allow anyone to act as an exchange to maintain an order book. The exchange is called a Relayer.

broadcast-order
broadcast order message

The Relayer:

The task of a relayer is to facilitate the signaling between market participants by hosting and propagating an order book, which consists of a generic order message. The relayer doesn’t and cannot execute a trade. It is the responsibility of the Taker to execute the trade independently and to make the entire process trustless.

What the relayer can and cannot do:

A conventional exchange service uses a matching service to fill market orders. The participating users generally trust the exchange to provide the best value at the time. This is not true for 0x protocol as the Taker has the ultimate power to execute the trade.

The relayers have control over which orders get posted in the order book. The fees in the order parameter is given to the relayer for propagating the orders. The maker needs to satisfy the fees set by the relayer for them to show in the order book. The fees are reduced only when the order is filled.

relayer-flow
Relayer flow

More about orders:

A Taker can also partially fill an order. Multiple partial fills can be executed in a single order as long as the sum of the partial fills does not exceed the total value of the order.

The Maker specifies the expiration time when creating an order. The expiration time cannot change after the order is created and signed. The expiration status doesn’t depend on the time when the taker broadcasts their intention to fill an order, but instead when the function is being executed in the EVM by the miner.

The Maker can cancel unfilled or unexpired orders via the cancel function in the smart contract even though canceling order costs gas.

Protocol token:

0x intends to serve as an open standard for dApps that incorporate exchange functionality. Protocol tokens can align financial incentives and offset costs associated with organizing multiple parties around a single technical standard.

Conclusion:

0x protocol is an open, permissionless protocol that allows digital tokens to be traded on the Ethereum blockchain. The orders are transported off-chain, which makes it cheaper and less bloat to the blockchain. The trades are executed directly on the blockchain. Relayers help to broadcast orders and collect fees. The protocol is application agnostic where anyone can be a relayer.

References:

Read summary of a whitepaper in four minutes. Every week. On Wednesdays.
Sometimes twice a week!