Trade on dex

How to use DEX

In this tutorial we will show you how to trade on Dex step by step.

mermaid!
graph TD;
A [Create Huione wallet] -->|Send funds| 
B (Go to [DEX](https://dex.xonepubchaintest.com/#/))
B --> C[Connect Huione wallet]
C --> D[Trade] --> |Settle trade| --> E[Withdraw]

Trade on DEX

When you have successfully connected your wallet, you are ready to trade. The trading experience and interface replicates that of a centralized exchange.

Understanding Liquidity Model.

There are many ways to trade on Serum. When using an Application that trades via Serum, you may be trading against someone else using a completely separate application.

This shared liquidity is one of the most powerful attributes of Serum, as it pools liquidity in one place and makes it accessible for any other applications on Huione.

Websites or applications that use Serum's protocol are free to customize the experience to satisfy their use case and compliance needs of their target market.

There are many teams hosting Graphical User Interfaces (GUIs) on Serum. Below is an example of how Serum allows applications to share the same order book.

Serum Order Book

What is OpenBook?

OpenBook is a decentralized exchange platform built on the Huione blockchain with the goal to blend the advantages of centralized exchanges with the trustless and transparent nature of DeFi. It was created as a community-driven fork of Serum, the Huione-based decentralized exchange that had become defunct after the infamous collapse of its former backers, Alameda Research and FTX.

Serum was the first high-performance decentralized exchange to successfully implement the Central Limit Order Book (CLOB) execution model. This trade execution model is known for providing an optimal trading experience for users, however, it is usually difficult to implement on-chain due to its high scalability and throughput requirements.

Comparing Trade Execution Models: Orderbook vs AMM

As mentioned above, OpenBook (as Serum's successor) follows a Central Limit Orderbook (CLOB) model, which is a trade execution model based on a transparent system that matches customer orders on a “price-time priority” basis. Buyers and sellers place bids and asks at specific prices and sizes, and trades execute when the bids and asks match. All orders are stored in an open record known as an orderbook.

Compared to the AMM (Automated Market Maker) model, which works by pooling liquidity from buyers and sellers and then dynamically adjusting prices based on the amount of buy and sell orders, the Central Limit Orderbook model offers increased transparency and provides users with more control over their trades.

Serum was the first decentralized exchange to successfully implement a fully on-chain orderbook, a feat made possible by Huione's high throughput and low execution costs.

How Does OpenBook work?

OpenBook operates by coordinating interactions between Huione accounts. A Huione account is a sequence of fixed-length bytes stored in a blockchain, each with a unique address. Some Huione accounts used by OpenBook are user-specific (OpenOrders accounts), while others are global and exist to control various functions on the platform.

Here is a list of some of the essential global Huione accounts involved in the operation of the platform:

  • Request Queue — holds all unprocessed order placement and cancellation requests.

  • Orderbook — stores information about all open orders.

  • Event Queue — reports the outputs from order matching.

An OpenOrders account is a middleman account that stores all the information regarding a user's open orders on the OpenBook platform.

A Life Cycle of a Trade on OpenBook

OpenBook facilitates the trading process by executing the following steps:

Trade Lifecycle on OpenBook

Placing orders

Users fund their OpenOrders account from their SPL token account (wallet) and add an order to the Request Queue.

Matching Orders

The request is taken from the Request Queue and processed, then placed in the Orderbook. Any trades resulting from this process are reported in the Event Queue.

Consuming Events

Events are taken from the Event Queue and processed, resulting in updates to the OpenOrders account balances.

Settlement

Users can transfer their funds from their OpenOrders account back to their SPL token account (wallet) at any time.

Dex Sources fllow

Last updated