0x exchange : decentralized and efficient exchange platform

in #stateofthedapps2 years ago

There has been a big energy flow in the revolution the blockchain has brought, with the intending purpose of disrupting the financial world as well as other sectors.

This revolution has made it possible for individuals to transfer their assets across an open financial network seamlessly without any need for a third party or some sort.

The smart contract processes even make it more efficient for this exchange to occur and turnover has been increased significantly.

Now over the years, Centralized cryptocurrency exchanges have been the most common means of cryptocurrency exchange, as they are run by single entities who dictate the flow of events and ultimately control the economy.

The big risk with centralized exchanges is their vulnerability to hacking or front-running conducted by the administrator.

There is an important progression from the world of centralized exchanges as there is a decentralized exchange that can effectively cater to the inadequacies.

The decentralized exchanges provide better security and also remove middlemen, thereby creating ease in transactions.

Numerous decentralized applications (dApps) have created Ethereum smart contracts for peer-to-peer exchange, of which Ox is a big part of.

0x is a decentralized blockchain technology that is built on the Ethereum Blockchain that allows the peer-to-peer exchange of assets.

The 0x platform is open, safe and a permissionless protocol allowing for ERC20 tokens to be traded on the Ethereum blockchain

The protocol is so designed that it involves Ethereum smart contacts that allow those around the world to run a decentralized exchange.

0x is designed to be different from both centralized and decentralized exchanges, providing the best possible combination of features.

The vision of the technology is that in the future, you will find thousands of tokens from Ethereum and that 0x can provide an efficient and trustworthy way to exchange them

0x came about in October 2016. Co-founders Will Warren and Amir Bandeali had a vision of a future where all kinds of assets, stocks, currencies, precious metals, could be traded publicly on the blockchain as tokens.

How to get started

Login to https://0x.org/

Click on Get Started

Then launch and register to be able to use the platform

0x differs from other exchanges because of the friendly user interface and reduced transaction fees

Features of 0x Exchange

  • AMM Smart Contracts
  • State channels
  • Hybrid implementation
  • Orders
  • 0x Smart Contract

Automated market marker (AMM)

The Automated market marker (AMM) is the direct alternative to traditional on-chain order book. It comes with a price-adjustment model in which an asset’s price adjusts in relation to market forces and market participants on either side of the market trade. AMM acts as a counterparty even though the spot price might be different from the traditional exchange.

The deterministic nature of price-adjustment models make them insensitive to market liquidity, meaning that trades cause prices to move the same amount in both thick and thin markets Whitepaper

It imposes self-inflicted restraints on supply to make sure that assets remain insensitive to market liquidity.

State Channels

State Channels characteristically are lines of communication, often two-way communication between participants that enables them to interact normally on the blockchain and even off the blockchain.

This downplays the role of third-parties by eliminating the validation of transactions by them. Participants in a state channel pass cryptographically signed messages back and forth, accumulating intermediate state changes without publishing them to the canonical chain until the channel is closed.

  • Requirements to do an off-chain state channel?

  • A segment of the blockchain state is locked via multi-signature or some sort of smart contract, which is agreed upon by a set of participants.

  • The participants interact with each other by signing transactions with each other without submitting anything to the miners.

  • The entire transaction set is then added to the blockchain.

Hybrid implementation

This basically refers to some “off-chain order relay with the on-chain settlement,” as it brings together the direct efficiency of state channels with the near-instant settlement of on-chain order books. Signed orders can easily be broadcasted off the blockchain and any interested individual can infuse them into the smart contract for trustless trades.

  • Architecture of the 0x Protocol

  • The Maker firstly approves the DEX smart contract.

  • Maker creates an order to exchange token A for token B specifying the desired exchange rate, expiration time and signs off with their private key.

  • Maker broadcasts the order.

  • Taker intercepts the order and decides to go for it.

  • Taker submits the Makers order to the DEX which proceeds to verify the signature.

  • The transfer between the Maker and Taker takes place at the specified exchange rate.


There are two types of orders in 0x:

  • Point-to-point.

  • Broadcast.

  • Point-to-point Orders

Point-to-point Orders allows two parties to directly exchange tokens while utilizing any communication route they deem fit. The order is made of packets of data containing a few hundred bytes of hex. The order is specific and can only be filled by the specified Taker address

  • Broadcast Orders

These are broadcast orders and is the most popular form of exchange orders. If the exchange would work, then a public order where buyers and sellers can post their orders should exist.

Relayers are the players in this platform. Relayers merely facilitate signaling between market participants by hosting and propagating an order book that consists of generic messages.

Relayers do not execute trades on behalf of market participants as this would require market participants to trust the Relayer.

The message format of broadcast orders has 2 major changes as compared to simple point-to-point messages.

  • There is no specification for taker address, this means that anyone who intercepts the order can fill it in
  • Broadcast orders include feeA (maker fees), feeB (taker fees), and fee recipient (relayer address) parameters.

The 0x Smart Contract

This is implemented within an Ethereum smart contract that is publicly accessible and free to use. The entire 0x smart contract has approximately 100 lines of code and costs ~90k gas to fill in order. There are four main components to this smart contract:

  • Signature Authentication.

  • Fills and Partial Fills.

  • Expiration Time.

  • Canceling Orders

  • Signature Authentication

The signature authentication is the first part of the Smart Contract. The contract is able to validate the Maker signature through the ecrecover function which takes a hash and signature of the has as arguments.

It also returns the public key that produced the signature. Then, if the public key returned is equal to the maker address, the signature is authentic. address publicKey = ecrecover( hash, signature( hash ) ); if (publicKey != maker ) throw;

  • Fills and Partial Fills

In order to stop the repetitiveness of orders, the smart contract stores a reference to each previously filled order. The references are stored as an SHA 3 Keccak hash. Since the hash for a particular input is unique, it makes sure that repetitive orders aren’t filled.

A Taker may partially fill an order by specifying an additional argument, valueFill when calling the exchange smart contract’s fill function. Multiple partial fills may be executed on a single order so long as the sum of the partial fills does not exceed the total value of the order.

In the bid to stop the repetitions of orders, there is a reference to each order filled in the past. The references are stored as an SHA 3 Keccak hash.

A Taker may partially fill an order by specifying an additional argument, valueFill when calling the exchange smart contract’s fill function. Multiple partial fills may be executed on a single order so long as the sum of the partial fills does not exceed the total value of the order.

  • Expiration Time

Every order in the 0xProtocol has an expiration time as specified by the Maker which is specified at the time that the order is signed. The value of the expiration time can’t be changed once it has been signed.

  • Canceling Orders

An unfilled order can be canceled before its expiry date by the associate Maker through the cancel function. Canceling an order costs gas and, therefore, the cancel function is only intended to serve as a fallback mechanism. Sources

The 0x Whitepaper notes one case where the cancel function may create an issue:

One issue with this approach is that it can create situations where a Maker attempts to cancel their order at roughly the same time a Taker is attempting to fill that same order. One of the two parties’ transactions will fail, wasting gas, depending upon the sequence in which the two transactions are mined. Uncertainty regarding the sequence in which transactions are mined could lead to undesirable outcomes at times. This uncertainty could increase if the Ethereum blockchain were to experience a significant backlog of pending transactions.”Sources

What Are 0x ( ZRX ) Tokens?

These are tokens of the 0x Project and it is unique to the 0x Ethereum blockchain, it is known as ZRX. This token is how users pay Relayers’ trading fees. It is also a decentralized form of governance for the 0x protocol’s upgrade system.

What are the benefits of 0x?

  • Trustless low friction exchange of Ethereum based assets.
  • Simple navigation from one token to the next on the blockchain. Exchanges involve high costs, which 0x is trying to break down.
  • When gas fees add up quickly, and transactions can get slow, 0x fixes this by moving most of its transactions off-chain, or outside the blockchain.
  • The 0x coin also brings with itself voting rights, allowing users to democratically decide on features, updates, and changes to be made to the 0x blockchain.

Final thoughts

A careful look at the flaws of many centralized and decentralized cryptocurrency exchanges, it only seems proper and logical what 0x has done. It has effectively taken care of the very many flaws seen in decentralized exchanges and it is however certain that 0x will grow quickly, providing the basis for other similar exchange systems using the Ethereum blockchain.


Useful links

0x Website
0x Whitepaper


Congratulations! This post has been upvoted from the communal account, @minnowsupport, by Donnest from the Minnow Support Project. It's a witness project run by aggroed, ausbitbank, teamsteem, someguy123, neoxian, followbtcnews, and netuoso. The goal is to help Steemit grow by supporting Minnows. Please find us at the Peace, Abundance, and Liberty Network (PALnet) Discord Channel. It's a completely public and open space to all members of the Steemit community who voluntarily choose to be there.

If you would like to delegate to the Minnow Support Project you can do so by clicking on the following links: 50SP, 100SP, 250SP, 500SP, 1000SP, 5000SP.
Be sure to leave at least 50SP undelegated on your account.