Carbon Whitepaper: A High-Level Summary

Nate Hindman
CarbonDeFi
9 min readDec 26, 2022

--

The Carbon Whitepaper was recently published detailing the key proposed features of the Carbon protocol. This post is intended as a high-level overview of the paper, broken down into the following sections:

  • Drawbacks of Existing AMMs as Limit Order Machines
  • Introducing Carbon
  • Parametrically Adjustable Bonding Curves (“Orders”)
  • Linked Orders (“Strategies”)
  • Carbon and MEV
  • Conclusion

Drawbacks of Existing AMMs as Limit Order Machines

The Carbon Whitepaper begins by providing historical context on the evolution of automated market-makers (“AMMs”).

The first generation of AMMs used the “constant product” formula. This technology typically supports the trading of two paired assets across an infinite range of exchange rates. However, most of the time any two assets in the market trade in well-known ranges. Constant-product AMMs therefore accommodate trading at price points that are rarely (if ever) reached under reasonable assumptions. As a result, most of the collateral in constant-product AMMs is employed inefficiently.

AMMs experienced a step-change with the introduction of concentrated liquidity. Instead of forcing users to provide liquidity across an infinite range, users can provide their liquidity to a specific price range. While this gives liquidity providers greater control over how their tokens are used for trading, most LPs today still approach AMMs with the same goal in mind: earn trading fees that are not only sufficient to cover for the Impermanent Loss (“IL”), but also deliver attractive risk-adjusted returns over and beyond covering IL. A growing body of research shows that most LPs in concentrated liquidity AMMs do not break even once IL has been taken into account.

More recently, a new paradigm is emerging in concentrated liquidity AMMs where users no longer provide liquidity solely to earn trading fees, but instead use an AMM to submit “limit orders” to the market. These orders serve a similar purpose to traditional LP positions in that they provide on-chain liquidity, against which other users can perform market orders. But the intent of the LP is notably not to earn trading fees but to execute trades at specific prices/ranges. However, using a conventional concentrated AMM for limit-order utility runs into a number of issues, namely that:

1. Liquidity is self-reversing: Executed limit/range orders are reversed when markets retrace (unless users withdraw liquidity in time).

2. Liquidity is costly to update and automate: It is gas intensive for a user to move their position into a different price range, since the user must withdraw and recreate their entire liquidity position.

3. MEV is rampant: Users who perform market orders against existing AMMs are exposed to “Maximum Extractable Value” (MEV) sandwich attacks.

Introducing Carbon

Carbon is a DEX designed with traders in mind, enabling true on-chain limit and range orders and MEV-resistant spot trading. Its most important features are based on concentrated, parametrically adjustable, asymmetric liquidity.

Concentrated

Similar to existing concentrated AMMs, Carbon allows liquidity to be provided to a specific price range. However, unlike existing concentrated liquidity, Carbon does not rely on predefined “tick ranges” that limit the price points or ranges at which users can place their liquidity. Rather, Carbon’s unique invariant function can be customized to facilitate liquidity provision to any possible price point or range. The invariant can also be customized to achieve a wide range of bonding curve shapes, from constant-product to constant-price, and everything in between.

Parametrically Adjustable

The status quo in concentrated liquidity models is to offer a prescribed set of price buckets, denominated by “ticks”, with which users can contribute capital. To modify the range necessitates a withdrawal from one set of buckets, followed by re-contribution of the capital to another bucket. A Carbon “order” (our term for an individual user’s liquidity position) has no prescribed ranges. Rather, each order is parameterized with an efficient set of three parameters: starting price, ending price and capacity. Users issue transactions that update the parameters of their position without requiring that the capital be withdrawn or moved. This provides users with a more gas-efficient means of managing liquidity and reacting to market changes.

Asymmetric

Contrary to all other AMMs on the market, Carbon’s underlying curves trade in one direction. One curve — or “order” — contains a single token balance that is either used for buying or selling, but never for both. Two curves can then be linked together to combine distinct buy and sell orders (with different pricing algorithms) via a single source of collateral. While other AMMs require a user to provide liquidity to one bonding curve that governs both the buy and sell orders symmetrically according to a single pricing algorithm, a user of Carbon can provide liquidity to two distinct buy and sell curves for a single trading pair, with each curve employing a uniquely defined pricing algorithm, and the two curves jointly forming an asymmetric trading strategy.

Combined, these features give rise to two new on-chain primitives that lie at the core of Carbon:

  1. Order: consists of a single concentrated, parametrically adjustable curve. (Examples: “buy ETH for USDC in the range between 1500 (start) and 1000 (end)”, or “sell ETH for USDC at 2000”)
  2. Strategy: consists of two orders linked together via their collateral. (Examples: “buy ETH for USDC between 1500–1000, and sell it at 2000, repeat until canceled”)

Parametrically Adjustable Bonding Curves (“Orders”)

As discussed, each curve in Carbon corresponds to a user-submitted order and is customizable via an efficient set of parameters that determine the exact price(s) or range(s) at which their tokens are bought or sold. This design offers users a number of advantages to traders in terms of precision as well as gas and operational efficiency:

  1. Users aren’t limited to a predefined set of prices or ranges available in existing concentrated AMMs, and can instead provide liquidity to any single price or range.
  2. Order conditions can be adjusted on the fly without requiring gas-intensive transactions to close and recreate the order.
  3. Curve parameters can be customized to achieve any bonding curve shape, including constant-product and constant-price. Constant-price curves in particular allow users to place liquidity at a specific price point to achieve a true on-chain limit order.

A Carbon curve can viewed in this Desmos chart and in the chart below. In the chart below, an example of a concentrated profile using Carbon’s new adjustable curve appears in green; the blue curve is the constant-product curve, and the straight orange line is the constant-price curve. The Γ value in the Desmos represents the relative concentration parameter, where Γ = 0 indicates infinite concentration (i.e., constant price) and Γ = 1 indicates zero concentration (i.e., constant product). If we change the Γ value on Desmos, we can see how the Carbon curve starts from being identical to the constant-product curve (green) at Γ = 1 to being identical to the constant-price curve (orange) at Γ = 0.

In practice, Carbon curves are customized with three parameters:

  1. The start of the range, indicating the exchange rate at which the first infinitesimal of the provided liquidity can be swapped for the other token in the pair.
  2. The end of the range, indicating the exchange rate at which the last infinitesimal of the provided liquidity can be swapped for the other token in the pair.
  3. The capacity of the curve, which determines how much collateral is needed to move from one end of the range to the other.

A fourth parameter describes the “state” of the curve and corresponds to the amount of tokens currently available for active trading. This is the familiar “token balance” of standard AMMs; however, the marginal price is a function of this balance alone, as opposed to a ratio of reserves for both tokens comprising the pair. As the token balance changes, so does the marginal price. As a Carbon order is filled, acquired tokens automatically appear in a separate “linked order”, which is explained in greater detail below.

Linked Orders (“Strategies”)

Two curves (or “orders”) can be linked together in a single liquidity position (or “strategy”), establishing distinct buy and sell orders that utilize the same pool of collateral. A user can initially fund both orders or fund only one order and leave the other order empty. Strategies are recurring in the sense that tokens acquired in a buy order become available to trade in the linked sell order, and vice versa.

Executing this type of multi-order strategy via existing AMMs would either require two separate liquidity positions or specialist tooling to automate gas-intensive transactions that withdraw and recreate a position as prices move into range. In contrast, on Carbon, two orders can utilize a single source of collateral and automatically rotate liquidity between the two prices (or ranges) as either order comes into range, in an infinite cycle until the user chooses to stop.

An example of one such “buy low, sell high” strategy can be found in this Desmos chart or in the Carbon Simulator.

The side-by-side chart below shows two linked curves that can be interpreted as a buy-low, sell-high strategy, where the active token on the left-hand side is “RSK”, and the active token on the right-hand side is USD. The curves appear on separate charts deliberately, because it is not possible to run both curves on a single shared state (x,y) while observing the asymmetry of the user’s intent.

The “sell RSK” chart on the left sells up to 100 units of RSK, at a range around the average value of 225 USD per 100 RSK, i.e., 2.25 USD/RSK. The “sell USD” chart on the right is much bigger — it contains up to 5,000 units of USD, and it buys RSK at an average price of 5,000 USD per 14,000 RSK, i.e., 0.36 USD/RSK.

Each of the curves describes the sale — and the sale only — of its active asset (by convention the one on the y axis), and selling stops when the curve runs out of tokens at y = 0. The tokens obtained against the sale are immediately moved onto the opposite curve, expanding it if need be. The system never shrinks a curve, save for adjustments made by its owner.

Carbon and MEV

An important issue for on-chain liquidity is Maximal Extractable Value or “MEV” — which results in profits extracted by parties who control the transaction flow, typically miners. A primary MEV attack vector for on-chain liquidity pools is the so-called “sandwich attack”, where a genuine transaction is sandwiched between transactions of the attacker. An AMM sandwich attack is very similar to front-running in traditional markets, except that a sandwich attack is guaranteed to either succeed, or to fail costlessly.

The way it works is as follows:

  1. The attacker identifies a reasonably large trade order, e.g., buying ETH against USDC; this order is a “market order”, i.e., it fixes a USDC amount, and takes whatever amount of ETH it will get.
  2. The attacker inserts a similarly-sized order buying ETH against USDC immediately before the attacked transaction.
  3. The attacker inserts an equal and opposite transaction to (2) immediately after the attacked transaction.

What happens if the above is executed successfully is that the price at which the attacked transaction gets filled is artificially high, due to the slippage introduced by the transaction (2). The transaction (3), which is now selling ETH, benefits from both the slippage introduced by the transaction (2) and that by the attacked transaction. In essence, the attacker shifts the transaction to a higher price point off-market and can pocket that difference in price in a risk-free manner.

This particular attack vector is closed in Carbon. While an attacker can still front-run a transaction as described under (2) above, the reverse transaction (3) is prohibited by the asymmetry of the system. Therefore, the attacker is no longer in a position to retreat from the consequences of their frontrunning trade, which defeats the underlying tenability of the sandwich attack entirely.

Conclusion

Carbon’s concentrated, parametrically adjustable, asymmetric liquidity model gives users an unprecedented level of precision to personalize on-chain trading strategies, while at the same time protecting market orders from MEV sandwich attacks, the most common form of MEV.

In general, Carbon flips the prescribed “short gamma” trading profile of conventional AMMs on its head. Whereas all other AMMs buy a token as its price is dropping and sell it as its price is rising, Carbon AMMs allow users to perform trading strategies that buy low and sell high at specific price or price ranges. This changes the status quo in existing AMMs: On-chain liquidity is no longer reliant exclusively on LPs who frequently suffer losses or poor returns due to IL, but can instead be supported by users taking directional positions via native on-chain limit and range orders.

This post was intended as a high-level summary of the whitepaper. Readers are encouraged to read the entire Carbon Whitepaper.

Additional resources:

--

--