Ēnosys Dex V3

Ēnosys
5 min readJun 10, 2024

--

First of many deep dives.

Ēnosys DEX V3 is a Concentrated Liquidity Market Maker (CLMM) based on the Uniswap V3 architecture. But what does that actually mean?

To understand CLMM’s let’s first talk about AMMs and how AMMs like DEX V2 handle trades, liquidity and positions.

In this article, we will discuss trading and how they differ between CLMMs and CPAMMs.

CPAMMs and Trading

DEX V2 is a Constant Product Automated Market Maker (CPAMM).

CPAMMs utilize the function XY=K where K is a constant determined by the initial liquidity ratio for X and Y. Changes to the balances of X and Y are controlled by the demand that K remain constant.

When a swap occurs in the pool, the input, output and resulting price are calculated on the XY=K curve.

For example, let’s say we are going to swap some FLR for some HLN. This swap can be written as:

dX = Amount of FLR going in

dY = Amount of HLN going out

When applied to the equation XY = K, we get (X+dX) (Y-dY) = K.

X is the amount of FLR in the pool before we added dX FLR because we sold FLR to the pool, and Y is the amount of HLN in the pool before we removed dY HLN because we bought HLN from the pool.

Visually, this trade would look like this if graphed on the curve

You can see that the point on the curve has moved down the Y axis, because we removed HLN from the pool, and moved out on the X axis, because we deposited FLR.

Now, this equation is relatively simple and produces very predictable trading based on available liquidity. However, due to the curve extending from 0 to infinity on each axis, the amount of liquidity being utilized at one time is very low compared to the total value in the LP. Generally, CPAMMs only utilize about 0.5% of total liquidity within each +/- 1% price range. This means that to have $10k worth of liquidity within 1% of the current price, the LP TVL would have to be around $2M.

This also means that every unit of liquidity is fungible because it covers the same range as every other unit of liquidity. This is why DEX V2 positions are represented by an ERC20 LP token which is fungible and receives the same share of fees generated as every other LP token.

Ok, now that we got that out of the way, you can forget all about it!

CLMM vs CPAMM

DEX V3 is a CLMM, which differs greatly from CPAMMs in that liquidity providers can choose the range on the liquidity curve to which they provide liquidity rather than passively providing liquidity to the full range.

This means that where a CPAMM pool would have to hold $2M of liquidity to achieve a $10k 1% spread, a CLMM could achieve the same $10k of liquidity with…$10k!

It works like this. Let’s once again consider the FLR (X) and HLN (Y) LP where we measure the price of FLR in terms of HLN. When you provide liquidity for this pair, you chooses a price range [𝑝𝑎, 𝑝𝑏] in which you would like to provide liquidity. Together with the current price 𝑝, this determines the ratio of the two tokens you need to deposit. The exact amounts of both tokens the LP decides to deposit then determines the amount of liquidity 𝐿 provided to the interval. Creating a position which does not cross p is called an out of range position, but we will talk about that in a later article.

For now, just understand that range bound (concentrated) positions create what is referred to as the virtual reserves where trades happen on the XY=K curve as though your $10k of liquidity were $2M of liquidity in a CPAMM . This means that as more liquidity concentrates within a certain price range, it takes more input of X to move the price ratio with Y.

Visually, it looks something like this:

You’ll notice that the virtual reserves appear very similar to the 0 to infinity curve of xy=k, whereas the real reserves have an actual x and y intercept. This is because the real liquidity in a concentrated position has a terminus at each end where all of asset X has been sold to buy Y, or vice versa.

On the virtual curve, when a position is fully traded and the price moves out of range, the constant K is recalculated to take into account the new level of real reserves in the trading range based on the liquidity available in the currently in range positions.

It’s not important that you understand fully how the math works, but it is important to understand that as the current price moves out of higher liquidity areas on the curve, the trading efficiency decreases and slippage increases unless liquidity providers rebalance, or add new liquidity to the new trading range.

This also means that only liquidity positions that have real liquidity in the current trading range will receive fees for trades in the LP. If the current trading range moves outside of your position’s price range, you stop receiving trading fees because your liquidity is no longer being used. If the trading range moves back into your position’s price range, you begin earning fees again. Generally, these fees will be much greater per unit of liquidity than in a CPAMM where only a small fraction of your liquidity is being utilized at any given time.

Below is a visualization of the liquidity differences between a CPAMM where the liquidity is even spread along the entire curve, a CLMM position where the liquidity ends at the edges of the price range, and an LP with multiple positions (including full range positions) where liquidity is most concentrated at the current price, thereby supplying the deepest liquidity where it is needed the most.

Hopefully this has provided some basic understanding on how CLMMs work and how they increase capital efficiency vs traditional CPAMMs.

In the next article we will discuss creating positions on Ēnosys DEX V3 and some simple strategies that can be considered.

--

--

Ēnosys

Formerly FLR Finance. Decentralized Finance Platform on the Flare Network.