Proteus: AMM Engine

An explanation of the Proteus design



Off the island of Pharos, an old sea god lives among the waves. He is primordial, more ancient than man, and his power of endless self-transformation is as vast as the ocean. We hope he finds here an appropriate homage.
The Proteus AMM engine is a tool that allows developers to create liquidity pools with custom bonding curves. Like its namesake, Proteus is incredibly flexible, enabling concentrated liquidity with fungible LP tokens.
Proteus is the next step in the evolution of AMMs. It’s simultaneously more capital efficient than Uniswap v3 AND more user-friendly than Uniswap v2. It can offer excellent swap rates with only a fraction of the liquidity of its competitors. How is this possible?
“Then spake Proteus, great Naiad, and seas churned beneath his mutable form.” — Sir Edmund Hale

Capital Efficiency

An AMM, short for automated market maker, is an algorithm that takes your tokens and trades them on your behalf. For it to work, you must first tell the algorithm how much to trade in a given price bucket.
For example, you could tell the AMM to trade 10 ETH when the price ranges from $1,400 to $1,600, and trade another 10 ETH when the price ranges from $1,600 to $2,000. Overall, liquidity will be more concentrated in the $1,400-$1,600 range and less concentrated in the $1,600-$2,000 range.
The more precision you have in setting these price buckets and the more price buckets you have, the better the AMM will be at making trades and the more money it will make for you.
You can think of price buckets as pixels on a television screen. The more pixels you have, the better the image quality. Would you want a clunky TV from 2005, or an ultra-high-resolution 4K TV from the 2020s?
This is where the advantage in capital efficiency of Proteus takes shape, versus Uniswap v3. Proteus has much higher precision, and can support more price buckets than Uni v3.
Consider the DAI+USDC pool on Uniswap. Virtually all of its liquidity is concentrated between 0.9998 and 1.0002. Due to the constraints of the algorithm, it’s hard for LPs (liquidity providers) to do much better than this when using Uniswap. This is because the smallest possible price range for a bucket is 0.0001. Additionally, if you want to add more price buckets, each bucket requires minting a new non-fungible LP token, which is neither cost-effective nor convenient.
Fig. 1: The only viable LP strategy on Uniswap v3 for a DAI+USDC pool is to deposit in the range of 0.9998–1.0002.
When we look at a histogram of the DAI/USDC exchange rate over the past year, it's clear that there is a lot of precision Uniswap v3 isn’t capturing. If you can find a way to match the price buckets to the data, you ought to be able to improve the performance of the AMM.
Fig. 2: Histogram of DAI+USDC price history over most of 2022.
Enter Proteus. Unlike Uniswap, Proteus has practically no limit to its precision (the parameters for our first pool are specified up to the tenth decimal place). Additionally, the entire distribution can be encapsulated in a fungible token, with no need to mint multiple NFTs. The figure below shows the approximate liquidity concentration of the first deployed Proteus pool, DAI+USDC. Notice how it corresponds to the price histogram? This precision unlocks a new level of performance. To put it another way, Proteus lets us trade in 4K, better mapping our price curve to the intricacies of the market.
Fig. 3: Approximate liquidity concentration of the Proteus DAI+USDC pool

User Experience

But, surely this level of trading performance comes at the expense of usability? Surely Proteus pools are only for the most elite financial engineers?
Nope. In addition to being more flexible and precise, Proteus is even more user friendly than Uniswap v2 (never mind v3).
If you want to LP into a Uniswap v2 pool, you must have equal amounts of each reserve token. If you don’t, you’ll have to swap for the correct amounts before you LP. Proteus lets you LP with only one token, or two (they don’t even have to be equal amounts). This is known as single-sided liquidity provision.
If you want to migrate your funds from one Uni v2 pool to another Uni v2 pool, you first need to make a withdrawal. After that, you must swap (possibly twice) to get the correct ratio. Only after all this, two-to-three separate transactions in total, can you LP into the new pool.
With Proteus, migrating LP funds is literally as simple as doing a single swap.
Fig. 4: Providing liquidity with Shell. It’s that simple.
How is Proteus so easy to use? Under the hood, Proteus is built on the Ocean, Shell’s composability layer. Moving tokens across the Ocean is seamless and gas efficient. (Read more about the Ocean and its capabilities here.)

History of Proteus

In 2021, the Shell team unveiled a proof of concept for an “automated market maker engine” that could precisely replicate any bonding curve. Just as a video game graphics engine lets game designers build more powerful video games, Proteus would let financial engineers design more powerful AMMs.
The purpose of Proteus is not to create the most capital efficient AMM per se. The purpose is to build an AMM engine that that can implement any trading strategy. That way, financial engineers can design trading strategies without ever having to write a line of Solidity code. An operating system is an abstraction layer between application developers and a computer’s hardware. Proteus’ AMM engine is an abstraction layer between financial engineers and the Ethereum Virtual Machine.
How is this possible? An AMM’s trading strategy is determined by the shape of its bonding curve. For example, a flat bonding curve has highly concentrated liquidity, while one with high curvature has diffuse liquidity.
Proteus uses a bonding curve algorithm based on multiple curve segments stitched together in a composite function. This allows the algorithm to replicate virtually any curve, any trading strategy. While it may seem complicated, the algorithm is based on mathematics you could teach to a high school student.