None of this is financial advice. For entertainment/educational purposes only. I have no affiliation with any exchange or platform.
I come from a financial background and have since become a software engineer. I would like to be involved in financial engineering but since I don’t have a degree in engineering or a hard science, I never had the chance. However, crypto and decentralized finance allow me to get first hand experience in high finance with relatively low stakes.
Crypto exchanges tend to provide a lot provide more information than your typical broker. For instance, Binance gives you access to the order book which lets you see the open interest for a token, historical trade data, and a well documented api with many functions that don’t require registration or an api key.
Here is a visual representation of the order book, a list of available buy and sell orders available at a point in time. You
Compare that to Merrill Edge, my primary stock brokerage, which is obsessed with having me validate that my email hasn’t changed every time I log on.
The most interesting thing I found about the platforms was decentralized exchanges built off Ethereum and Binance Smart Chain. For instance, Uniswap is a decentralized trading protocol that allows you to swap tokens and act as a market maker. The Binance equivalent of Uniswap is called Pancake Swap.
Automated Market Making
High frequency traders make money by providing liquidity. This means offering to buy and sell an asset at a limit price. For instance, if an asset is trading at $1, you can offer to buy it at $0.99 and sell at $1.01.
This serves a function in any exchange, otherwise matching up buyers and sellers would be considerably more rare. Today we take for granted deep order books that allow us to trade at any time while not moving the price a lot.
Automated market makers (AMM) perform a similar function. Consider a market for two coins: A and B. We can create a fund that holds 50% of A and 50% of B, in terms of market value. The user can then get the price of the pair by looking at the ratio of A and B in the account balances.
The liquidity provider charges a fee (usually around 0.3%) which is shared with the creator of the contract and the person who provided the liquidity by funding the contract.
Take an example where A and B are ETH and USD, respectively.
ETH = 100USD
10ETH + 1,000USD = 2,000USD
Price of 1 ETH: 100USD
Suppose someone wanted to buy 1 ETH:
Original ETH balance:
10ETH * 100USD (price) = 1,000USD
Buy 1 ETH:
(10 - 1) * price = 1,000
price to buy 1 ETH = 111.11
Final:
ETH: 9
USD: 1,111.11
New price of 1 ETH: 1,111.11 / 9 = 123.46USD
To buy 1 ETH, it would cost you $111.11 plus a fee that accrues to the liquidity providers. The end pool would still have the same K. Buying the coin increases the price. That’s known as slippage (Price Impact) below:
The bigger the trade size, the more slippage. Illiquid coins have a high slippage as the liquidity pool is very shallow.
If the price of ETH is still $100 on other exchanges, arbitragers will buy 1 ETH elsewhere and trade it for USD and receive $111.11 for it. Then everything will be back to normal.
The formula is X * Y = K always holds, where X is the amount of the coin, Y is the price and K is a fixed amount. In the example above where K is 1,000, this is what our graph and prices would look like:
Buying 1 ETH would reduce the pool from 10 to 9, moving us along the curve to a Y of 111.11 (the price to be paid).
The bigger the K (i.e. pool size), the less the price moves on a trade. For instance, in the example above, if K was 2,000 as opposed to 1,000, the pool would contain 20 ETH and buying 1 ETH would only cost $105.26 as opposed to $111.11:
The benefits of scale are very large. Everyone wants to trade in the largest, deepest pools as they’ll have the best execution. And people that want to provide liquidity would prefer to fund large pools since that’s where you’ll see the most action.
On PancakeSwap, they call them farms and Uniswap calls them pools.
For PancakeSwap, you need to own both tokens for which you’re providing liquidity (e.g. BUSD-BNB). You can buy the respective tokens by using the same liquidity pool you’ll soon be funding. You buy a pair token with the respective amounts of each coin (50% in terms of market value in each token). Finally, you can stake this token to begin “farming” and theoretically earn a ridiculous APR, depending on the token pairs.
Uniswap is similar, but without the LP token step. You just buy the respective token pair, then stake them directly.
How am I going to get screwed?
You still have exposure to the two coins. You’re staking both sides in the AMM, so you have to compare your returns relative to a buy and hold strategy. If you’re making a market in ETH-USD, and the price of ETH increases, you sold on the way up. Had you just held the two positions, you would have been better off. This is called impairment loss. The fee you earned from the trades may or may not make up for impairment loss.
As the relative price of the coins moves, you lose money compared to a buy and hold strategy:
The best case scenario for providing liquidity in an AMM is if the price fluctuates around your initial price, or you collect enough fees from the trades that it makes up for the impairment loss.
Final Thoughts
Decentralized exchanges is the one proven application of smart contracts that is obvious. It allows people to trade a large number of coin pairs relatively easily. You can also combine trades to get better execution. For instance you can trade coin A -> B -> C and often get a better rate than trading A -> C directly, even if such an option exists.
It also allows people to provide liquidity and earn a return without much effort. But this isn’t exactly a killer app for tokens, because it still relies on the underlying principle that the tokens being traded are useful. If you’re trading shit-coins with no utility, then AMMs amount to a technical triviality. AMMs are not enough to sustain themselves in terms of utility. But if there is some utility in some tokens, AMMs serve as an important piece of infrastructure to make the system work well.