Mercurial x Serum: Serum DEX, On-Chain Serum Swap Integration, and more!

Meteora
7 min readAug 31, 2021

--

This is an article written by Mercurial’s community member @tiddernips to explain Serum. If you have more questions, you can ask him and our other knowledgeable members, in our discord!

What is Serum DEX?

The evolution of DeFi has been on an exponential trajectory since the Summer 2020 DeFi boom. One of the latest developments to propel DeFi forward comes from the Project Serum team. Serum is a decentralized Central Limit Order Book, or CLOB for short. Serum decentralizes the traditional order book by replacing the central authority with a smart contract, making the exchange trustless, permissionless, and transparent. Order books are starkly different from Automated Market Makers, or AMMs. By trading on Serum, users are able to specifically choose the order direction (buy or sell), the price rate and the size of their trade. And, Serum’s on-chain smart contract will automatically match and fulfill those trade orders.

How Does Serum Share its Liquidity?

Serum DEX provides an order book for any market. These markets can be accessed by any program on Solana. This means it’s possible to trade the same market on a completely different website. In fact, it’s quite possible a user may be trading on Serum Dex without realizing it!

Examples of trading Graphical User Interfaces (GUIs) that allow a user to trade on Serum Dex include Bonfida, Mango Markets, Symmetry Swap, and many more. All 3 of these exchange interfaces are accessing the same underlying markets from Serum DEX. This shared liquidity is one of the most powerful attributes of Serum as it pools liquidity in one place, on-chain, in a way that makes it accessible for any other applications on building on Solana.

How to Trade on Serum?

First, users need to select the market they wish to make a trade in. Serum offers the largest variety of SPL token markets that a user can trade in. When making a trade in the desired market, users need to specify which direction they wish to trade. Orders can move in two directions, a buy or a sell order. After specifying the direction of the order, users need to input the price rate they wish to receive on the order and the size of the order. Users are able to view open orders for that specific market in the “Open Orders” tab underneath the chart.

When placing orders on the Serum DEX, they will not be executed until there is another buyer/seller on the other side of the trade that meets your order criteria. This means that the order will remain open until either fulfilled or canceled. However, Serum orders can be partially filled, meaning the entire size of your trade order is not met yet. To prevent orders from being partially filled, a user can use IOC which I will discuss later in this article.

How to Find the Right Price to Execute Your Trade?

Let’s look at an example Serum DEX Market, MER/USDC. Buy MER orders are in green and sell MER orders are in red. Each order indicates the “Size” (in MER) and “Price” in (USDC). The graph on the left indicates the historical prices for orders that have been executed. A user can refer to the graph as well as this number to find a price to set for their order.

If a user is looking to have their order executed immediately, they will need to create a buy/sell order that matches an existing order in the orderbook. The easiest way to do this is to click on the order you wish to buy/sell into. The criteria from this trade will automatically load into the user’s interface, all they will need to do is change the size of the order to their desired size.

What Do POST and IOC Mean?

By enabling POST, a user is turning their order into a Post Limit Order. A post-limit order ensures that the order is not immediately matched and executed. A post-limit order must either be added to the order book or canceled. The reason for this is that orders that are immediately matched and executed, will incur a taker fee of 22 bps, or basis points, for taking liquidity out of the order book.

By enabling IOC (Immediate-Or-Cancel), a user is specifying that their order is executed immediately and any portion of an IOC order that cannot be filled immediately will be canceled. This is helpful when a user does not want a partial fill on their order and remaining funds to sit in the intermediary account until filled or canceled.

Why are my Funds not in my Wallet and What is a Settlement?

Funds do not automatically transfer to a user’s wallet. When you submit a trade order to Serum, the assets are sent to an intermediary account before executing. This means that the assets are removed from the user’s wallet and deposited into an intermediary account and as the trade order gets fulfilled the funds from that trade remain in that intermediary account until the user settles them back to their wallet.

To fetch the funds from the intermediary account, a user must manually settle their balance from the Serum DEX. Settlements can be found underneath the order form and are manually necessary after successfully transacting on the Serum DEX.

How to Reduce Trading Fees?

Each trade on Serum DEX has a fee associated with it. Holding SRM, the utility token of Serum, will reduce the amount of fees by up to 50%. Holding 1 MSRM, or 1 million SRM, gives a 60% discount on fees.

What are Price Fulfillment and Size Increments?

When using Serum, there are a few markets that require a user to trade an increment of 0.1. A few of these markets are SOL and FTT. When a user executes a trade in one of these markets, any left over funds that cannot be used in the trade will be returned back into the user’s unsettled balance. The user will then need to settle and approve the transaction to move the funds back into their wallet. Many users often forget to settle their funds after transacting on the Serum DEX. It is important to always settle funds after using Serum DEX.

Another important thing to take note of when using Serum is price fulfillment. For an order to execute on Serum DEX, there needs to be a buyer on the other side of the trade. When you open an order, the order will remain open if the price is higher than the price of the highest buy order. If a user is looking to execute a trade immediately and not at a specific price, they will need to look at the orderbook on the right-hand side. Here a user can see all of the open buy and sell orders for that specific market. To ensure the best chances of having an order filled, a user can set the price of their sell order at the value of the highest buy order or their buy order at the value of the lowest sell order.

Mercurial Cross-Protocol Swap Integration with Serum

Using Serum can often be overwhelming to new users. Creating an easy-to-use interface to execute all of these steps, in one simple click, would alleviate a lot of the confusion in a new user’s experience. Enter the Mercurial x Serum partnership. Mercurial Finance recently released an on-chain swap integration with Serum which simplifies all the steps in a single click.

On Mercurial, it will automatically find the best price for a trade as well as handle the settlement for the user. On top of that, Mercurial will help the user swap tokens that are not in a direct market. This is able to happen because the integration utilizes both Mercurial and Serum’s liquidity in one transaction. The swap is first routed through Mercurial’s stablecoin pools to find a stablecoin that has an open market on the Serum DEX with the asset of choice. After exchanging for the correct stablecoin, an order is then placed on Serum with instant fulfillment and settlement for the user. Give Mercurial’s swap a try if you want a simpler and immediate trade.

--

--

Meteora
Meteora

Written by Meteora

Building the most secure, sustainable and composable yield layer for all of Solana and DeFi. Discord: https://t.co/vJ6ey5RYnm

No responses yet