Table of Contents
- Alpha Exchange – Using Liquidity Pools
- FIN Comparison
- Beta Exchange – Off Chain Matching
- How does FIN circumvent high fees
- Gamma Exchange — Computational Complexity of O(n)
- Delta Exchange — FIFO order matching
- FIN — “Everyone Deserves To Be A Whale”: Pro Rata
- Conclusion
- Useful Links
Recently, we have seen a surge in orderbook-style exchanges cropping up on the Cosmos network, highlighting its growth as a competing ecosystem/layer 1. At Kujira, we are thrilled to see the network get the recognition it deserves, but we have noticed something about the new exchanges. They are AMM / orderbook hybrids, and not traditional orderbooks.
This gives us the opportunity to reinforce why we think FIN avoids all of the problems faced by this hybrid model.
How do AMM/Orderbook hybrids work?
AMM/Orderbook hybrids work using liquidity pools and limit orders. The AMM pricing algorithm will calculate a price and when this matches the price of the limit order the trade is executed. This means there is no order-to-order matching algorithm that is synonymous with all orderbook exchanges.
2025 — The DEX Battle
To illustrate how these hybrid models may fall flat, imagine the year is 2025. After 3 full years of DEX battles, FIN is on top. While competition was tough, in hindsight it was inevitable — from the 4 main competitors, different issues arose over time due to various components of the hybrid model. I will explain how each feature contributed to its demise, and contrast how FIN avoids the problem entirely.
Note — all exchanges in this article are entirely fictional and the outcomes are purely speculatory. This format allows me to compare FIN to this hybrid model and outline chokepoints that are avoided when using our exchange.
Alpha Exchange — Using Liquidity Pools
Meet Alpha Exchange — an orderbook/AMM hybrid. Since Alpha exchange incorporates components of an AMM, they have been using liquidity pools for over 3 years. As the swap APR for most trading pairs on Cosmos was around 0.5%, Alpha Exchange had to encourage LPs to supply liquidity by offering inflationary rewards in the form of their token, $ALPHA.
$ALPHA Inflation
This worked for the first year or so, but liquidity on Alpha Exchange began to decrease as the token supply continued to inflate. With no alternative value accrual to $ALPHA, there was no reason for investors to speculate on its price. If tokens are entering the market through LP rewards, but no investors are willing to buy them, what do you think happens next?
$ALPHA Token Price Plummets
As the price of $ALPHA continued to decrease over the next 2 years, the APR for LPs dropped with it. Fast-track to 2025 and the incentive to LP on Alpha is now far less than the opportunity cost of holding each asset (due to impermanent loss) and nearly all liquidity has been pulled from the exchange.
Unfortunately, this is a possibility for exchanges that use liquidity pools to execute trades. Unless the underlying inflationary token can hold value as the supply increases, the APR for LPs will decrease until there is no reason to provide liquidity anymore.
How has FIN compared?
Since FIN is an orderbook that doesn’t use liquidity pools, no inflationary incentives were required to encourage LPs to deposit liquidity. Instead, market makers, traders and arbitrageurs provided the liquidity required to facilitate trading.
As the volume continues to rise on FIN, so does the organic revenue created which is distributed to all KUJI stakers. With higher volume, market makers can expect higher returns for providing deeper liquidity, which results in lower slippage and a thicker orderbook. Over the years, FIN has cemented itself as a durable, robust exchange that has been able to scale efficiently.
Beta Exchange — off-chain matching
Beta Exchange is an AMM/orderbook hybrid that utilises an off-chain order matching mechanism. On-chain transactions are often expensive with fees rising during times of network congestion, so to solve this Beta Exchange has moved the matching algorithm off-chain.
Fees
Now that the fees are next-to-nothing, the exchange can handle thousands of orders cheaply and thus faces fewer issues with scalability. This allowed Beta Exchange to grow exponentially until that fateful day in 2023…
Lack of Transparency
Off-chain matching algorithms sacrifice the one thing that is integral to decentralised networks — transparency. Since the matching of orders could not be verified by individuals in a trustless manner, the system could be exploited by internal employees.
Market Manipulation!
By preferentially matching orders to their trades, members of Beta Exchange could ensure they were filled before anyone else, manipulating the market. It was only after a whistle-blower alerted the public to this that the exchange had to shut down and trading was halted.
While this is obviously a dramatic over-representation, it brings up an important and valid point — Unfortunately, information asymmetry in crypto has become synonymous with exploits/manipulation. If you cannot verify what is happening, why should you trust it?
How does FIN circumvent high fees while being 100% on-chain?
Considering the limitations of both on-chain and off-chain matching systems, an orderbook DEX with low fees, 100% transparently on-chain and entirely scalable would be the best of both worlds. Time to re-introduce “Hans’ Special Sauce”:
The orderbook model is not new, with the algorithm existing for a long time. The problem is that it does not transfer efficiently into a blockchain environment. To explain, let’s look at an example:
Thought exercise: Matching algorithms
Take a list of 10 buy orders, 10 sell orders, and try to configure a matching algorithm to match the two orders. Easy right? Now, increase the number of orders that need matching to 10,000 or 100,000. The same algorithm created for just 10 orders will be entirely inefficient with a larger number of orders, resulting in major issues with scalability.
O(1) computational complexity
The solution is to create an algorithm with the computational complexity of O(1). To achieve this, the matching algorithm must always execute in the same amount of time, regardless of how many orders there are.
This allows FIN to operate with constant fees and speed as its volume continues to grow, creating an entirely scalable product. Hans’ Special Sauce! But what if an exchange uses a matching algorithm that cannot achieve a computational complexity of O(1)? Meet Gamma Exchange.
Gamma Exchange — Computational Complexity of O(n)
Gamma Exchange worked perfectly in its first year of inception, experiencing periods of rapid growth in TVL and volume. Yet, one thing the exchange did lack was a matching algorithm with a computational complexity of O(1), instead only achieving O(n).
Linear Complexity
This is known as linear complexity, meaning the runtime of the matching algorithm increases (nearly) linearly with the number of orders. This wasn’t a problem as Gamma Exchange was growing since the number of orders was low, leading unsuspecting investors to grow in confidence.
Increased Validator Costs
However, as the number of orders steadily increased, validators on the network found that they needed to run higher quality hardware to handle the volume of transactions. This increased the costs of each validator, tightening their profit margins — something had to change.
Increased Gas Fees
To combat this, Gamma exchange needed to pass this rise in cost onto its customers in the form of increased trading fees (or inflationary rewards). It is often true that fees on exchanges are correlated to the computing power required to run a node, thus the more expensive it is for validators, the higher the fees.
As fees increased, users became discouraged to use the platform and trading volume steadily decreased. Validators were now running high quality, expensive hardware to validate far fewer transactions for less profit. I’ll spare the details of what happened next, but it’s safe to assume Gamma Exchange slowly fizzled out of market dominance as validators jumped ship.
Delta Exchange — FIFO order matching
When orders are matched and executed, there are several ways exchanges prioritise which ones are filled first. Back in 2022, Delta Exchange decided to use First-In-First-Out order matching, prioritising orders placed first at each price point.
An Example
If I place an order at $15.00 and 30 minutes later you also place an order at $15.00, your trade will not be executed until my entire order has been filled.
Issues with FIFO
Over the last 3 years, Delta Exchange has become a hotspot for traders with large amounts of capital. Due to the way FIFO works, a whale can place a limit order early in the orderbook and guarantee no one else can trade at this price until his entire order has been filled (or the order is removed).
If the order is particularly large, it may absorb all selling pressure before price reverses, resulting in all orders beneath it never executing. You can see why this might ruin a smaller users trading experience!
Front-running
However, trade execution has no real effect on the scalability of an exchange, it simply changes the user experience. What really caused Delta Exchanges demise? Front-running.
In crypto, front-running refers to the process of pushing your transaction ahead of other trades waiting to be processed. This is achieved by paying a larger gas fee so that miners process your transaction before others waiting to be processed.
Why FIFO Encourages Front-Running
This provides an opportunity for profit. For example, if I know there is a large buy order waiting to be processed that will move price, I can front-run this with my own buy order before selling immediately after for near-instant profit. The opportunity to front-run trades is omnipresent, but with FIFO execution the front-runner can receive all the rewards by placing his trade first.
As more and more orders were front-run, users of Delta Exchange noticed their trades were being executed at a worse price than what was quoted. As time passed, users migrated to an exchange with far superior trade execution — one in which trades were given equal opportunity for a fill and executed at quote price. “Which exchange was this?” I hear you ask…
FIN — “Everyone Deserves To Be A Whale”: Pro Rata
FIN uses an order-matching principle known as pro-rata which only accounts for price and not time. In this way, all orders are executed in proportion to their weight at specific price points.
How It Works:
At a price of $100 there are 3 orders:
- Person A — One limit order for $500
- Person B — One limit order for $1000
- Person C — One limit order for $1500
Therefore, in total there is $3000 in limit orders resting at $100. Person A owns 16.6% of all orders at $100 (500/3000), Person B 33% and Person C 50%.
Let’s say an order comes in for $500 at a price of $100. Person A would receive 16.6% of this order ($83.33), Person B $166 and so on, ensuring that everyone receives a partial fill. We believe this is the fairest approach to order execution, providing equal opportunity for fills to both whales and shrimp alike.
Mitigating Front-running
Pro-rata order matching also helps to mitigate the front-running of trades too. When a front-runner manages to execute his trade before other orders, the matching algorithm will still execute partial fills on all other orders placed at that price-point. This reduces the profitability of each trade as the spoils are shared between all orders rather than just the first to be placed. Neat right?
Conclusion
Given that the main issue regarding scalability on AMMs is the use of liquidity pools, this new hybrid model doesn’t solve anything. The system is flawed unless the exchange can produce other avenues of value accrual to the token — something that few cryptocurrency protocols have achieved.
With FIN you get the best of both worlds: a gas-efficient orderbook that can scale easily. We don’t pretend to offer you an unrealistic “yield” in the form of inflationary rewards, we simply offer the sustainable revenue produced by our dApps. With our ethos “Everyone deserves to be a Whale”, we believe that pro rata trade execution achieves this best, giving everyone the same opportunity to fill orders.
Useful Links
- Learn about our new stablecoin USK here.
- Learn about our Incubator Program “Kujira Labs” here.
- Trade on our exchange, FIN.