Blog

Trader Joe ( @TraderJoe_xyz ) vs UniswapV3 ( @Uniswap ) and the slippage problem

After having audited both protocols, it's time to dissect the most important difference between both:
UniV3: Concentrated Liquidity and Ranges

In UniV3, liquidity providers (LPs) can allocate their funds within specific price ranges. This model allows for what's known as "concentrated liquidity." Here, LPs have the flexibility to target their liquidity provision to the price levels they expect to be most active, enhancing capital efficiency.

The flip side, is that each price range operates akin to a mini Uniswap V2 pool, leading to potential slippage within that range during a swap.

This slippage occurs because, within a given range, the price can shift due to the trade's impact on the supply and demand dynamics of the tokens involved.

Larger trades may span multiple ranges, impacting the price incrementally as they consume liquidity from one range to the next. But inherently a swap is always executed on the active range and within each range, slippage will be present, similarly as we know it from UniswapV2.


Trader Joe: Liquidity Bins

Trader Joe introduces a unique take on concentrated liquidity by organizing liquidity into discrete bins rather than continuous ranges.
Each bin represents a specific price point, and LPs can choose to provide liquidity directly to these bins. This approach simplifies the process for LPs, as they don't have to select a price range but instead choose specific price points to support. Investors can therefore provide liquidity only to one single bin or multiple bins.

The critical advantage here is the reduction in slippage for swaps.
When a swap is executed, it can fully consume the liquidity available at a particular bin's price, ensuring the swapper gets a consistent price for as much of the swap as that bin can support.
If the swap size exceeds the liquidity in one bin, it moves to the next available bin, continuing until the swap amount is fulfilled. This sequential consumption of liquidity bins ensures that slippage is minimized, as each portion of the swap is executed at a known and fixed price.


As you can see, the getAmounts function uses the current activeId for the amount calculation, which is simply the current price of the bin.

The difference in approaches between UniV3 and Trader Joe fundamentally impacts swaps:
The method build by Trader Joe can offer more predictable pricing, especially beneficial for large swaps that might otherwise experience significant slippage in a range-based system like UniV3's.

Both systems represent innovative attempts to solve the liquidity and efficiency challenges inherent in decentralized trading platforms. The choice between them will depend on the specific needs and strategies of both liquidity providers and those looking to swap assets.