Understanding Hybrid DEX

Kevin Meowth
CrescentNetwork
Published in
7 min readSep 19, 2022

We are witnessing a variety of experimental DEXes coming out to overcome existing AMMs. As an operating app-chain with technological supremacy, we want to show you what future DEX looks like and how it works by describing Crescent DEX.

AMM or Order book?

Before we start, let’s compare AMM(Automated Market Maker) and order book market maker in each criterion.

  • Capital Efficiency: The capital efficiency in AMM is very low because it has to provide liquidity for all price ranges, while market makers in CLOB(central-limited-order-book) supply liquidity within more tradable price ranges. Most of the capital locked in AMM is not likely to be used.
  • Freedom: AMM has a low degree of freedom because the algorithm decides how much liquidity is provided from liquidity pools, and any LPs should abide by it.
  • Execution: With great freedom, market-making activities in order book are quite burdensome work with frequent order correction following price movement. AMM, on the other hand, liquidity providers can deposit and forget.
  • Openness: Only full-time traders with technical support can participate as order book market makers because of its complexity in execution. However, any individual can join in AMM as a liquidity provider.
  • Matching: Lots of transactions coming in and out in order books can cause high computational complexity. AMM is relatively simple because it does not need transactions to provide liquidity.

No one is necessarily superior in every aspect. Order book market makers have the upper hand in capital efficiency and degree of freedom but require many resources to engage in the market actively.

An automated market maker has little freedom in providing liquidity and low capital efficiency, but it is easy to deploy for retail users. That is why AMM succeeded in blockchain, where transactions are costly.

Hybrid DEX!

Uniswap(concentrated liquidity) + Dydx(orderbook) = Crescent

Crescent has introduced hybrid DEX, combining advantages from AMM and order book. Liquidity providers can participate in the market as they put capital into the pool, and at the same time, traders can enjoy a CEX-like trading experience through order book. Liquidity pools locate limit orders on each tick with order amount, which is calculated from CPM(Constant Product Model) and all the trades are matched on the order book.

On top of the basic pools, we have adopted ranged liquidity(aka concentrated liquidity). Users can enjoy much higher freedom in providing liquidity compared to basic pool by setting the price range they want. These multiple pools can participate in the marketplace for each coin pair.

In Crescent, all transactions are transparently conducted on-chain, and operate in a batch auction system trying to avoid unnecessary low-latency competition. Orders from multiple pools, market makers, and retail traders meet once in each batch. The price discovery must work adequately through fair competition between traders and market makers to build a more equitable marketplace.

As a result, retail investors can easily make pool investments in LP farming like AMM. At the same time, liquidity supplied by the pool is visible in the order book so that traders can trade against them. If they set the price range for the pool, one can provide liquidity much more efficiently.

In order book, traders can place a limit order at a specific price, and then they may not experience slippage like AMM. Users can enjoy the convenience of AMM and the agility in trading from order book simultaneously in Crescent.

How does AMM work with order book?

Let’s do some basic math to help you to understand CFMM(Constant Function Market Maker). We especially adopt CPM(Constant Product Model) for our AMM.

Constant product means the product of reserve is always the same after the swap. The following graph shows the change in pool reserve when someone pays ∆y to obtain ∆x from the pool.

  • x, y: initial reserve of ABC, XYZ token
  • ∆x, ∆y: the amount of change
  • P: Initial pool price (=x/y)
  • P_s: swap price(=∆x/∆y)

It is easy if we start with an example.
The liquidity reserve of ABC and XYZ is 100 and 200 each. (x = 100, y = 200, P = 0.5)
If we put 50 XYZ in the pool, we get 20 ABC from it.

(100 — ∆x)*(200+50) = 100*200
∆x = 5000/250 = 20
The swap price of this transaction is 0.4
∆x/∆y = 20/50 = 0.4

When we put 25 ABCs in the pool, we get 40 XYZ. The swap price is 0.625
(100 + 25)*(200 — ∆y) = 100*200
∆y = 5000/125 = 40
∆x/∆y = 25/40 = 0.625

It is safe to say that the XYZ/ABC pool (with a pool price of 0.5) can provide 20 ABCs for 0.4 and 40 XYZs at 0.625.
In other words, users can buy 40 XYZs in exchange for 25 ABCs(buy price 0.625), and sell 50 XYZs getting 20 ABCs (sell price 0.4) from the pool.

If we generalize this equation,
Initial position was x*y = k, and moved position is

CPM means k = k’ therefore

We can derive ∆x with ∆y (How many ABC tokens can we get with given XYZ?)

Swap price is

Then we can say we pay ∆y at a price P_s and get ∆x

We can switch this into another form, we can say ‘Pool can provide ∆x amount of ABC token at swap price P_s”.
To generalize, we flip both sides of the equation (a)

multiply x∆x on both sides,

This equation stands for ∆x of ABC token can be provided at P_s by the pool. We can also obtain ∆y by using the same derivation.

The derived liquidity depth provided by the pool is as follows.

XYZ can be provided up to 200 at infinite price

The amount of liquidity possible to deliver by the pool will differ according to the price.

To place orders in order book, we must make them discretely. We introduced tick system to work it smoothly. Liquidity on tick(i) is the difference between liquidity depth on tick(i) and tick(i-1).

Liquidity pool automatically places orders on each tick

As I’ve mentioned before, a couple more pools can place limit orders on the same pair. Ranged pool is no different from the basic pool in calculating liquidity. The only difference is that the whole token is consumed at the end of the price range.

Liquidity Depth of Ranged pool with P_min 0.25, P_max 1.0

Market Maker Incentive Program

On top of liquidity pools, we are to deploy a market maker program to add more depth to the market. Market makers can provide liquidity much more efficiently by placing orders around the current price. For example, $10,000 depth at ±1% of the current price generated by the market maker has the same effective liquidity as the $2 million basic pool offers. Therefore, users can enjoy a level of UX and deep liquidity equivalent to the CEX.

Crescent will launch an incentives program to attract competent market makers. The program will manage the list of market makers, evaluate them, and distribute incentives. The target token will be major tokens that are easy to hedge. Market makers will show capital efficiency comparable to that of the traditional financial market in providing liquidity for these pairs.

The activity of ATOM/USDC pair is growing rapidly, which shows the potential for deep liquidity

Market maker evaluation is done off-chain with on-chain data stored in Crescent network. Codebase will be publicly accessible for any third-party verification. Scoring the quality of the liquidity provided by market maker is different from AMM providing static liquidity.
The availability of liquidity is one of the most important factors, which will be measured through market makers’ uptime. Besides, contribution score calculated based on spread and depth will be reflected. Market maker score is calculated and share of incentives will be distributed through governance every month. Market maker program will launch this year.

The introduction of market maker is essential in creating capital-efficient exchanges and further growth in the future. Users can trade major tokens such as BTC and ETH which have been challenging to trade efficiently in Cosmos ecosystem. Eventually, this liquidity will be the basis for further Defi derivatives. We also have plans to support market makers for native tokens of newly launched projects in Cosmos. It is going to be a completely different experience for projects and users.

--

--