Limit Orders, Order Books, and Carbon
Decentralized exchanges (DEXs) based on automated-market makers (AMMs) have evolved beyond the conventional constant product model. AMM protocols have increasingly started to share similarities with order-book based exchanges. Bancor’s new product, Carbon, is an exemplary case. Carbon is an AMM/Order Book hybrid specifically designed for traders. What makes Carbon orders different from traditional limit orders and the Carbon protocol different from traditional order book-based exchanges? Let’s break it down.
What are Limit Orders and what is an Order Book?
An order book is a list of open buy and sell orders, often referred to as limit orders, for a specific pair of assets. In the image below the paired assets are USDT and BTC. Sell orders, also known as asks, are listed on top in red while buy orders, or bids, are listed on bottom in green. The far left column displays the price of BTC in terms of USDT. The second column displays the size of each order in terms of BTC, and the third column displays the total amount of USDT each order equates to.
The top sell order, for example, shows a trader wanting to sell 17.355 BTC at a price of 7500 USDT per BTC, totalling 130,162.50 USDT. Buy orders display the same pieces of information only as bids rather than asks. The top buy order in this example shows a trader is willing to purchase 22.594 BTC at a price of 6700 USDT per BTC, totalling 151,392.09 USDT.
Traditional Limit Orders
Trading “on spot” is at the mercy of volatile changes that may occur before a trade is executed, whereas limit orders give traders the ability to execute trades near-deterministically. Traders can name a precise price, granting them more control and confidence in the execution value. In addition to this added confidence of the exchange value, the owner of the limit order is not subject to the time-sensitive nature of manually executing a trade at a given price target. Rather, they need only have the patience to wait for another trader to take their order at the requested price.
It is important to note that funding for traditional buy/sell orders is required at the time an order is placed. Using the example above, a buyer is required to “lock” 151,392.09 USDT if their bid for 22.594 BTC is to remain open. While seemingly obvious, this observation has implications for AMM hybrid systems, where only bid/ask rates are required, allowing the underlying capital to be dynamic and adjustable.
There is no guarantee an order will be executed; the fulfillment of a limit order is predicated on an active counterparty who is willing to accept the price on offer — effectively closing a “deal” between taker and maker. Understanding the distinction between the quoted “market price” and the one that is likely to be closed at the sale of some quantity of tokens categorically separates the naive, from experienced traders.
Historically, limit orders have lived exclusively in the domain of centralized services, with only piecemeal approximations existing as their blockchain counterparts, with very few exceptions. While not everyone is willing to self-custody, not everyone is willing to deposit their assets on a centralized exchange either. Translating the longstanding utility of an order book exchange into the language of blockchain and DeFi therefore stands to service a readily identifiable demographic of traders, for whom permissionless and decentralized technology is a personal imperative.
Scaling In, Scaling Out
Scaling In and Scaling Out refer to a trading profile where tokens are bought or sold during a trend, and executed over a range of prices rather than specific price targets. Such strategies can be performed by trading on spot in regular intervals, or conversely, by placing a number of premeditated limit orders with varying fractions of an asset to be bought or sold within the confines of the trader’s total budget.
Scaling In generally refers to the act of accumulating at a specific price point, and continuing to accumulate as the price of the target asset trends downwards.
Scaling Out is equivalent to profit taking, and allows a trader to cautiously exit a position, locking in profits at a chosen price point and maximizing returns as the price continues to trend higher.
What is Carbon?
Carbon is an AMM/Order Book hybrid designed to bridge the gap between familiar order book mechanics, and the smart-contract infrastructure developed for DeFi applications. In short, Carbon is a DEX that is specifically designed to support the trading behaviors naturally exhibited by the most engaged demographics; it does not introduce exotic concepts, or ask its target audience to adapt their expectations to the product on offer. Carbon is simply a smart contract realization of an order book with additional features garnered from the AMM paradigms of recent years. The product design culminates in a general perspective of traders’ activities, created with a firm foundation in the agency of individuals — rather than an attempt to describe such a group in aggregate.
At the smart contract-level, Carbon introduces a novel description for concentrated liquidity free from virtual token balances or tick ranges. More importantly, Carbon establishes the concept of a trading strategy as a programmable object consisting of two opposing limit orders with each order trading in only one direction. From these foundational concepts emerge the abstract notion of continuous, asymmetric AMM liquidity.
Carbon is fully decentralized and exclusively on-chain; a distinct advantage to those holding dear the motivating philosophy behind DeFi and blockchain technology.
As evidenced by Uniswap V3 and its clones, conventional AMMs have been attempting a shift towards a more order book-like system for some time, and these iterations bring with them the traits of their constant-product ancestors. For example, requiring use of a single bonding curve (or hypercurve) and balances of two or more tokens to determine an exchange rate, reflects design decisions appropriate in their own time, at the genesis of the AMM era. The symmetry of such systems with respect to the prescribed trading profile could be argued to have served an essential purpose in establishing an exchange primitive in DeFi in lieu of active market makers for the long-tail of cryptographic assets. It could also be argued that it is an unintended consequence of a naive prototype. Regardless, the symmetry of AMM products, including concentrated liquidity AMMs, is an unnecessary obstruction to a truly expressive marketplace.
Adjustable Bonding Curves (ABCs) are the result of a unique invariant function, and the beating heart of the Carbon design. The pricing algorithm of each curve depends on the balance of only a single token, rather than two or more. Each curve executes orders in one direction, irreversibly, and can be updated in a highly gas-efficient manner. Each strategy is comprised of two independent bonding curves, defined by three constants and a single token balance; the strategy overall occupies a total of three slots in memory. Adjustments to these parameters are uncomplicated transactions, allowing for active users to adjust their strategy on the fly without requiring complex interactions with a set of supporting smart contracts, including and especially the issuance of new NFTs.
Whereas traditional limit orders strictly adhere to a quantity of tokens and a specific bid/ask, the most popular trading strategies acknowledge the uncertainty in developing market structures by refusing to accept a single price target. To marry the innate uncertainty of future market valuations with conventional limit order restrictions, traders are ultimately tasked with the creation and subsequent management of a plethora of limit orders over a price execution range that agrees with their ambitions and risk tolerances. The ABCs of Carbon offers a quadratic bid/ask profile with infinite resolution over such a range; effectively, one range order on Carbon can replace dozens of conventional orders on a centralized limit order book. Notably, Carbon does not sacrifice single-price execution. In its own language, Carbon can execute single-price orders by setting the range boundaries equal to each other, thus collapsing the ABC equations on constant price (i.e. infinitely concentrated).
For example, the image below shows a trader-created strategy in which they wish to start accumulating ETH beginning at a rate of 1600 USDC per ETH, and ending at a rate of 1300 USDC per ETH, with a quantity of 10,000 USDC. The entire USDC balance of the order will be traded for ETH, quadratically, throughout the nominated range. Such behavior is generalizable for any range, and can describe the exchange of any token to any token (vide infra).
Carbon also introduces Asymmetric Liquidity, a new form of on-chain liquidity emerging from the inability of an ABC to process trades in both directions. Asymmetric Liquidity refers to the property of Carbon’s AMM, where the bid and ask of a user’s strategy are uniquely defined; conventional AMMs force both to converge to the same number. Therefore, users of Carbon provide liquidity to two distinct ABCs for a single trading pair, whereas conventional AMMs require users to contribute to a single bonding curve governing the execution of a prescribed trading strategy.
Carbon enables recurring strategies, meaning tokens acquired in a buy order become immediately available to trade in a linked sell order and vice versa. So long as these multi-order strategies are not deactivated by their owner, then trading within the user’s ranges automatically rotates liquidity through each of the linked orders.
The example below depicts a strategy comprising two linked range orders. This strategy accumulates ETH at a rate between 1300 and 1100 USDC per ETH, and sells at a rate between 1700 and 1800 USDC per ETH. As each order is engaged by a counterparty trade, the associated liquidity will continuously shift from one ABC to the other. Rather than prefund each individual limit order, one to buy and the other to sell (as is required in traditional limit order systems), Carbon enables a trader to define the strategy independently of the token balances financing each, thus letting the intrinsic self-financing of the strategy evolve over time. This automation replaces the organizational overhead of managing many discrete limit orders, as would be required to execute such a system on a conventional order book. Therefore, Carbon salvages valuable component utility of legacy AMMs, and applies it to an order book-like system to create something new, without sacrificing the hard-won intuition from users in either paradigm.
Now that we have an understanding of limit orders, order books, and Carbon, let’s take a look at Part 2: Popular Trading Strategies Using Carbon.