📚Abas Under the Hood

What is Arbitrage?

Arbitrage is a trading strategy that exploits small price differences across different exchanges on the same underlying asset like Bitcoin. Traders with access to both exchanges can buy Bitcoin on the lower price exchange, transfer the Bitcoin to an exchange trading at a higher price, and sell the Bitcoin for a profit.

There is no better person to explain how this work than Sam Bankman-Fried himself, who made his first fortune doing arbitrages between US and Japan exchanges:

Centralized Exchange Arbitrage

However, doing arbitrages profitably across centralized exchanges is a lot more difficult than it sounds, if not impossible for normal users for the following reasons:

  1. The opportunity is small across major exchanges. Price in exchanges like Coinbase, Binance, and FTX moves almost completely in sync due to the same group of market makers are plugged into them. When there is a price difference, it would be such a small profit that is lower than the normal user's trading fee to enter the trade.

  2. The opportunity is short-lived. Market maker firms spent tens of millions of dollars upgrading their network infrastructure and software for sub-millisecond trade execution.

  3. Smaller exchanges that may have a higher frequency of price differences are gated by a heavy KYC process, and usually only accepts the residences from where the exchange is (Japan in Sam's case.)

DEX Advantages

Abas's cross exchanges arbitrage strategy solves these problems by strictly trading on decentralized exchange only and embedding the trading strategy framework into its on-chain program.

By integrating with Drift and Mango on the Solana blockchain we gain the following advantages:

  1. Arbitrage opportunities on decentralized exchanges are in an abundance state due to Drift employing a Dynamic AMM price model. This means when an asset's price moves in other exchanges, it is expected and encouraged for an arbitrager to trade on Drift to bring price into the correct state.

  2. Arbitrage opportunities last for 400ms (block time) on Solana blockchain before updating to the next block. This provides a leveled playing field for anyone with normal internet speed to read on-chain order-book, search for profitability, and broadcast transactions into the next block.

  3. Most importantly, due to the nature of the single-state blockchain, users are guaranteed either they will be filled in both exchanges at the price they want, or neither transaction happened. For example, when Abas observes the BTC-PERP price differences between Mango and Drift is wide enough, it places one single transaction into both exchanges, specifying the price it wants from both exchanges. If say Mango can not meet the price requirement for any reason, the transaction will fail - reverting the Drift order as well. This is impossible to do in a centralized platform such as trading between Coinbase and Binance. In fact, Abas does not need to monitor the order book or price movement at all, more on this in the following section.

Abas Under the Hood

On every block, Abas simulates a transaction opening a long position in Mango regardless of price. Abas then uses the long position's price to calculate the short position price it should expect on Drift. If Drift can not provide this price at the current block, the simulation will fail, and Abas will wait for the next block.

For example: Abas runs a new simulation and opened a Long position on Mango for SOL-PERP at the price of $100. Then Abas calculates that the expected short price on Drift needs to be $100.50. If Drift can fill a $100.50 short position on SOL-PERP, the simulation will succeed, and Abas will broadcast the transaction publicly. If Drift is only selling SOL-PERP at $100.30, the simulation fails and Abas will try again the next block.

In rare cases, the simulation succeeds in simulation but the transaction fails after broadcasting. In that case, the user bears no losses because none of the transactions were opened and the transaction fee was paid by Abas keeper. This trade execution logic is written in Abas' program and can not be easily altered. It serves as a strategy framework for Abas users because it can only execute according to configurations. It is not possible for Abas to suddenly spend all of the user's collateral USDC to buy up BTC-PERP. This strategy framework acts as a protection layer for the user compared to the traditional centralized exchange trade bot service, where the operator has total control over the user's trading once obtaining the API key.

Last updated