Part 2 — Next Form: Carbon — Expressive On-Chain Trading Strategies
This is the second installment in a two part series exploring the evolution of Decentralized Exchanges. The first part covers the mechanics of constant product and concentrated liquidity Decentralized Exchanges. The second part focuses on Carbon and the innovation it provides to this changing landscape.
Introduction
Recently announced, Carbon is a decentralized exchange that can be considered an evolution of previous AMMs. Its purpose is to let traders be able to express their trading strategies via three core features:
- Asymmetric Liquidity: individual user strategies are composed of independent buy and sell orders, each of which trade in a single direction and are therefore irreversible on execution.
- Recurring Strategies: multi-order strategies automatically rotate liquidity between linked orders as they are fulfilled, automating and reducing the cost of manually creating orders.
- Adjustable Bonding Curves: order conditions can be pre-defined using specific concentrated ranges and updated on the fly without closing and recreating the order.
These features are in addition to what is typically available on limit orders in centralized exchange venues. Carbon can be considered a more advanced on-chain orderbook with certain qualities of AMMs.
Asymmetric liquidity
In part one of the series, we covered the symmetrical liquidity profile of CPAMM (constant product automated market making) but also that of Uniswap V3 (one can think of a token pair in Uniswap V3 as being composed of many small Uniswap V2 bonding curves with the boundaries terminating on the X and Y axis respectively). To put it succinctly, symmetrical liquidity means that I can swap token A → B
and token B → A
to go back to the original starting position on the bonding curve and therefore exchange rate. The trades that are made via a symmetrical AMM can therefore be reversed and return the liquidity pool to its initial token quantities and exchange rates.
We can visualize this in the example provided where RSK
was swapped for USDC
(Step 1 and Step 2) and in Step 3 USDC
was swapped for RSK
to return us to the original starting point on the bonding curve. This is possible due to both tokens sharing the same exchange rate.
In an Asymmetrical liquidity profile, we have two bonding curves, with each respectively governing how token A
can be swapped for Token B
and how token B
can be swapped for token A
. These two bonding curves don’t overlap and therefore each one has a different exchange rate dictated by the parameters of the bonding curve and configured by the LP.
This diagram is a representation of a strategy for the RSK-USDC
token pair:
Each token has its reserves on the Y-axis
and unlike the symmetrical model, our X-axis
holds no token reserves. If we assume that our RSK
bonding curve (on the left) is actively being traded, then as RSK
is swapped for USDC
, the reserves on the separate USDC
bonding curve (on the right) are being replenished. Similarly, the opposite case is also true, if the USDC
bonding curve is actively being traded then as USDC
is being swapped for RSK
, the reserves on the separate RSK
bonding curve are being replenished.
Such a strategy has the following starting profile:
Strategy 1, at T0:
Order 1: 100 RSK
Sell Range 1: 1.25–1.50 USDC/RSK
Order 2: 75 USDC
Sell Range 2: 1.00–0.75 USDC/RSK
Assume that the current price of RSK
is 1.10 USDC/RSK
and the price rises above 1.50 USDC/RSK
. Order 1 would then be completely filled and we would acquire ~136.93 USDC
. When this happens, Order 1 is depleted and Order 2 has an additional ~136.93 USDC
in funding:
Strategy 1, at T1:
Order 1: 0 RSK
Order 2: 211.9306394
At some point in the future, Order 2
gets filled when the price of RSK
drops to below 0.75 USDC/RSK
. When this happens, we acquire ~244.72 RSK
if the entire quantity of 211.93 USDC
was sold.
Strategy 1, at T2
Order 1: 244.7164234 RSK
Order 2: 0 USDC
While our example above shows orders being completely fulfilled, in reality this might not always be true. If, for example, we are selling 100 RSK
for ~136.93 USDC
as in Order 1
at T0
and about half the order gets filled (~68.47 USDC
is acquired) due to the price rising to ~1.372 USDC/RSK
then this means that Order 2
has only an additional ~68.47 USDC
for a total of ~143.47 USDC
.
A keen reader might have noticed that even though the price of RSK
has gone up to ~1.372 USDC/RSK
(very close to the median 1.375 USDC/RSK
of our 1.25–1.50 USDC/RSK
range) that we have already sold more than half (52.28
) of our RSK
tokens. This currently leaves us with 47.72 RSK
remaining in our RSK
order. What this shows is that each unit of the token which is being sold is getting more expensive as it is depleted. This should be intuitive as the token is getting scarcer.
It is important to highlight that once tokens are sold, if the price retraces in the opposite direction, you are not back where you started. As shown in the diagram below, if the price of RSK
is currently at 1.37 USDC/RSK
and it retreats to 1.10 USDC/RSK
the 68.47 USDC
acquired won’t be converted back to 52.28 RSK
.
Recurring Strategies
We covered asymmetrical liquidity and while describing this feature covered the idea of the reserves in an order being replenished as its linked order is completely or partially filled. This idea of rotating liquidity is what powers recurring strategies and leads to automated on-chain trading.
To demonstrate this feature, we can start with the previous initial example when the current price of RSK
is 1.10 USDC/RSK
Strategy 1, at T0:
Order 1: 100 RSK
Sell Range 1: 1.25–1.50 USDC/RSK
Order 2: 75 USDC
Sell Range 2: 1.00–0.75 USDC/RSK
At time T1
the current price of RSK
is 1.60 USDC/RSK
which results in a balance of ~211.93 USDC
for Order 2
:
Strategy 1, at T1:
Order 1: 0 RSK
Sell Range 1: 1.25–1.50 USDC/RSK
Order 2: 211.9306394 USDC
Sell Range 2: 1.00–0.75 USDC/RSK
If the price were to retrace at time T2
to 0.70 USDC/RSK
then we would end up with ~244.72 RSK
tokens.
Strategy 1, at T2:
Order 1: 244.7164234 RSK
Sell Range 1: 1.25–1.50 USDC/RSK
Order 2: 0 USDC
Sell Range 2: 1.00–0.75 USDC/RSK
On the next cycle, if the market price of RSK
increases to 1.60 USDC/RSK
then our USDC
order would now contain ~335.09 USDC
! Our initial strategy contained 100 RSK
and 75 USDC
, and after three complete iterations of buying/selling (sell RSK
for USDC
, buy RSK
with USDC
, sell RSK
for USDC
) we are up 260.09 USDC
(starting point was 75 USDC
).
We can start to see some of the advantages that rotating liquidity provides as it allows token reserves to automatically be replenished as orders are fulfilled. For certain market conditions such a feature might prove to be quite useful.
One example would be “like-kind” assets that are paired with a base asset to maintain their peg. These pairs typically trade in tight ranges and occasionally the like-kind asset might trade below or above the price of the base asset it is paired with. Other such examples include markets that tend to trade sideways or within what traders believe to be predictable ranges. If a trader believes ETH
will range trade between 1400–1700 USDC/ETH
in the next few months, a user could set buy orders by depositing USDC
that continuously buys ETH
when ETH
is trading 1500–1400 USDC/ETH
and then sells the ETH
between 1600–1700 USDC/ETH
. Traders inherently take a directional view on the market of where they think a given asset will trade. These are some use-cases but there are many others depending on the trading strategy that a trader is looking to implement.
Adjustable Bonding Curves
The last core feature of Carbon which we will cover is dubbed ABCs (Adjustable Bonding Curves). The novel invariant function behind Carbon strategies (and therefore orders) is implemented with adjustable parameters that allow each trader to create their own individual bonding curves per order. When creating an order in Carbon, a trader can provision liquidity across the entire price curve, within a range, or concentrated in a single point.
The generic pool invariant curve (shown in the chart below) is capable of supporting all three options with the derivation details being highlighted in the Carbon whitepaper. Additionally, this is also made available in Desmos which allows the reader to adjust certain curve parameters to see some of these results.
In practice, when you are setting up a strategy and its orders, a lot of the complexity is abstracted away. As a trader, the information required is the trading pair, funding amount, and rate. What you end up creating for an order looks like the following when setting up a fixed range:
Strategy 1 Order 1:
Funding amount: 100 RSK
Rate: 1.25–1.50 USDC/RSK
Note that the range example above shows us denominating this order in USDC/RSK
for ease of readability. When implementing this order in Carbon, it is denominated in RSK/USDC
. Its linked partner order in this strategy which contains the acquired USDC
on the other hand is denominated in USDC/RSK
. The rule of thumb is that the token that is being funded for an order is the numeraire and how you express the sell range.
Alternatively, you can also express concentrated liquidity at a single point by setting the upper and lower boundaries of the rate to the same amounts:
Strategy 1 Order 1:
Funding amount: 100 RSK
Rate: 1.25–1.25 USDC/RSK
Some differences between Carbon and other AMMs when it comes to funding a strategy is that you are not required to provide both assets in a pair. For example, for the RSK/USDC
trading pair a trader can create their strategy with RSK
only, USDC
only, or both. Possible combinations are the following:
+------------+------------+
| RSK Order | USDC Order |
+------------+------------+
| Funded | No Funding |
| No Funding | Funded |
| Funded | Funded |
| No Funding | No Funding |
+------------+------------+
As previously discussed, as one order is fulfilled the liquidity rotates to the linked order. This means that you can start with a single asset and later on have two orders in a strategy funded if one order partially fills.
A possible option in Carbon is to have a strategy without any funding for either order. This might prove beneficial for any advanced traders that want to have a strategy pre-created and readily available. All that is needed is for funding to be added to the order for it to be made available for trading.
Updating the parameters of a Carbon strategy (funding and rates) can be done easily with minimal cost. This is possible as each strategy is its own unique “pool” for all intents and purposes and a trader updating their strategy does not affect other strategies for that same trading pair. In addition,when updating order parameters (rates) a trader is not required to remove the underlying funding; rather, parameters can be updated “on the fly” without needing to close or recreate your position.
One other important distinction about Carbon is that unlike other concentrated liquidity solutions which require you to fit your liquidity (or order) within a tick(s) (defined by an upper and lower price point), Carbon orders don’t have this limitation and are only limited in resolution (1e-18 in Ethereum) by the blockchain system. This lets traders create orders with boundaries at any price point of their choosing.
Conclusion
We have now covered the main features in Carbon and the differences between the most common concentrated liquidity solutions. We find that Carbon in general is more flexible due to its expressive nature. This lets traders utilize Carbon as a normal limit order system and take advantage of key features not seen anywhere else.
Additional Resources
- Visit us on carbondefi.xyz
- Read the litepaper, whitepaper, and patent filing
- View and simulate strategies using the Carbon simulator, Binder, and Python module.
- Follow Carbon on Twitter
- Subscribe to the Carbon Medium
- Join the Carbon community on Discord
- Participate in Carbon Governance
Carbon. A decentralized protocol for asymmetric liquidity and trading.