# Blog Posts by Justus

Canonical page: https://justus.sh/blog

## Quantum Computing - An Overhyped Science Project (for now)

- URL: https://justus.sh/blog/Quantum_Computing_-_An_Overhyped_Science_Project_(for_now)
- Markdown URL: https://justus.sh/blog/Quantum_Computing_-_An_Overhyped_Science_Project_(for_now).md
- Source: https://raw.githubusercontent.com/jstEagle/Personal_Blog/main/posts/Quantum%20Computing%20-%20An%20Overhyped%20Science%20Project%20(for%20now).md
- Date: 2025-10-28
- Tags: Educational, Computers, Physics

Quantum computing, much like fusion energy is a field of technological innovation the exhibits a phenomenon where every 2-3 years it gets a brief moment in the media limelight.

![](Pasted%20image%2020251027125246.png)
And well.... its that time again.

### Motivation
I just want to preface the rest of this article by saying that I have absolutely **no** financial interest in any of this. I am not invested in any of the companies that may be mentioned and I don't have any long or short exposure on any of the stocks mentioned.

If there is something that really grinds my gears. It's media outlets blowing up tech news *way* out of proportion by writing sensationalist posts about new developments in a field. As we saw in the last few months with quantum computing. As a symptom of many people being exposed to these advanced technical concepts; with the added ability to jump in on the hype by buying in on these companies through the convenience of their phone. There is a lot of misinformation circulating about quantum computing.

So lets clear up what quantum computers really are. What they can and can't do. And why they aren't going to make "AI faster".

### What is a Quantum Computer?
A **quantum computer** is a type of computer that exploits some *really* cool quirks of quantum mechanics (definition: Physics that focuses on interactions between individual particles at an atomic or smaller level.), such as superposition (definition: When a particle (system) exists in multiple states at once until measured), entaglement (definition: When two or more particles become linked so that measuring one instantly affects the other, at any distance apart.), and interference (definition: When quantume states combine in ways that amplify some outcomes and cancel others (just like waves) guiding probabilities towards a certain result.) - to perform calculations by exploring **many** possibilities in *superposition*. The actual power comes from **interference patterns** that bias outcomes (not from parallel universes literally computing all results).

This all sounds incredibly complicated. And it is!
But the main thing to know is that it works fundamentally different to normal computers. You can think of it as preparing a bunch of special quantum bits (qubits) that explore many possible solutions at once, and then, using clever tricks, extracting the right answer from all those possibilities.

### Is a Quantum Computer actually useful?
In short: yes. However there is more nuance to this than Google, IBM, Microsoft and every major tech media outlet would have you believe. Quantum computers are very good at very specific class of problems that are exponentially hard to run on traditional computers, but have some algorithm that can take advantage of all these quirks to allow for a good mapping to quantum principles.

In computer science, there is the concept of Algorithm Complexity (definition: This measures how the resources an algorithm needs, like time or memory, grow as the size of the input grows.). Complexity is a very useful measurement tool of how good an algorithm is. You can imagine this like two people looking for a book in a library using different algorithms. The first one simply looks into the catalogue and finds the bookshelf where the book is and then searches that one. The second person just looks through all of the bookshelves until they find the right book.


![](Untitled-2025-10-27-1321.png)

If there were 100 bookshelves instead of 3, the first algorithm would still take the same time as there is still only one bookshelf to be searched. But the second algorithm would take about 30 times longer on average because it needs to search all of the bookshelves present until it finds the book.

The main goal of quantum computing is to run algorithms that on our current best computers with the best we can do, require us to search the whole library. But on a quantum computer would allow us to go straight to finding the right book. This is the kind of advantage that leads to what researches call *quantum supremacy* - when a quantum computer outperforms classical ones on a specific task.

*Note: this is a very crude way of explaining how Quantum computers can be better. It is hard to provide a better explanation without assuming some understanding of computer science and mathematics. [Read this Wikipedia article to learn more about complexity.](https://en.wikipedia.org/wiki/Computational_complexity)*

### Some common misconceptions
Now let's go over some of the common misconceptions that are floating around.

##### Quantum computers are faster!
No, they are not.
Quantum computers, as mentioned before, can take advantage of some special quirks that allows for **different** algorithms to solve problems faster than algorithms that we can run on traditional computers. The most famous of these being [Shor's Algorithm](https://en.wikipedia.org/wiki/Shor%27s_algorithm) for factoring prime numbers and also [Grover's](https://en.wikipedia.org/wiki/Grover%27s_algorithm), sometimes called the "quantum search algorithm".

When it comes to actual speed, quantum computers are very slow compared to traditional computers. Speed in computers is measured how many "steps" or "cycles" the CPU can perform per second. Individual gate operations in current superconducting quantum processors run around the Megahertz range, far slower per gate than Gigahertz classical CPUs.

##### Quantum computers will change the world!
Hmmmmm..... possibly?
Quantum computers are no doubt useful in certain areas. Especially in some fields of science. But especially in recent years the advantage a quantum computer would have, has been reduced in a lot of areas.

In a lot of cases it may be useful. And even better than traditional computers. But, airlines already handle their scheduling very well. Amazon handles millions of packages a day with no issues. And video games and other physics engines simulate the world to an incredibly accurate degree. Technically yes, these could get better with quantum computers. But who is going to pay these huge amounts of money to optimise the path your uber takes on its way to deliver your burger by a couple of percent.

Of course this can be debated and argued endlessly, but from my perspective, there isn't quite as much value in a lot of these use cases as the companies building quantum computers would have you believe there is.

AI? Possibly small or uncertain improvements in specific algorithms that are heavily focused on linear algebra.

Physics simulations? Yes, but at a low level. Simulations of individual particles or cells will be more accurate which can be very useful for material science and medicine. But even here, there are already a lot of pretty good solutions already.

Other optimisations? Traveling salesman problem, Job scheduling, or large financial portfolios where every basis point counts. A lot of these problems are called [NP-hard problems](https://en.wikipedia.org/wiki/NP-hardness) which get more "expensive" or "difficult" to compute as the number of inputs gets larger in such a way that it is uneconomical or *impossible* to calculate solutions (at least in our lifetime).
*Again if you want to learn more, here are some links:*
- [QAOA (Quantum optimization algorithms)](https://en.wikipedia.org/wiki/Quantum_optimization_algorithms)
- [QUBO (Quantum unconstrained binary optimizations)](https://en.wikipedia.org/wiki/Quadratic_unconstrained_binary_optimization)

##### Quantum computers will make AI faster!
This is one I've heard a lot recently. And it's not a bad conclusion if you've just read the media articles (and there is no shame in that). In the end, AI inference - the process of taking some input tokens and calculating output tokens is just a lot of multiplication of numbers. This linear algebra on real numbers, not quantum amplitudes is not well suited to current quantum hardware. Or in other words, **a lot** of multiplication of numbers. And **a lot** of loading things in and out of memory. These constraints aren't loosened by making quantum computers, but by stuffing more transistors into more cores onto larger boards called GPUs.

As mentioned earlier, some algorithms used in training or optimisation of AI models may improve with better quantum computers. But those are still a while away.

### Quantum computers are NOT HERE yet.
No matter what Google would like you to believe. The currently largest quantum computing companies manufacture processors with very few qubits, a couple hundred to a couple thousand. And these are what are called **Physical Qubits**. The raw qubit implemented physically (e.g. a superconducting loop, trapped ion, etc). These have very large error rates, meaning that they are very inconsistent and not very usable. The **Logical Qubit** is the end goal. A *fault-tolerant*, *error-corrected* qubit built from many physical qubits (via quantum error correction). These are not achievable at scale yet and are still very experimental. So the numbers you are hearing in the news are not even the "right" kind of qubits. **And** it is important to remember that even a couple thousand qubits are not much! Once a superposition is collapsed (i.e. the qubits just end up being read as 1's or 0's) that is only enough space to store a few numbers or maybe a couple of words or maybe barely this sentence.

Me writing this article was provoked by a piece of news I saw the other day about Google's new revolutionary breakthrough on their Willow chip. [This](https://www.nature.com/articles/s41586-025-09526-6) paper which was being hailed as an incredible breakthrough in quantum computing by showing one of the first signs of "Quantum Supremacy". Was really just a contrived science experiment so specifically tailored to work on their quantum computer that it would have taken *an estimated* 13,000x longer on a traditional computer - though such comparisons depend heavily on simulation methods.

In essence they designed a very specific physics experiment that can be set up and measured on their quantum chip but is too complex for classical supercomputers to simulate efficiently.

![](Pasted%20image%2020251028212700.png)
*Not the Google quantum computer. Just here for illustration*

### Cryptography - actually pretty scary
This is where quantum computers actually get really interesting and yes, pretty scary. The world is built around encryption algorithms that keep **your data safe**. If you are sending a message to your friend, streaming a movie on Netflix or interacting with any of the most popular blockchains. You rely on encryption algorithms.

Most of these algorithms were implemented circa 30 or 40 years ago and a lot of the most common ones used today are quantum vulnerable. Most prevalent are:
- **RSA** - widely used for encryption and digital signatures, it is vulnerable because its security relies on the difficulty of factoring large prime numbers.
- **ECC** - A more modern and efficient alternative to RSA that is also vulnerable. Its security is based on the difficulty of the **Elliptic Curve Discrete Logarithm Problem**. *This is what secures Bitcoin and Ethereum using [secp256k1](https://en.bitcoin.it/wiki/Secp256k1]) and Solana using [Ed25519](https://en.wikipedia.org/wiki/Curve25519) which has some design advantages that make it more secure in practice than secp256k1*
- **Diffie-Hellman** - Used for secure key exchange (everything on the internet pretty much). It is vulnerable to quantum attacks that can solve the discrete logarithm problem.
- **DSA** - Similar to RSA and ECC, DSA is a digital signature algorithm that is vulnerable to quantum attacks.

These algorithms are all in danger if [Shor's algorithm](https://en.wikipedia.org/wiki/Shor%27s_algorithm) can be run on quantum computers with enough qubits. *Technical note: the complexity of Shor's algorithm is $O((\log N)^3)$ which means that over 1 million qubits would be needed to break SHA-256. And the estimate is about 13 million to break a 256-bit ECC public key in 24 hours.*

And so again, we are still a long time away from it being feasible to crack any kind of meaningful encryption. Some of the more (very) optimistic estimates range from 2-3 years. Personally I wouldn't be surprised if it took more than 10 years at least. However, progress is being made everyday and I won't claim to understand how AI and other advancements will affect the speed of development of these systems and algorithms.

Another important thing to note before everyone freaks out is that there are quantum secure encryption algorithms that simply use different approaches to encrypt data that cannot be cracked by quantum computers. Governments have started implementing these a while ago, and if this becomes any real threat, everyone will quickly scramble to switch everything over to these different encryption methods and a lot of the advantage will be gone.

### Conclusion
I've spent a long time ranting, seemingly trying to convince you that quantum computers aren't "good". **They will be!** And most importantly they are *incredibly* cool. Even the name sounds like it's straight out of Star Trek. But recently, things have just been blown out of proportion too much for my liking. I just don't like when fact and hype are at odds with each other.

Quantum computing isn't the end of classical computing - it's the sequel nobody green-lit but everyone's curious about. The plot's slow, the budget's enormous, and half the cast doesn't know their lines yet.

One day it might win awards. For now, it's mostly special effects and potential energy.

And that's okay - revolutions rarely start with fireworks; they usually start with error correction.

___

If you enjoyed reading this article. And have a decent understanding of mathematics. I would highly recommend you watch [this video](https://www.youtube.com/watch?v=RQWpF2Gb-gU) going a bit deeper into how quantum computing actually works by explaining Grover's algorithm.

---

## FusionAMM - The Gold Standard

- URL: https://justus.sh/blog/FusionAMM_-_The_Gold_Standard
- Markdown URL: https://justus.sh/blog/FusionAMM_-_The_Gold_Standard.md
- Source: https://raw.githubusercontent.com/jstEagle/Personal_Blog/main/posts/FusionAMM%20-%20The%20Gold%20Standard.md
- Date: 2025-08-24
- Tags: DeFi, Blockchain, News

### *Investment Disclosure:*
*This article will be discussing FusionAMM, a protocol created, owned and operated by DeFiTuna. As the author of this article I have personally been involved in the community for over half a year and have made substantial investments into their token $TUNA. I do not wish for this breakdown to come across as "shilling" or confirmation bias (that's what X is for). I will not mention anything other than the FusionAMM architecture any further. Any comparisons to other protocols are made solely for context and carry no intent of promotion or criticism.*

This article will assume basic knowledge of how order books and liquidity pools work. I recommend reading [my liquidity pool article](https://www.jsteagle.dev/blog/Liquidity_Pools_-_The_Core_of_DeFi_as_we_know_it) if you aren't familiar with these concepts.

### The Problem
Liquidity pools are great! They have a bunch of really cool features and allow for a **ton** of cool use cases that wouldn't be possible without them. But traditional order books still have one feature that LPs (definition: Liquidity Pools) don't. Limit orders.

> A **limit order** is an order to buy or sell an asset at a specific price or better. It guarantees the price, but not that the trade will be executed.

Order books are good at these.... because that's all they are. A set of limit orders. If you want to buy or sell **right now**, you have to pick the best limit order in the book and use that as the counter party to your trade. Liquidity pools are really good at this kind of order because of how they keep track of price and handle orders. But if you want to set an order to execute at a certain price in a liquidity pool. Things get a bit trickier.

![](LPPriceDiagram1.svg)

The image above is showing a simplified visualisation of what a LP of SOL-USDC might look like at some price. As you can see, the current price is not where we want to trade. LPs however, don't store discrete orders. They represent a continuous price curve where liquidity exists at all points between ranges, so you can't "wait" for price like in traditional limit order books. Under the hood they keep track of what the current ratio of tokens is (the price) and how it should change as tokens get added or removed but don't keep track of when/if someone wants to buy or sell.

Now that we have established that you can't create limit orders on LPs. Lets go to [Jupiter](https://jup.ag/swap?sell=EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v&buy=So11111111111111111111111111111111111111112) and create limit orders on LPs....

![](Pasted%20image%2020250824121414.png)

Doesn't seem right, does it? It looks like a limit order. Quacks like a limit order. But is it actually a limit order? The short answer is: **"No"**. But that doesn't make for a good article. So let's dig deeper into what is actually happening.

![](JupiterLP.svg)

The first clue is the name, "Trigger". The way limit orders execute on LPs is by constantly watching the price. Once it hits the required level, a transaction is sent to execute the swap. Issue is, this is really inefficient. Imagine yourself in Jupiter's position. Thousands of tokens, each one could have one or hundreds of pools. Thousands of users placing millions of orders on different pools at different prices. And every user expects to have their order filled at the price they requested. That creates immense cost for Jupiter. And the worst part is, fills aren't guaranteed. If your order isn't the fastest or not quick enough you may not buy at the price you requested, or you might only buy a portion of the amount you wanted. Also consider other providers of limit orders. When everyone wants to be the first to get the best price, speed is vital, and more speed = more cost.

*Note: There are on-chain order books and protocols that use order books. But these in turn lose the advantages of LPs*

### The Solution
Make the limit orders part of the liquidity. Simple. Efficient. Ingenious.

FusionAMM does this by allowing users to place limit orders that the pool keeps track of between ticks (definition: The smallest price interval in the pool (represented by coloured square in the diagrams)). This means that in order for price to move past a level, all liquidity and limit orders on that level have to be consumed.

![](FusionAMMdiagram.svg)

And if we flip the whole thing on its side and hide the core liquidity itself....

![](FusionAMMToOrderbook.svg)
By managing orders in this way we get a bunch of benefits:
- Orders are executed faster
- Orders are executed more accurately
- Execution is cheaper (just a small fee for the user)
- No risk of partial fills even though price moved past limit order

This finally gives AMMs the final leg up on traditional order books.

### Advanced Technical Note
By blending LP and limit order mechanics, FusionAMM achieves **real-time, precise execution without external infrastructure**. However, this architectural elegance trades off multi-path routing efficiency. Unlike aggregators like Jupiter—which split large trades across multiple liquidity sources to minimize slippage—FusionAMM executes trades solely through the pool they originate in. That doesn't inherently increase slippage at the limit price, but it means large orders may depend on arbitrageurs to be filled when pool volume is insufficient.

### Conclusion
FusionAMM isn’t about reinventing the wheel—it’s about putting better tires on the one we’ve been using for years. By collapsing liquidity and limit orders into the same pool, execution becomes smoother, cheaper, and far more intuitive for both traders and protocols.

So if you’re still clinging to spaghetti-routing across 12 different venues, paying a premium just to outbid the next bot in line, go ahead—your bags will thank you (eventually). But for the rest of us? The future looks refreshingly obvious.

After all, the best innovations are the ones that make you wonder: _"Why weren’t we doing this the whole time?"_

I encourage you to take a look at the [official FusionAMM website](https://fusionamm.com/?pool=7VuKeevbvbQQcxz6N4SNLmuq6PYy4AcGQRDssoqo4t65) and their [docs](https://docs.fusionamm.com/)

---

## Flash Loans - What TradFi can't

- URL: https://justus.sh/blog/Flash_Loans_-_What_TradFi_can't
- Markdown URL: https://justus.sh/blog/Flash_Loans_-_What_TradFi_can't.md
- Source: https://raw.githubusercontent.com/jstEagle/Personal_Blog/main/posts/Flash%20Loans%20-%20What%20TradFi%20can't.md
- Date: 2025-08-23
- Tags: DeFi, Blockchain, Educational

Imagine having access to **millions** of dollars worth of liquidity for a few seconds. Make any trade. Do *anything* you want. Without having to put down **any** collateral.

That makes no sense right? How could that possibly work? Who would do such a thing? And why is this so exciting for DeFi as a whole?

______
### From the beginning
Loans or the act of lending something for something else is as old as civilisation. The first recorded loans we can trace occurred in ancient Mesopotamia around 4 thousand years ago.

>In early Sumerian and Babylonian city-states, farmers often needed seeds or food to get through until the next harvest. Wealthy landowners or temple authorities would lend them **measured amounts of barley** or silver, recorded on clay tablets in cuneiform. These tablets included the amount borrowed, the due date (often tied to harvest season), and the interest rate—sometimes as high as **20% for silver** and **33% for grain**. - GPT5 (with some double checking on google)

Since then we have begun lending more and more. From mortgages to financing on cars. Even more recently the duration of these loans has gotten shorter and shorter. With services like Klarna or After Pay allowing users to turn almost any transaction into a loan which can then be paid off in small instalments over some time (usually a few weeks).

### DeFi Loans
For blockchain and more specifically, DeFi protocols, loans have been a difficult system to implement. Of course, there are many places where you can take loans. [Kamino](https://app.kamino.finance/lending), [Rain.fi](https://rain.fi/) and more recently [Jupiter](https://jup.ag/lend/borrow) allow you to borrow a variety of tokens or NFTs with one catch. You have to overcollateralize (definition: Overcollateralized means you must deposit more value as collateral than the amount you borrow (e.g., lock 150 USDC to borrow 100 USDC worth of SOL).) your loan.

This makes it ineffective as a means to leverage your current capital. Or in other terms, these loans don't allow you to buy more than you can currently spend. Instead they are used to earn yield generated by the interest on these lending pools or access liquidity without reducing exposure to the underlying asset. i.e. borrowing USDC against SOL to to have USDC to spend while still being exposed to SOL as you will get it back when the USDC loan is repaid.

### What are Flash Loans
Now that we understand what loans are and how general DeFi loans work we can talk about flash loans. 

>A flash loan consists of 2 instructions. Borrow and Repay with interest. When these instructions are packed into the same transaction and all instructions are valid. Then the transaction has the effect of borrowing some amount of capital without depositing any collateral.

Don't worry, I'll now explain the concept in *human* words (and with some pretty pictures).
First, transactions on multipurpose blockchains like Solana or Ethereum aren't just sending tokens from A to B, but are a set of instructions to execute. These instructions have to follow certain rules. Like respecting ownership and authority over accounts (definition: Accounts are the building blocks of Solana. They can represent a lot of different things, but for the most part are out of scope of this article). Instructions are calls to programs with some inputs. For example, to send a token from one wallet to another, a transaction is created with an instruction to invoke the `TransferChecked` instruction provided by the **Token Program** as shown in the picture bellow.

![](Pasted%20image%2020250821190328.png)

Lending protocols like [Marginfi](https://app.marginfi.com/) or [Kamino](https://app.kamino.finance/earn/lend) have on-chain programs that expose instructions like `Borrow` and `Repay` that allow the creation of transactions to start or repay loans. If they allow for it, transactions can be created that contain a `Borrow` instruction followed by some other instructions to trade something or swap something followed by a `Repay` instruction to repay the borrowed amount with interest. If the amount borrowed is available in the pool and the amount repaid is the borrowed amount plus interest then the transaction is executed and a flash loan is performed.

![](TransactionDiagram1.svg)

This works because every transaction is **simulated before being committed** to the chain. The node processing the transaction verifies that the repayment amount is correct and that all instructions are valid. This is called **atomic execution** - either everything succeeds, or nothing happens.

In practice, this means a user—let’s call him Ray—can borrow an amount $X$ and use it freely within a single block, as long as by the end of that block he repays $X + Y$, where $Y$ is the interest. If he fails to do so, the transaction is invalid and nothing changes on-chain. The key point is that **history is only written once a transaction is successfully committed and the block is finalized**.

____

### Why should anyone care?
"Free" money is pretty neat. And while it does make for a *great* present. The charm quickly fades when you only get access to it for less than a second. Funnily enough, traders tend to be less fussy as long as they come out the end a tiny bit richer.

In todays DeFi space, arbitrage trading has become very competitive. Fancy algorithms, thousand-dollar-per-month RPC node subscriptions and incredibly high priority fees (definition: A priority fee is an optional extra fee that a user can include in their transaction to increase their transactions priority. i.e. get their transaction executed faster.). All to make fractions of percentages most of the time. Picking up pennies can be very lucrative if you do it 100 million times over, but its rather tiresome. Instead **flash loans** can be used to increase profits as 0.1% on one million USDC is more than 0.1% on one thousand USDC. Flash loans are also popular with MEV bots (definition: MEV stands for Maximal Extractable Value. These arbitrage bots are often malicious and use high speed and high fees to front-run large trades to make profit.) and almost any kind of bot that operates on very small time-frames and benefits from more liquidity.

They can also be used to leverage assets and have other side effects. A good example of this is Kamino's [multiply](https://app.kamino.finance/multiply). But their [docs](https://docs.kamino.finance/products/multiply) do a way better job of explaining it than I ever could, so I recommend to read about it there.

### My Fascination
In the end, this article is not supposed to be a technical breakdown of how to use flash loans. Or how to implement them. Or even to create awareness about them. Flash loans are one of the few **new** and **cutting edge** concepts and financial tools made available and created through the nature of how blockchains work. Something traditional finance can't do.

Allowing **anyone** to borrow something without collateral, completely trustless, while maintaining security and protecting the lender is something that couldn't have been conceived of before the adoption of blockchain technology.  And that is f\*\*\*\*ing exciting. As this technology progresses, what other uses will be enabled? What new concepts will be discovered?

When math, machines and money melt together; some really interesting things can come of it. And I think we should all be looking forward to what could come next.

---

## Liquidity Pools - The Core of DeFi as we know it

- URL: https://justus.sh/blog/Liquidity_Pools_-_The_Core_of_DeFi_as_we_know_it
- Markdown URL: https://justus.sh/blog/Liquidity_Pools_-_The_Core_of_DeFi_as_we_know_it.md
- Source: https://raw.githubusercontent.com/jstEagle/Personal_Blog/main/posts/Liquidity%20Pools%20-%20The%20Core%20of%20DeFi%20as%20we%20know%20it.md
- Date: 2025-07-27
- Tags: DeFi, Blockchain, Educational

A lot of Decentralized finance (DeFi) protocols or infrastructure can seem very futuristic and most of all **very** complicated. On the one hand this is because they are often a fusion of traditional finance principles along with math and computer science. But on the other hand, it's also easier to get people to invest into your coin when you call it an *"Algorithmic Stablecoin with Seigniorage-Based Elastic Supply"* instead of *"When price go up, we make more coins. When price go down, we destroy more coins."*

This article is meant to build intuition and build up the understanding to help demystify Automatic Market Makers (AMMs) also known as Liquidity Pools (LPs), the building block of DeFi as we know it. To do that we will cover the following:
- [Market Makers](#Market%20Makers)
- [Automatic Market Makers](#Automatic%20Market%20Makers)
- [How do modern AMMs work?](#Modern%20AMMs)
- [Impermanent Loss](#Impermanent%20Loss)
______
### Market Makers
In traditional finance (TradFi) there are 2 main ways in which assets get traded. Over the Counter (OTC) or through an Order Book. OTC orders are pretty self explanatory. Someone makes an offer to either buy or sell and *usually* anyone can accept that offer and provide the other side of the trade.

Order books are where it gets interesting. An order book is just a record of all the limit orders (definition: Limit orders are buy or sell orders set to execute at a specific price or better) that are open. A trader that puts in an order on either side is called a **maker** and a trader that trades against that order is called a **taker**.

![](orderbooksimple.svg)
Above is a simplified example of what a theoretical order book for Solana (SOL) might look like. Note that the *real* price of SOL at this time would be somewhere between 150 and 151. This is because an order book has no indication of what the actual price of SOL is, it only contains a list of orders to execute if the price is at the limit or better (definition: In this context "better" means that for buy side orders, the price is at or lower than the limit. And for sell side orders the price is at or above the limit).

A Market Maker is a trader that places both buy and sell side limit orders within a small range of where the *real* price is. This range is called the spread (definition: Spread is defined as the highest bid price and the lowest ask price in an order book also called the cost of immediate execution). This spread is what makes traditional market making profitable. Any trader who wants to sell SOL spot (definition: A Spot or Market Order is just an instruction to execute a trade for some amount of money at the best price immediately) will lose a small amount of money by not selling at the *real* price due to the spread of the market maker. This is called **slippage**.

![](orderbookhorizontal.svg)
In our simple orderbook example, we can think of the price of SOL as this imaginary line that goes from 0 to $\infty$. And limit orders as buckets of liquidity (definition: Simply put: The amount of buy and sell volume available through limit orders at a time (I will elaborate on this more soon)) placed along the way. As these buckets of liquidity get emptied, takers (the active buyers or sellers) need to move further up and down the line to get their orders filled. Of course in reality market makers constantly replenish their offers to always give takers an offer while maintaining their spread. And so as price moves up and down depending on the supply and demand of either side, so does the order book.

![](orderbookhorizontal2.svg)

______
### Automatic Market Makers
With the rise of DeFi and blockchain technology the first Decentralised Exchanges (DEXs) started to appear. But they had some key issues with their order books:
1. **High gas fees** for orders
2. **Slow execution** due to Ethereum block times
3. **Front-Running risks** because pending orders were visible in the mempool (definition: This isn't important to the article, it just means that pending orders were visible to everyone else)
As a result DEX trading was clunky, expensive, and illiquid.

So in 2018 a breakthrough was made by the [Uniswap](https://app.uniswap.org/) team.

> Instead of matching buyers and sellers, **let traders interact with a pool of assets using a pricing formula**

This is genius because it removes the need for *active* makers to support price, allows anyone to *passively* contribute to an asset pairs liquidity and it was fully on-chain and gas-efficient.

![](constantproductammdiagram.svg)

Above is a visualisation for what a simple **constant product AMM** looks like. Don't worry, it looks *mathy* but it's really not that bad. A **constant product AMM** is simply a pool (definition: Pools are represented on-chain in various different fashions but that isn't relevant to the scope of this article) that keeps one simple rule. The amount of token $X$ multiplied by the amount of token $Y$ is always a constant $K$. This just means that when a swap happens, the amount of the opposite token a user gets out of the swap is determined by this simple rule $X\times Y = K$. This constant $K$ is just a measure of how much liquidity there is in the pool. So as more tokens get added, the amount the price changes by the same amount of tokens swapped changes.

This is why you often hear that you should be aware of tokens with low liquidity. As this means that a trade of 100 tokens for example, will affect a token with low liquidity much more than a token with a lot of liquidity

> *Note: the amount that the price of the tokens changes is only affected by the amount of tokens traded, not by the dollar value. So a trade of 1000 SOL for example might have the same proportional affect as the trade of 1000 USDC if you had two pools with the same liquidity and ratio of tokens*

To understand why you should avoid trading in pools with low liquidity, we need to talk about **slippage**. Slippage refers to the difference between the expected price of a trade and the actual price paid, caused by the trade itself moving the market. In AMMs (automated market makers), prices are determined by a curve — typically based on the constant product formula. When you place a trade, it’s like executing a series of small orders that gradually shift the price along that curve.

For example, if you try to buy 100 SOL at 150 USDC per SOL, you won't get all of them at that price. As your trade progresses, each incremental purchase pushes the price slightly higher, so you’ll end up paying more than 15,000 USDC in total. The **lower the liquidity** in the pool, the **steeper the price curve**, and the **greater the slippage** — meaning large trades get significantly worse execution.

**Higher liquidity dampens this effect**, allowing larger trades to be executed with minimal price impact. That’s why high-liquidity pools are not only more efficient but also safer for larger trades.

Another key difference between this kind of AMM and a traditional order book is that an AMM has **a set value of what the real price is at any ratio of tokens**. However, we also have a problem... how are liquidity providers (the market makers) making their money? Having your money locked up in a liquidity pool can incur both opportunity cost (definition: The theoretical value of the next best investment you give up when making a choice) and impermanent loss (definition: The temporary loss in value an LP experiences when the price of tokens in a liquidity pool diverges from their original price due to market movements. (This will be explained further)). The answer, trading fees. Every trade made through a pool is charged a percentage fee. Usually in equal parts of the two tokens provided in the pool. *Now most pools have very low fees. Usually less than `0.5%`. Some more modern liquidity pool providers also allow for automatic adjusting of fees. So during periods of high volume or high volatility, fees can increase to offset the additional impermanent loss that may be incurred.*

![](Untitled-2025-04-27-1540.svg)

Fees have to be set competitively as there are usually many pools that offer the same pair and platforms like Jupiter will automatically pick the best one for the user.
_____
### Modern AMMs
The original Uniswap model was revolutionary and completely changed the DeFi landscape. But since 2018, some improvements have been made.

> **Note:** When exploring Liquidity pools, we usually refer to the two tokens present in a pool as the base token and the quote token. The base token priced in the quote token. i.e. SOL (base token) is priced at 150 USDC (quote token).

##### DLMMs and CLMMs
These are some terms you might have seen if you frequent Solana DeFi on platforms like [Jupiter](https://jup.ag/), [Meteora](https://www.meteora.ag/), [Orca](https://www.orca.so/) or pretty much any other platform that revolves around trading tokens.

**CLMM** stands for **Concentrated Liquidity Market Maker**. Again, sounds very complicated. But isn't actually. Before, we were thinking about the price of SOL moving up and down an infinite range. CLMMs think of prices the same way. However, instead of depositing liquidity into the entire range, it is deposited into buckets called ticks (definition: A tick is the smallest increment that the price can move in the liquidity pool. This may vary for different pools and providers). Each tick to the left of the price in a pool would be filled with quote tokens and each tick to the right with base tokens.

![](firstlpsimplediagram.svg)

As shown above, the _real price_ corresponds to the active tick—the one that currently holds a mix of both tokens. This helps explain why ticks on either side contain only one type of token. To the right of the active tick, the price is higher, so these ticks hold only base tokens; buyers must deposit quote tokens to purchase base tokens, pushing the price up. Conversely, to the left, the price is lower, and these ticks hold only quote tokens, as selling base tokens for quote pushes the price down.

Providers can decide exactly what range of ticks they would like to deposit their tokens into. This means that you can deposit tokens into only the pools in a certain price interval. While the price is in this range you will earn fees. But once the price has left the range you will not earn anymore fees and your position will be fully converted into base or quote tokens depending on which side of your range the price exits.

**DLMM** stands for **Dynamic Liquidity Market Maker**. It is very similar to **CLMMs** but have some more fancy math and calculations built in to increase efficiency to both reduce fees and increase profits of makers. Below is a simple diagram to try communicate what liquidity might look like in a **DLMM**. The shape of the liquidity may change depending on the characteristics that are desired. If it is a stable pair (definition: A liquidity pool that contains two different stable coins tracking the same thing. i.e. USDC-USDT) or a memecoin pool all affect how the equations controlling the liquidity might be set up.

![](DLMMdiagram.svg)

**DLMMs** may also change how liquidity acts inside ticks. Instead of behaving like a simple constant product AMM inside each tick, DLMMs can use other formulas that better fit the token pair’s nature (e.g. stableswap curves for stablecoins).
_______
### Impermanent Loss
Earlier defined as
> The temporary loss in value an LP experiences when the price of tokens in a liquidity pool diverges from their original price due to market movements.

This is one of the more difficult concepts to understand so don't feel discouraged if you have to read this section a couple of times to fully grasp it.

Let's ease into this explanation with an analogy. Meet **Ray**. He loves trading Solana (SOL). However, Ray has learned that if you don't take profits on the way up, you might not have any profits to take when price comes back down. So here is what Ray does. He invests **100 USDC** into **SOL** when it is at **100 USDC per SOL** and every time **SOL** goes up 10 dollars or **10 USDC** he sells **0.1 SOL**..
![](solchartdiagram.svg)

Here is a table of what that would look like

| Price of SOL | Amount of SOL held | Amount of USDC held |
| ------------ | ------------------ | ------------------- |
| 100          | 1                  | 0                   |
| 110          | 0.9                | 11                  |
| 120          | 0.8                | 23                  |
| 130          | 0.7                | 36                  |


*Note: If Ray had just held 1 SOL, then at 130 his portfolio would be worth 130 USDC. But instead his portfolio is worth $130 \times 0.7 + 36 = 127$ USDC.*

Looking at Rays strategy we can see that he does not make as much profit as he could have made if he had just HODLed his **SOL** until **130 USDC**. Impermanent Loss in liquidity pools works in a similar way. If Ray had deposited **100 USDC** worth of **SOL** into a liquidity pool, then his **SOL** would have been converted into **USDC** incrementally as the price increased. Each tick his position had filled with **SOL** now contains **USDC** meaning that while he might still be in profit, he is not in as much profit as he *could* have been.... and that's just no fun. However, if the price of **SOL** goes back down to **100 USDC** then all those *impermanently* converted tokens get turned back into **SOL** and he has **1 SOL** again. This phenomenon is what we call **Impermanent Loss**.

> "Then why would anyone want to hold their SOL in a liquidity pool?" - Roy (Ray's friend who buys index funds instead of crypto).

Now, while Roy might just be trying to heckle Rays investing strategies, it is a fair question. As mentioned earlier, anyone who deposits tokens to be used as liquidity in these pools gets to share in the fees earned by these pools. A lot of the time, these fees offset the impermanent loss. But they might not. That's the risk.

For more advanced traders a normal and balanced liquidity position would be called "shorting volatility" as the most money is made when the price stays close to the start price of the position while making fees. There are also other cool trading strategies and opportunities that are created by the characteristics of Liquidity Pools but that will have to wait for a different post...
