Date
Author
Alex Berke
DevRel
Arbitrage and Winning a Cryptocurrency Trading Competition at MIT
What we learned about crypto markets, arbitrage, and Celo’s stability protocol — and how I won the trading competition.

Reading time
7 minutes
Share
There are numerous cryptocurrencies and crypto assets, and a variety of markets on which they are exchanged. Arbitrage opportunities arise among these various markets, and a corner of the Internet is financially capitalizing on these opportunities by programming algorithms that automatically execute trades.
MIT students recently had the opportunity to peer into this profitable world of crypto trading, and compete in our own small version of it.
MIT, where I am currently a graduate student, has a January term during which classes are offered that may not fit in to more traditional curriculums. One of those classes was a crypto trading workshop, sponsored by Celo and MIT’s Bitcoin club. The class included sessions with professionals who make their living from crypto trading, with lessons that covered the economics of trading and arbitrage opportunities of crypto markets.
At the same time, students competed in a month-long competition to trade Celo’s cryptocurrencies most profitably.
This post is an overview of what we learned about the markets and arbitrage strategies that make crypto trading profitable, as well as how I used those strategies to win the crypto trading competition to take home some cash. I’ll share what we learned about:
Crypto markets and arbitrage
How Celo uses a price stability protocol to control the volatility of its crypto assets and maintain a stable token pegged to a fiat currency such as the US dollar
Implementing a winning algorithmic arbitrage strategy
Crypto markets and exchanges
Bitcoin (BTC), Litecoin (LTC), and Ethereum (ETH) are among the most well known cryptocurrencies, but there are more than 1600 other crypto assets. Many of the newer ones are ERC-20 tokens, which means they are implemented as “smart contracts” on the Ethereum blockchain. Cryptocurrencies are exchanged both on and off their blockchains.
Centralized exchanges
Most trading occurs on large centralized exchanges, such as Binance and Coinbase. These exchanges allow users to trade one cryptocurrency for another, as well as trade between crypto and fiat currencies (e.g. US dollars, Euros). They do this by matching the trade orders of their traders in a similar manner to how order books are used for traditional securities trading. Someone can place a trade order to buy token A for token B at a given exchange rate, and the exchange will match that order with someone else’s order to sell token A for token B at a compatible rate. With enough sellers and buyers, and an overall high volume of such trades, prices for tokens are established.
Like traditional financial markets, many of the large exchanges support limit and stop orders. They also provide APIs that make it possible to write code that trades on behalf of its programmer. While people can submit manual trades on these platforms, more advanced traders write algorithms in order to automatically submit trades as quickly as possible once profitable trading opportunities are found.
Centralized exchanges have been subject to notorious hacks. For example, Mt. Gox was a Bitcoin exchange based in Japan that lost an estimated $450 million in Bitcoin due to a hack in 2014. The reason that centralized exchanges are so attractive to hackers and a liability for their traders is that they store the funds that are involved in their transactions. They act as a central authority for the trades executed on their platforms by managing the funds, trades, and withdrawals of their users. Despite the famous hacks, centralized exchanges are still the most widely used means of crypto exchange.
Decentralized exchanges
There are also decentralized exchanges (DEX), such as Etherdelta and IDEX. These are open source platforms with no central authority, where traders can exchange currencies on a peer-to-peer basis. They allow users to maintain control of their funds (and anonymity), which makes them more resistant to hacks. They are also more difficult to use, and so have lower trade volume than centralized exchanges, which has kept their fees higher. Most trades are still conducted on centralized exchanges.
Alternative markets and liquidity systems

Crypto technologies have introduced new ways to design market making mechanisms and allow for automatic trading. Bancor and Uniswap use a similar model design that is both simple and powerful: the x∗y=k model. While most exchanges maintain order books and facilitate matches between buyers and sellers, these alternative systems use smart contracts to hold liquidity reserves of various tokens, and execute trades directly against these reserves.
A simple way to understand this liquidity supply is as pairs of token reserves. For example, a reserve of token A paired with a reserve of token B allows for the trade of token A for token B, as long as the trade obeys the model rule: the product x∗y=k must be preserved, where x is the reserve’s total quantity of token A, y is the reserve’s total quantity of token B.
“The idea is that you have a contract that holds x coins of token A and y coins of token B, and always maintains the invariant that x∗y=k for some constant k. Anyone can buy or sell coins by essentially shifting the market maker’s position on the x∗y=k curve.” — Vitalik Buterin, Ethereum Founder.
The token exchange price is then determined by the ratio x:y in the pair of token reserves. Naturally, the market drives this ratio towards a price that matches that of the other token exchanges. If the ratio did not match the exchange rate on other exchanges, then there would be a price differential between the exchanges, which would create an opportunity for traders to make a profit. This is where arbitrage comes in. Arbitrage, while it allows for opportunistic traders to make a profit, is also an important mechanism to keep the overall market in sync.
Note that the exchange rate for tokens in an x∗y=k model changes with each trade, because each trade alters the ratio of tokens. This creates a continuous “slippage” that can be mathematically determined prior to the trade. The x∗y=k market maker operates on-chain. The exchanges that operate by this model are decentralized, and trades are automated by smart contracts. Those who supply the initial liquidity for the token reserves can then reap yields. A small fee (0.3% for Uniswap) is taken out of each trade and added to the reserves, generating the yield for the liquidity providers, as well as increasing the overall quantity of reserves.
Arbitrage
With so many different exchanges, there end up being price discrepancies between them. The variations in prices across exchanges can be capitalized on. For example, if token A and token B are exchanging at a rate of A / B = 1 / 2.2 on exchange X and at a rate of 1 / 2 on exchange Y, then a trader can make 0.2 of profit in token B by purchasing 2.2 units of token B for 1 unit of token A on exchange X at the 1 / 2.2 rate and then immediately selling 2 units on exchange Y at the 1 / 2 rate to get back their 1 unit of token A. They get to keep their unspent 0.2 units of token B.
This conceptually simple form of arbitrage can be summarized as “buy low, sell high”, and is known as 2-leg arbitrage. The first leg in our example is the transaction on exchange X and the second leg is the transaction on exchange Y. Arbitrage is a set of transactions that involve no negative cash flow, and only positive cash flow. An arbitrage cycle is a series of trades that generates a “riskless” profit.
In practice, 2-leg arbitrage and other trading strategies that require moving assets between exchanges are risky and not well suited for cryptocurrency markets. Moving assets between exchanges means withdrawing funds from one exchange, making a transaction on the blockchain, and then depositing the funds in another exchange to complete the next transaction. Each of these steps incurs fees and are time intensive. In the time it takes for a transaction to complete on the blockchain, a profitable opportunity can disappear. Executing a series of transactions within a single centralized exchange is much faster, and arbitrage opportunities can still be found within a single exchange.
Similar to 2-leg arbitrage cycles, traders can find arbitrage cycles with more legs. For example, an arbitrage cycle with 3 legs, known as “triangular arbitrage”, occurs when exchanging three assets, say tokens A, B, C, in a cycle: token A for token B, then token B for token C, and then token C for token A, resulting in a net gain. These opportunities can arise within a single exchange due to market inefficiencies. However, these opportunities are quickly closed by those who exploit them. Finding and exploiting arbitrage cycles is a race, where the traders with the fastest trading algorithms win.
There is another arbitrage strategy that a professional trader discussed in our class. It is like a simplified version of what some might call “statistical arbitrage”. It involves maintaining positions in two centralized crypto exchanges at once. Opportunities are then found where a given asset has different prices across the two exchanges in order to take a short position where the asset is more expensive, and a long position where the asset is cheaper. Every so often, the trader withdraws or deposits funds on the two exchanges in order to rebalance the values in the accounts or extract their profits.
Celo’s Tokens and Stability Protocol
Volatility is a well known problem for popular cryptocurrencies. A currency with highly volatile price fluctuations is not as useful in the exchange of goods and services as a currency that has a trusted and understood value. In order for the public to benefit from cryptocurrencies as actual currency rather than just financial assets to trade and profit from, cryptocurrencies need a value that the public can trust to remain stable.
“Stablecoins” or “stable tokens” are commonly presented as a solution to this problem. Stable tokens are pegged to a fiat currency (e.g. the US dollar) so that their value can match that currency with limited fluctuations. The implementations of stable tokens vary, and often involve backing tokens with collateral.
Celo has two crypto assets and uses them in a clever protocol in order to algorithmically address the price stability problem. The Celo Dollar token (cUSD) is a stable token that is pegged to the US dollar and has an elastic supply. The Celo Gold token (cGLD) has a fixed supply, but its value is allowed to vary. Celo Gold is used to help control the circulation of the Celo Dollar and keep its value pegged to the value of USD. Celo’s protocol does this by automatically adjusting the supply of Celo Dollars by buying or selling Celo Dollars for Celo Gold.
When there is more demand than supply for the Celo Dollar, its price is pushed up above $1. When the supply exceeds the demand then the price is pushed below $1. By expanding or contracting the quantity of Celo Dollars in the open market, Celo brings the supply and demand to the desired $1 equilibrium. Expansions: when the price of Celo Dollars is greater than $1, the protocol creates new Celo Dollars and sells them on the open market in exchange for Celo Gold and other crypto assets that it puts in Celo’s reserve. Contractions: when the market price is less than $1, the protocol purchases Celo Dollars from the open market with reserve assets, and then “burns” them.
The Celo protocol uses decentralized auctions to perform these expansions and contractions in the open market. The auctions are capped, multi-unit, first-price sealed-bid (also known as “blind auctions”). Sealed bids are hidden until the auction bidding stage is complete, so traders must use past auction bid prices to determine their optimal next bid. Multi-unit means traders can bid on any fraction of the total pool of assets being auctioned off. Capped means each auction has a limit to the amount of Celo Dollars that will be bought or sold; submitted bids are ordered by price, from highest to lowest, and filled in order until the cap is reached.
Competition and Arbitrage Algorithms
The crypto trading competition that Celo ran throughout the month-long class made use of our lessons about crypto markets and arbitrage strategies. It operated on a fork of the Ethereum network and only involved trading Celo Dollars (cUSD) and Celo Gold (cGLD).
Game mechanics: each competitor was given a wallet initially filled with 25 cUSD and 25 cGLD. The winner would be the one with the most value in their wallet at the end of the month. The prize was payment of the wallet’s value in US Dollars, plus a $1000 added bonus for the winner. The competition involved two markets to trade in: an auction that ran once an hour (where traders could bid to buy or sell cUSD for cGLD depending on whether the auction was performing an expansion or contraction), and an exchange that operated by the x∗y=k model and could be used to trade between the two assets at any time.
The occurrence of hourly auctions and the constant presence of the exchange created arbitrage opportunities that successful trading strategies could profit from. Trades could be manually executed via a CLI, or executed by programmed algorithms (Celo provided an SDK to interface with the CLI). Once an algorithm is programmed and tested, it can be left running on a server, taking advantage of each auction and arbitrage opportunity around the clock.
I programmed an algorithm that ran around the clock by using Celo’s SDK and hacking on some of their sample code. By the end of the competition it had net a profit of about $500 after starting off with about $50 of crypto. The algorithm’s approach to profit was simple, like 2-leg arbitrage: “buy low, sell high”. The implementation involved the following ideas and variables:
Balance — to minimize risk, I kept the value of cUSD and cGLD in my wallet balanced at a 50 / 50 target. After each auction closed, if the ratio deviated from the target by a 10% threshold, I traded with the exchange to restore it.
Bid discount — profit could be made by placing bids at a “discount” to the exchange rate, then trading the auctioned tokens at the exchange for the exchange rate (less slippage). The higher the bid-discount, the higher the profit margin — but too high and other traders would outbid.
Bid adjustment — the bid-discount was incremented or decremented by a fixed amount to maintain an optimal value.
Minimum bid discount — the bid-discount was never allowed to fall below a minimum value (e.g. ~1.01) even if this meant being outbid.
Success streak — a numeric variable kept track of when bids were successful. At the end of each auction, a successful bid incremented the success-streak by 1; otherwise it reset to 0.
A simplified version of the algorithm, in pseudocode:
For each auction: get the exchange rate and multiply it by the bid-discount bid to buy as much as possible at the discounted rate, then wait for the auction to end if the bid was unsuccessful: reset success-streak and decrement bid-discount (keeping it above the minimum) if the bid was successful: increment success-streak, and if success-streak > 5, increment bid-discount rebalance the values of cGLD and cUSD in the wallet if necessary
This algorithm was simple, but it was enough to be successful. More importantly, thinking about arbitrage strategies for Celo’s competition was an interesting way to learn about crypto markets. Thank you, Celo, for the workshop resources and lessons.
To answer your next question: No, I am not planning to invest my winnings back into crypto markets and continue writing arbitrage algorithms. Crypto trading was a fun means through which to learn more about digital currencies and blockchains, and learning is what I will continue to invest my time in.
DeFi
Stablecoins
Events
Latest


