The invention of the Automated Market Makers has been one of the most significant innovations in the history of DeFi. When Uniswap V1 launched, it enabled permissionless, open and decentralised trading on a scale that wasn’t possible before.
That was almost four years ago, V2 followed in 2020, and V3 was released last May. For over two years, most decentralised exchanges used Uniswap’s code or variations of it. Now Trader Joe takes the next step and opens a new page in the book of DeFi.
Trader Joe’s new AMM, powered by the Liquidity Book (LB) algorithm, aims to improve the experience for liquidity providers and traders while staying true to the spirit of DeFi. So what exactly makes it innovative, and how can it benefit all DeFi users?
Concentrated Liquidty
Both Uniswap V2 and Trader Joe use the constant product formula to determine the price of assets in their pools. It is usually written down as x*y=k, where x and y are amounts of assets and k is the constant. It is easy to see that as x increases, y must decrease and vice versa.
This approach provides unlimited liquidity - the pool buys and sells tokens at all prices, including when they approach 0 and infinity. This is very convenient for traders, as they always have a place to sell and buy. However, many coins trade at particular levels most of the time. Therefore, spreading liquidity evenly along all possible prices becomes very capital inefficient.
Concentrated liquidity massively improves liquidity depth at points where it is most needed. Liquidity providers can choose at what prices they are willing to supply their tokens. Let’s say they anticipate that AVAX will trade between 15 and 20 dollars for the next few months. They can opt-in to provide liquidity for AVAX-USDC at this interval instead of at the whole range (i.e., between 0 and ∞).
Better capital efficiency means larger fees for liquidity providers who choose tighter ranges. However, if the price moves outside the bin, the bin becomes “inactive”, and liquidity providers in it stop earning fees. They then can either choose to rebalance - move their tokens to a new bin, or wait for a price to return to its previous value.
Ticks vs Bins
Uniswap V3 implements Concentrated Liquidity by dividing all available price space with ticks. Users can choose any two of those ticks and provide liquidity in the range between them. The smart contract will then track all liquidity available at a current price and use it for swaps.
Liquidity Book, on the other hand, separates the price range into individual bins. Liquidity providers then pick bins they want to deposit into. TraderJoe’s smart contract then uses liquidity from the bin corresponding to the current price.
While this might not seem like a big difference at first glance, there is one crucial distinction. Price can belong to multiple tick ranges but will always be in only one bin. Consider the following example:
With the price of AVAX at $20, it will be both in the $19-$21 and $15-$25 ranges on Uniswap V3.
In Liquidity Book, however, it will correspond to only one specific bin ($19.99 or $20.03 one in this case, assuming the bin step of 0.2%).
The exact implementation is more complicated than that, but you can think of bins as a collection of bundled constant sum pools. Instead of using the x*y=k formula, each bin uses the x+y=k instead. With it, the price isn’t dependent on the pool's composition and is constant throughout the whole bin. Rather, the price changes once the current bin consists exclusively of one of the tokens in pair.
Price Impact
One of the issues with constant product exchanges is price impact. Because the amount of assets in the pool changes during the swap, the quoted price differs from the actual one. That difference is referred to as price impact and is unavoidable, especially with large transactions.
Uniswap V3 and Liquidity Book tackle the problem of price impact a bit differently. They both minimise it thanks to the capital efficiency concentrated liquidity provides. It essentially allows pools to perform as if they had more liquidity than they actually do. More liquidity means less price volatility on each swap. Liquidity Book’s design, however, completely eliminates price impact when trading inside one bin.
Thanks to the Constant Sum formula in the Liquidity Book, price impact only occurs if the price moves from one bin to another during the trade. This means that if the swap utilises liquidity in only one bin, it is performed with zero price impact.
Flexibility
Another important advantage of Liquidity Book over Uniswap V3 is improved fungibility. Because of how ticks in Uniswap are designed, the liquidity positions are represented by ERC-721 NFTs. This complicates integrations with protocols mostly developed to work with ERC-20 tokens. NFTs also make managing liquidity positions difficult, time-consuming and expensive. For example, changing ranges involves multiple complex transactions. Users must withdraw their tokens, define new ticks and re-deposit with gas paid at each step.
Liquidity Book wraps positions into the much more versatile custom contract similar to the ERC-1155 standard. Therefore, LB positions behave like regular fungible ERC-20 tokens, making a wide range of custom strategies readily available.
Users can manage and deploy those strategies themselves or rely on third-party solutions that build on top of the Liquidity Book. The strategies can include:
limit orders - providing liquidity below or above the current price;
custom bonding curves - depositing in multiple bins to mimic a specific distribution;
active liquidity provision - moving liquidity to the current price bin to capture maximum fees;
All these things are available with Uniswap V3 but require more resources due to the non-fungible nature of liquidity.
Impermanent Loss
Impermanent loss (IL) occurs when the price of the pooled assets changes compared to the one they were deposited at. It is referred to as “impermanent”, as if prices return to previous values, the loss will be negated. However, the loss often becomes permanent for many liquidity providers as cryptocurrency markets are extremely volatile, with prices swinging in both directions.
Uniswap V2 and similar exchanges try to compensate liquidity providers for the IL. They often do this by paying LPs a fixed percentage fee from each swap. They can also often run liquidity mining campaigns and distribute native token rewards on top of the fees.
Liquidity Book introduces the concept of the variable fee, which increases along with the volatility of the assets in the pair. The volatility accumulator keeps track of bin changes over a fixed interval. If large swings in prices occur quickly, resulting in liquidity from more and more bins being used, the fee ramps up to help liquidity providers recoup some or all of their losses.
When the frequency of transactions drops, the accumulator will gradually reduce by a prespecified reduction factor until it reaches a new equilibrium. In cases when transactions occur especially rare, the accumulator will reset to a number of bin changes in the current swap. Each bin has its own separate volatility fee, which is capped at a certain amount to prevent it from growing out of proportion.
Summary
With the Liquidity Book, Trader Joe can offer better capital efficiency for liquidity providers than legacy exchanges like Uniswap V2. As a result, it massively reduces the price impact for most traders. It can even offer swaps with zero price impact for assets like stablecoins that are expected to trade inside one bin most of the time.
While it uses the same idea of concentrated liquidity as the Uniswap V3, it offers several significant improvements over it. Namely, it makes managing positions easier thanks to the fungible design of liquidity tokens. It also makes those tokens more composable, positioning them to become a core piece of Avalanche’s DeFi infrastructure.
With the Liquidity Book, users have more control over their assets than ever and can optimise liquidity provisions to meet their goals. Additionally, thanks to the introduction of the volatility accumulator and variable fees, Liquidity Book can alleviate Impermanent Loss in a sustainable manner.
DeFi has certainly come a long way since the introduction of the first AMMs, so it’s time to turn over a new leaf. With the Trader Joe’s Liquidity Book, liquidity provision on Avalanche becomes more capital efficient and flexible than ever before, all while reducing price impact for traders.