Introducing Capy Trading Bot

Introducing Capy Trading Bot

Today, we are sharing the Capy Trading Bot to both showcase how programmable transaction blocks can power DeFi on Sui and to provide an open-sourced tool for the community to use when building trading agents on Sui.

The accompanying Capybot Monitor is a collection of Python scripts to monitor the status of a running instance of a Capy Trading Bot. It produces price charts and key status indicators used by the Capy Trading Bot.

This blog provides an overview of simple DeFi bots in Typescript, designed to identify arbitrage opportunities in different Sui DEXs and/or perform trading activities based on script-logic strategies. We're providing these resources only as a reference for developers to consider when implementing their own custom strategies, and nothing here is investment advice or trading recommendations.


  • Implements a basic Strategy interface (developers can use the Strategy to implement their own custom strategies)
  • Provides three basic trading strategies as reference implementations (described below)
  • Automatically executes trades when it finds profitable opportunities
  • Supports multiple cryptocurrencies and trading pairs; currently supporting trading on three Sui DEXs
  • Supports receiving data from multiple sources, including swap pools and external sources like Binance. Currently, the bot utilizes feeds from CCTX (CryptoCurrency eXchange Trading Library) to get the latest prices from Binance. Note that CCTX supports Binance, Bitget, Coinbase, Kraken, KuCoin, and OKX.


In Capy Trading Bot, strategies subscribe to relevant data sources and create trade orders based on the information they get. Every second, Capy Trading Bot requests new data points from each data source. When it receives a new data point, Capy Trading Bot sends it to subscribing strategies which return trade orders to Capy Trading Bot. Capy Trading Bot submits transactions to the relevant swap pools modules to execute these trade orders. If a strategy returns multiple trade orders, Capy Trading Bot submits them as a single transaction.

Data Sources

Capy Trading Bot can leverage two different types of data sources: Swap pools and external sources. Capy Trading Bot can execute trades via swap pools, and swap pools provide the current token price in the pool. External data sources can provide additional data that could be useful inputs to trading strategies.

In this release, Capy Trading Bot supports swap pools from Cetus, Turbos, and Suiswap, and uses Binance (via CCTX) as an external data source for the relative prices of some token pairs.


Capy Trading Bot supports the following three trading execution strategies:

  • Arbitrage: This strategy looks for arbitrage opportunities in chains of two or more swap pools across different DEXs. It computes the product of the prices along the chain of swap pools, say SUI -> USDC -> CETUS -> SUI, and if the product is different from, it means an arbitrage opportunity exists.
  • Ride The Trend: This strategy looks for trend following opportunities in a single swap pool by comparing a short moving average with a longer moving average to get an indication whether the price of a given asset is going up or down.
  • MarketDifference: This strategy compares the relative price of a token pair in a swap pool with the price of the same pair on an exchange, such as Binance. If the price differs, the strategy opts for either going long or short on a given token.

Strategies are located in the src/strategies folder in the GitHub repo, and each strategy extends the Strategy class which requires you to implement the evaluate method to be implemented. The evaluate method is called every second with the latest data point from the data sources and should return a (potentially empty) array of trade orders.

To add other strategies, you can implement them as described above and add them to Capy Trading Bot by calling capybot.addStrategy in src/index.ts.

Installation and Usage

For installation and usage instructions, read:

Capy Trading Bot Repo

Capybot Monitor Repo