a decentralized protocol for asymmetric liquidity and trading
Whitepaper
November 2022 | v1.2
Carbon
a decentralized protocol for asymmetric liquidity and trading
Whitepaper
v1.2
Mark Richardson
mark@bancor.network
Stefan Loesch
stefan@bancor.network
Carbon Protocol
22 Nov 2022 (last updated: 7 Jan 2023)
Abstract
Carbon is a next-generation AMM protocol that introduces a number of innova-
tive design features that greatly increase the possible use cases for this technology
class. The key new feature introduced is that of asymmetric liquidity, where any
given bonding curve only trades in a single direction, effectively being an out-of-
the-money limit order. Two curves can then be linked together into more advanced
trading and market-making strategies. Combined with a sophisticated routing and
arbitrage design, Carbon expands the design space for trading and market making
on-chain. This whitepaper describes Carbon’s key features in detail.
© Copyright Bprotocol Foundation 2022.
carbondefi.xyz/whitepaper
1
Contents
1 Introduction: Carbon and the evolution of AMMs 4
1.1 Concentrated liquidity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.2 Concentrated liquidity as trading facilitation . . . . . . . . . . . . . . . . 5
1.3 Carbon: asymmetric, parametrically adjustable, and concentrated liquidity 6
1.4 Outline of this paper . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2 Parametric concentrated liquidity 8
2.1 Pool invariant curve . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.1.1 Geometry of the invariant curve . . . . . . . . . . . . . . . . . . . 9
2.1.2 Constant-price (Γ = 0) . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.1.3 Constant-product (Γ = 1) . . . . . . . . . . . . . . . . . . . . . . . 11
2.2 Swap and price equations . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.3 Leverage in Carbon . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.3.1 Methods of generating leverage in AMMs . . . . . . . . . . . . . . 13
2.3.2 Carbon leverage . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2.3.3 Leverage, pool prices, and the asymptotic invariant equation . . . 18
3 Asymmetric liquidity 21
3.1 Carbon asymmetric liquidity mechanics (simplified) . . . . . . . . . . . . . 23
3.1.1 Token distribution strategy . . . . . . . . . . . . . . . . . . . . . . 24
3.1.2 Buy-low-sell-high trading strategy . . . . . . . . . . . . . . . . . . 26
3.2 Actual Carbon asymmetric liquidity mechanics . . . . . . . . . . . . . . . 28
3.3 Carbon deployment strategies and the role of fees . . . . . . . . . . . . . . 32
3.4 Carbon and MEV . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
3.5 Outlook . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
4 Adjustable bonding curves 35
5 Matching, routing, and arbitrage 38
2
5.1 Matching and routing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
5.2 Arbitrage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
6 Conclusion 41
A F ormulas 43
A.1 Fundamental model parameters . . . . . . . . . . . . . . . . . . . . . . . . 43
A.2 Invariant curves . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
A.3 Swap and marginal price equations . . . . . . . . . . . . . . . . . . . . . . 46
A.4 Parameters and their relationships . . . . . . . . . . . . . . . . . . . . . . 48
B Implementation formula reference 52
C Resources 54
3
1 Introduction: Carbon and the evolution of AMMs
Automated Market Makers – short “AMMs” – are key components of Decentralized
Finance (“DeFi”) infrastructure. AMMs allow market participants to trade their assets
whenever they want, without the need to find another willing counterparty in the market,
and without having to resort to centralized infrastructure.
Bancor and all other early AMMs used theconstant-product technology. This technology
is extremely elegant because it has no view on where the exchange rate of the two
assets it trades should be – it works equally well everywhere. This advantage is also its
greatest disadvantage, because in reality, constant-product AMMs work equally badly
everywhere. The reason for this is that most of the time, any two assets in the market
trade in well-known ranges. There may be periods of heightened volatility, but for
reasonable time frames the maximum price changes of 10x, or possibly 100x are a far cry
away from the complete scale invariance exhibited by constant-product AMMs which are
designed to work equally well on ranges of the 1000x, 10000x or more. In other words –
a lot of the collateral in constant-product AMMs is supporting trading at price points
that will not be reached under any reasonable assumptions. This collateral is therefore
employed extremely inefficiently and should be removed from the AMM.
1.1 Concentrated liquidity
The area where this problem was most pertinent was for like-kind assets, ie assets that are
expected to trade at a constant (typically unity) price point. The best-known example
for such like-kind assets are two stable coins that refer to the same underlying asset, for
example USDC and USDT. Those are expected to trade in a very narrow range around
unity, and any collateral that sits meaningfully away from unity will never be used. Also,
if ever it is used this is probably a meltdown of one of the coins, and the AMM would
have been better off halting the trading in this case to limit its losses. The desire to
trade like-kind assets efficiently on AMMs led to the design of the so-called stable-swap
invariant curves, where the large majority of the liquidity is deployed around unity. The
4
purest example here is the constant-sum (or slightly more general, constant-price) curve
where the entire liquidity is located at one specific price. The AMM then simply stops
trading at either side of this price. In practice, stable-swap curves do accommodate
a certain price range – a few percent – with the large majority of their liquidity, and
they often also allocate a very small amount of liquidity to the wings so that they can
continue trading (and continue to be useful for price discovery) without wasting much
collateral.
Concentrated liquidity experienced a step-change with the introduction of Uniswap v3 in
2021: whilst stable-swap curves are designed to operate around a specific price point, the
new model offers a multitude of concentrated trading curves, each associated with a spe-
cific trading interval, the entirety of which segments the price axis into non-overlapping
and fully-exhaustive segments. A liquidity provider effectively invests in one, or mul-
tiple, of those stable swap curves. This however is a difficult choice, because only the
segment corresponding to the current price point earns fees, so all collateral on the other
segment is wasted. Also, liquidity cannot simply be moved: it must be withdrawn and
re-staked, which can be a cumbersome and gas-intensive process.
1.2 Concentrated liquidity as trading facilitation
One interesting thing that started happening on Uniswap v3 was that people deliberately
placed collateral far away from the money – not necessarily for liquidity provision, but
rather with the intent of buying assets on a dip, or selling them after a rally. The
traditional paradigm of AMMs was that liquidity providers were there to earn fees on
their collateral, and that those fees are sufficient to not only cover for the so-called
Impermanent Loss (“IL”), but also deliver attractive risk-adjusted returns over and
beyond covering IL. We have shown previously that apparently this is not the case, and
that the large majority of liquidity providers do not even break even once IL has been
taken into account (see LHRW2021).
This traditional paradigm of AMMs is partially replaced by a trading paradigm, where
5
“liquidity providers” no longer provide liquidity but instead use an AMM to submit
limit orders to the market. However, using a traditional concentrated liquidity AMM
for conditional trading runs into a number of issues. The first of those we already
have alluded to above: when views change and positions are to be moved, that can be
cumbersome and expensive, because a hefty cost is incurred every time a change is made
rather than only when trading happens. More important however is the second issue:
traditional AMMs provide symmetric liquidity, meaning one curve governs trading in
both directions. So a liquidity provider may have placed an order to buy ETH on the
downside, and may even have spent a lot on gas moving it around when expectations
changed. Then the order is finally executed – but before the user, who may not be able
to monitor it 24/7, has canceled it, markets may have moved back, and the position has
traded back.
1.3 Carbon: asymmetric, parametrically adjustable, and concentrated
liquidity
Carbon is a DEX designed with traders in mind, and its most important features are
based on asymmetric, parametrically adjustable , and concentrated liquidity .
We take those terms one by one. Concentrated liquidity has already been discussed
above, and Carbon is not different from other AMMs, except that it can be used to
create a wide range of bonding curves, from constant-product to constant-price, and
everything in between. This is not fundamentally new, but it is covering the whole
gamut of what is currently available in this space. Parametrically adjustable liquidity
relates to what has been discussed above: rather than putting liquidity at a fixed place
and having to redeem and re-stake it whenever change is desired, a Carbon “order” (our
term for an individual user’s liquidity position) is parameterized with an efficient set of
parameters, and can be moved around quickly and cheaply simply by issuing transactions
that update parameters.
The most important innovation in Carbon, however, is the asymmetric liquidity paradigm:
contrary to all other AMMs on the market, Carbon’s underlying curves trade in a single
6
direction: one curve – or “order” – is either used for buying or for selling, but never for
both. This is a very important point that we want to drive home: Carbon can essen-
tially do everything other major AMMs can do, notably effectively-symmetric liquidity
provision either across the whole curve, or within a range of any size, or even concen-
trated in a single point. But the main strengths of Carbon lie elsewhere, because it is
fundamentally designed to support trading and market-making strategies composed of
independent and irreversible buy and sell patterns.
Carbon offers two new primitives, and a number of others that are still under research.
The first and most fundamental primitive is that of an order that consists of a single
parametrically adjustable, concentrated, and asymmetric curve. Examples of orders are
“buy ETH for USDC in the range between 1500 (start) and 1000 (end)” or “sell ETH
for USDC at 2000” . The second primitive is that of a strategy, which consists of
multiple, currently at most two, orders that can be linked together via their collateral.
An example of a strategy would be the combination of the two orders above, leading to
“buy ETH for USDC between 1500-1000, and sell it at 2000; repeat until canceled” .
1.4 Outline of this paper
In the remainder of this paper we will go through Carbon’s feature set in more detail. We
will start with Carbon’s parametric liquidity, defining the set of hyperbolic curves we are
using. We then discuss our main innovation, asymmetric liquidity, how we implement
it in the case of a strategy composed of two linked curves, and some of its interesting
properties, eg MEV resistance. Finally, we discuss how to adjust curves in a manner
that does not require closing and recreating a liquidity position, thereby reducing the
cost of active management.
Before we conclude we also briefly touch on an important issue that arises in the context
of Carbon, which is how to optimally match trades to orders (what we refer to as
matching and routing), and how to implement arbitrage strategies either within Carbon,
or between Carbon and other systems. Those topics, however, are important enough
7
to warrant their own publication and will be discussed in more detail in forthcoming
publications.
2 Parametric concentrated liquidity
In this section, we discuss Carbon’s first big innovation – parametric concentrated
liquidity based on a set of recently and purposefully engineered invariant curves.
2.1 Pool invariant curve
Our generic pool invariant curve is
(desmos)
y = P0x0 (x (Γ− 1)−x0 (Γ− 2))Γx−x0 (Γ− 1) (2.1)
Before we go further, we need to define the variables. As usual, x,y describe the state of
the pool, with x to be interpreted as the amount of risk asset, and y as the numeraire.
The variablesP0,x0 and Γ are parameters whose meaning we will discuss further below.
The equation is of the form y = f(x), and it is not immediately obvious that it is
symmetric vis-a-vis exchanging the risk asset and the numeraire. We assert that it is,
and we are here giving the reverse invariant function which reads as follows
x = y0 (y (Γ− 1)−y0 (Γ− 2))P0 (Γy−y0 (Γ− 1)) (2.2)
Note that we usedy0 instead ofx0, reflecting our change of numeraire. We did not change
P0 however. Had we used the inverse price ¯P0 = 1/P0 instead, then the functional form
would have exactly been the same. In other words – all the equations we show in this
document hold when we replace x,x 0, ∆x withy,y 0, ∆y, respectively, and we replaceP0
with ¯P0 = 1/P0.
8
Figure 1: The new invariant curve
Also, because we will use it below, and because it is a very elegant form of describing
the invariant curve, we want to introduce here another variant of that curve that is
parameterized with the x and y intercepts xint,y int and the parameter Q = (1− Γ)2.
Please see the appendix for a more thorough discussion and other relevant formulas.
Q = xy(x−xint) (y−yint) (2.3)
2.1.1 Geometry of the invariant curve
Whilst it is not immediately obvious when looking at the new invariant curve (the red
curve in the figure “The new invariant curve”), its construction process has been very
geometric. Fundamentally, it is still the same x·y = k hyperbola first introduced by
Bancor and ultimately popularized by Uniswap. However, it has been translated in the
x,y plane and has also been scaled. This yields 3 free parameters, 2 for the translation
and 1 for the scale.
We have plotted the invariant curve in the chart “The new invariant curve”, and we
have also prepared an interactive version on Desmos that we invite the reader to play
with. In the chart, the red curve is the curve for a specific value of Γ (about 0.5 in
this case). The blue curve is the constant-product curve, and the straight blue line is
the constant-price curve. The point where they all meet (also indicated by the green
9
lines) is x0,y 0, and the slope (aka price) at this point is P0. The red curve is stretched
around the fixed point x0,y 0, keeping the slope fixed, and it no longer has the axis’ as
asymptotes, but the dashed purple lines instead. If we change the Γ value on Desmos,
we can see how the curve starts from being identical to the constant-product curve at
Γ = 1 to being identical to the constant-price curve at Γ = 0.
(desmos)
We have just seen that the new curve covers the constant-product and constant-price
cases, depending on the parameter Γ, and we want to discuss this in more detail here.
2.1.2 Constant-price ( Γ = 0)
First, we set Γ = 0. In this case, the pool invariant curve simplifies dramatically to
y =P0 (−x + 2x0) (2.4)
We see that this invariant function is of the constant-price form x +Py =k. This also
shows that the parameter P0 can indeed be interpreted as a price, at least for Γ = 0
where it is the constant price of the AMM. We also note that the expression x +Py is
the total value of the liquidity pool, expressed in units of the risk asset. This allows us
to interpret the term x0 as the invariant size parameter of the pool (expressed in terms
of the numeraire), because for y = 0 we find x = 2x0. In other words – x0 is half the
invariant pool size, expressed in terms of the numeraire.
2.1.3 Constant-product ( Γ = 1)
We now set Γ = 1. Again, the equation simplifies dramatically, and we obtain
y = P0x20
x
(2.5)
This is the constant-product invariant xy = k where k = P0x20. If we remember the
10
parameter y0 we previously introduced, then we can rewrite this as k = x0y0. So, for
Γ = 1, the parameters x0,y 0 are the respective pool holdings of the risk asset and the
numeraire, at an arbitrarily chosen reference point, and P0 is the price at this point. So,
again, P0 is a price-related parameter, and x0, y0 and√x0y0 are all possible pool-size-
related parameters.
2.2 Swap and price equations
From the pool invariant curve, we obtain the swap equation, ie the equation that de-
scribes what happens if we want to swap a quantity ∆x of the risk asset into a quantity
∆y of the numeraire, or vice versa. In other words, ∆ y is obtained as the difference of
the right-hand side of the invariant curve when evaluated at x andx + ∆x, respectively.
What we get in this case is the following equation
−∆y = P0∆xx20
(Γ (x−x0) +x0) (Γ (∆x +x−x0) +x0) (2.6)
or, equivalently, after slight refactoring
−∆y = P0∆xx20
(Γx−x0 (Γ− 1)) (Γ (∆x +x)−x0 (Γ− 1)) (2.7)
Note the minus sign on the left-hand side, which indicates that when the AMM receives
the numeraire, it returns the risk asset and vice versa. Therefore ∆ x and ∆y always
have the opposite sign.
The above equation can look somewhat daunting, but it is important to understand
that, seen as a function f : ∆x→ ∆y/∆x, the structure is simple. Its general form is
−∆y∆x = a1 +b∆x (2.8)
which importantly only depends on two parameters, a and b. This suggests that our
11
curve space is somewhat over-parameterized, and that there are many different ways of
achieving equivalent swap curves. This of course is not new: invariant curves generally
contain too much information. For example,
√
k =√xy is equivalent to k =xy and so
is almost any f(k) =f(xy) for that matter.
Also, for the eagle-eyed, we need to point out that the ( a,b ) parametrization above
breaks down for Γ = 1 in which case we could use a∆x/b + ∆x. This in turn breaks
down for Γ = 0. This is the well-known problem of parameterizing a mathematical
manifold – we may need more than one map. We could introduce 3 variables, but this
would obfuscate the fact that the function space is of dimension 2.
We now look again at what happens for the special values of Γ, and we first look at
Γ = 0:
−∆y =P0∆x (2.9)
This is a constant-price swap equation where the exchange between risk asset and nu-
meraire always happens at a price P0. When we look at Γ = 1 we find the well-known
swap equation for the constant-product case:
−∆y = P0∆xx20
x (∆x +x) (2.10)
The swap equation relates macroscopic transactions ∆ x, ∆y to their effective price
Pef f =−∆y/∆x. From this, we can move to the infinitesimal transaction dx,dy by
going to the limit ∆ x → 0. The effective price then becomes the marginal price
Pmarg =−dy/dx. This marginal price can also be obtained from the invariant curve
above via derivation, so the term −dy/dx can be rightfully interpreted as a derivative.
(desmos)
12
Pmarg = P0x20
(Γ (x−x0) +x0)2 (2.11)
2.3 Leverage in Carbon
2.3.1 Methods of generating leverage in AMMs
The main purpose of Carbon’s concentrated parametric liquidity is just that – concen-
tration, aka leverage. Before we go into details on how Carbon creates concentrated
liquidity, we remind ourselves how AMMs usually do that. In fact, there are two funda-
mental models:
1. Along the lines of Bancor v2 (but not v2.1) and Uniswap v3, by running the AMM
on a virtual token supply, thereby creating bona fide leverage
2. Along the lines of Curve and others, by modifying the actual invariant curve
Carbon effectively uses a mix of both, so we will discuss the two methods in turn. Start-
ing with the first option, what is a “virtual token supply”? We as프로젝트로 돌아가기