Adventures in Programmable DEX Trading: Carbon Recurring Strategies

Nate Hindman
CarbonDeFi
5 min readJan 24, 2023

--

Carbon is an automated trading protocol built for on-chain limit orders. Every Carbon order is designed to execute trades at a specific price or within a specific range — “e.g., sell ETH at 1600 USDC”, or “sell ETH between 1600–1900 USDC”.

Users can submit individual orders or combine their orders together to create “recurring strategies” that automatically buy a token low and sell it high. Buy and sell orders can be placed above and below a set price based on where a user expects a given token will trade, automating the process of “swing trading” a token. If the token’s price moves through the user’s selected ranges and their orders are executed, the user profits, having bought the token low and sold it high.

A Carbon recurring strategy that buys ETH in a lower range (1400–1000 USDC) and sells ETH in an upper range (1600–1900 USDC).

Say you expect ETH to trade in the coming months between 1000–1900 USDC. You might use Carbon to deploy a recurring strategy that buys ETH in a lower range (eg, 1400–1000 USDC) and sells ETH in an upper range (eg, 1600–1900 USDC) — so you’re buying the ETH dips, and selling the peaks.

Recurring vs. disposable strategies

Carbon strategies can either be recurring or disposable. A disposable strategy is composed of one active order that removes tokens from active trading as the order is executed. For example, a single limit order (“sell ETH at 1500”) or a single range order (“sell ETH between 1450–1500”).

A recurring strategy, in comparison, is composed of two linked orders that trade in perpetuity. One order auto-buys a token in a lower range, the other auto-sells in an upper range, until the user chooses to stop the strategy. Liquidity automatically rotates between the orders as the token’s price moves into each range.

Funding

A recurring strategy can be funded in three ways: A user can choose between funding the sell order, the buy order, or both. For example, a user could deploy the above ETH/USDC strategy by funding just the buy order with USDC only, and leaving the sell order empty. The USDC would automatically convert to ETH as the ETH price moves through the lower range, and convert back into USDC in the upper range.

Since liquidity rotates between linked orders, tokens acquired in the buy order become automatically available in the linked sell order, and vice versa.

Outcomes

Traders use Carbon to express their expectations of a given token’s price changes. The directional nature of Carbon stands in contrast to existing AMMs, where LPs try to earn trading fees above and beyond the impermanent loss.

Carbon users, on the other hand, are neither motivated by trading fees nor interested in minimizing impermanent loss; rather, they provide liquidity with the sole intention of executing trades at specific prices.

Let’s explore what a favorable and unfavorable outcome would look like in Carbon. The below examples show the profit/loss for the ETH/USDC recurring strategy referenced above — “buy ETH 1400–1000 USDC, and sell ETH 1600–1900 USDC” — with different example ETH price charts.

Favorable Outcome

Summary: ETH range trades between 1,000 and 1,900 twice; +47.35% profit vs. HOLD (after one cycle); +117.14% profit vs. HOLD (after two cycles).

  • User deposits 5,000 USDC
  • ETH price drops from 1,500–1,000 ETH/USDC; ETH buy order executes — 5,000 USDC sold for 4.22 ETH
  • ETH price recovers to 1900 ETH/USDC; ETH sell order executes — 4.22 ETH sold for 7,367.88 USDC
  • Current holdings (profits): 7,367.88 USDC (+2,367.88 USDC)
  • ETH price drops again from 1900 to 1000 ETH/USDC; ETH buy order executed — 7,367.88 USDC sold for 6.22 ETH
  • ETH price rises again to 1900 ETH/USDC; ETH sell order executed — 6.22 ETH sold for 10,857.14 USDC
  • Final holdings (total profit): 10,857.14 USDC (+5,857.14 USDC)

Unfavorable outcome

Summary: ETH drops from 1500 to 900 and never recovers; -23.95% loss vs. HOLD.

  • User deposits 5,000 USDC
  • ETH price drops from 1,500–1,000 ETH/USDC; ETH buy order executed — 5,000 USDC sold for 4.225 ETH
  • ETH price never recovers and settles at 900 USDC
  • User sells their entire ETH deposit — now worth 3,802.50 USDC — and withdraws.
  • Final holdings (total profit): 3,802.50 USDC (-1197.50 USDC)

The examples above show how strategies in Carbon can be profitable or unprofitable depending on the user’s ability to forecast a given token’s price movements. Let’s now take a look at how adjusting the size (or “width”) of each order’s range changes its risk/return profile.

Order Precision

Carbon users are able to define the specific prices at which they buy or sell a given token. The width of an order’s range determines the number of prices where liquidity is offered. An order with a “wide” range offers liquidity across a larger number of prices, while tighter ranges offer liquidity within fewer prices, all the way down to an infinitesimally tight range — where all of the order’s liquidity is concentrated in a single price.

Orders with wide ranges have a lower payoff, but a higher chance of being executed. Orders with tighter ranges have a higher payoff, but a lower chance of being executed. Imagine setting a strategy and deciding where you want to buy ETH — buying it at 1100 would have a higher payoff, but is riskier than buying from 1300 to 1100. This also applies in the reverse direction: selling your ETH at 1900 has a higher payoff but is riskier than selling it from 1600–1900. Buy and sell orders linked together in a recurring strategy have independently adjustable widths, which a trader can use to change the overall risk/return profile of their chosen strategy.

Summary and next time..

By allowing on-chain limit orders to be programmable and linked together via their liquidity, Carbon provides users with greater control, automation and transparency to perform active trading strategies on-chain.

The next post in this series will explore how different Carbon’s on-chain trading strategies can be used to trade various real-world price charts.

Additional Resources

Carbon. A decentralized protocol for asymmetric liquidity and trading.

--

--