Fundamentals of DeFi: Exchanges & Trading

Author: Alyssa Chen

What are exchanges?

A cryptocurrency exchange is a platform that facilitates the exchange of cryptocurrencies for other cryptocurrencies or fiat currencies. They match buyers and sellers and charge fees (specific to the exchange) for their services, and essentially serve as a medium between buyer and seller.

There are two main types of exchanges— centralized and decentralized exchanges. Centralized exchanges (CEXs), such as Binance or Coinbase, are operated by a central authority that maintain centralized control of user funds and transactions. Decentralized exchanges (DEXs) have no central authority and operate via smart contracts on a blockchain. Examples of DEXs include Uniswap, dYdX, and SushiSwap.

Coinbase, a centralized exchange, allows users to maintain a portfolio to buy, sell, and trade assets via Bitcoin, Ethereum, and over 260 other cryptocurrencies. (Source: Coinbase)
Coinbase, a centralized exchange, allows users to maintain a portfolio to buy, sell, and trade assets via Bitcoin, Ethereum, and over 260 other cryptocurrencies. (Source: Coinbase)

Users will typically pick an exchange to trade on, then create an account on the exchange and subsequently add funds to the account. The user can then purchase cryptocurrencies, and either keep the funds in the exchange or move their funds into a crypto wallet and start trading.

A user’s first digital wallet will likely be on a crypto exchange. Once the user purchases crypto, the crypto is automatically stored there. Wallets are identified by its public key, which is publicly accessible to anyone in the system. In order for User A to transfer assets over to User B, they would need to know User B’s public key in order to send the transaction over to a certain address. A private key is similar to a password— it is used as an identification method for users to prove ownership to their public key, and should be privately and securely stored. Public and private keys are built off the notion of public-key encryption in cryptographic systems (For further reading, check out A Method for Obtaining Digital Signatures and Public-Key Cryptosystems).

In CEXs, the exchange retains full control over your private keys, and the user logs in with a generic username and password combination. DEXs, however, are non-custodial— each user is able to maintain full autonomy over their private keys. Therefore, for every DEX and CEX, there is a tradeoff between security and convenience.

Tradeoff between security and convenience in exchanges. (Author: Tiffany Liu)
Tradeoff between security and convenience in exchanges. (Author: Tiffany Liu)

Additionally, there is the notion of a hot and cold wallet in crypto exchanges. Hot wallets are connected to the internet and may be prone to hacking— however, hot wallets offer more convenience and are faster to access compared to cold wallets, which operate offline and are less prone to hacking.

In general, wallets on exchanges are hot. Reputable exchanges will store user funds in cold wallets for security reasons. For example, if a hack occurs, hot wallets would be vulnerable, whereas cold wallets would not be susceptible as most funds are locked away physically.

There are three main types of transactions that can occur on crypto exchanges:

  1. On-Ramp

  2. Crypto-Crypto

  3. Off-Ramp

On-ramp transactions allows users to buy cryptocurrencies and pay in fiat currencies while crypto-crypto transactions, as the name suggests, allow for users to buy and sell crypto in exchange for other cryptocurrencies. Off-ramp transactions allow users to buy fiat currencies and pay in cryptocurrencies (think of it as the opposite of on-ramp transactions).

Market Orders

When placing a market order on an exchange, the goal is to execute the trade immediately at the best available market price. Market orders prioritize speed and are designed to maximize the likelihood of the trade being completed quickly, though their execution still depends on the asset's liquidity and availability.

In a highly volatile market, the price can change rapidly between the time an order is placed vs. the time it is executed.

As an example, you place a market order of 1000 stocks when a stock price is $20 per share ($20,000 total). However, when the order gets executed, the stock price is actually $21 per share, resulting in an unexpected cost of $21,000.

In this scenario, let’s think about why would a user want to be cautious about placing a market order for highly volatile stocks.

It turns out that market orders are often executed quickly at the best available price. However, this market volatility, as discussed earlier, can account for the $1000 price discrepancy— this is known as price slippage. Additionally, market orders may be filled at multiple prices if the order is large and liquidity is limited, further increasing the potential for discrepancies in the total cost or sale.

To mitigate these risks, users can place limit orders, where they either specify the minimum price they are willing to sell at or define the maximum price they are willing to buy. Two scenarios in which placing a limit order can be helpful would be (1) if the stock is highly volatile or (2) if the stock has a large bid-ask spread (i.e. the difference between the highest price a buyer is willing to pay for the stock and the lowest price a seller is willing to accept the stock for).

Limit orders are designed to execute only when the market price reaches a specified price (or better) and often come with an expiration, meaning the order will remain active only for a set period. If the market price does not meet the specified limit within that time frame, the order may never be filled. This trade-off makes limit orders useful for buyers seeking to control the purchase price, though they risk missing the trade if the price doesn’t reach the desired level.

There may also be partial fills based on the liquidity of the asset when an order price is met. If not enough available shares or units are available at the specified price, only part of the order may be filled, with the remaining portion left unexecuted unless further liquidity becomes available. This is another important consideration for traders to make, particularly in lower liquidity markets or when placing larger orders.

Traders should also be mindful of the fees associated with trading on an exchange, which can impact the overall cost and profitability of a trade. In terms of fees, exchanges typically charge several types of fees:

  1. Network fees

  2. Trading fees

  3. Deposit/withdrawal fees

These fees typically depend on several factors: trading volume (i.e. how many trades are being executed in a period of time, cryptocurrency pairings (which pair of currencies a user is exchanging), and account type. Below, we go more in depth into network and trading fees.

Network fees, otherwise known as gas fees or blockchain fees, refer the the fee a user pays to network for their transaction to be placed and included (or approved) in the blockchain. Trading fees are paid to crypto exchanges for their trade to be carried through. The most popular model used to determine trading fees is the “maker” and “taker” model.

Makers essentially sell crypto, which “make” the market while takers “take” crypto or liquidity off the market. Usually, limit orders are subject to maker fees, while market orders are subject to taker fees. When a user places an order that is not immediately filled, it goes to an order book. Maker fees typically apply to these transactions. Some orders will fill partially on an order book— a taker fee applies to the portion of the order that fills immediately, whereas the portion that makes it onto the order book are subject to maker fees. This system is designed to incentivize large transaction amounts (This video from Binance does a great job at explaining the maker and taker model).

Coinbase fee tiers based on trading volume. Makers and takers are both subject to different charges based on these tiers. (Source: Coinbase)
Coinbase fee tiers based on trading volume. Makers and takers are both subject to different charges based on these tiers. (Source: Coinbase)

Introduction to Trading

As we presented earlier, slippage can occur when there is insufficient liquidity in the market. Liquidity is defined as the ability to buy or sell an asset without affecting its price. A market with high liquidity will have a large number of buyers and sellers, making it easier for users to execute trades at the desired price. On the other hand, a market with low liquidity may have wider bid-ask spreads, making it more difficult to execute trades at the desired price.

Slippage is formally defined as the difference between the expected price of the trade and the actual price at which the trade is executed. This can impact profitability of a trade, especially for large orders, which is more pronounced on low-liquidity markets.

There are a few different types of cryptocurrency trading:

  1. Spot trading- traders take advantage of market movements by buying or selling cryptocurrencies at the current market price.

  2. Margin trading- traders borrow funds from exchanges or other traders to increase their buying power.

  3. Futures trading- buying or selling contracts that obligate traders to buy or sell cryptocurrencies at a future date and predetermined price.

  4. Options trading- similar to futures trading, except traders have the option (rather than the obligation) to buy or sell.

One of the most popular methods of trading is margin trading. The goal with margin trading is to generate a profit from the price movement of the asset. Investors will borrow funds from a broker to trade assets, which allows traders to increase their trading position with a smaller initial investment.

There are a few benefits of margin trading. First, it can increase a traders leverage, from trading with an initially smaller investment to exposure to a larger position. Additionally, traders have more profit potential with market movements, and are able to use margin trading to hedge (protect) their positions against potential losses.

However, cryptocurrency markets are highly volatile. This leads to significant price swings, and if the market moves against the trader, then their position may be liquidated as a result in order to prevent further losses. Traders are also charged interest on the funds they borrowed, which may eat into their profits.

Arbitrage is a strategy in which traders leverage price differences between markets, and involves buying and selling the asset in different markets. The primary objective with arbitrage is to generate risk free profit by exploiting market inefficiencies, but this depends on the speed of executions and market conditions (market inefficiencies are often corrected pretty quickly). For example, by buying Bitcoin on an exchange where the price is low, and selling it on an exchange where the price is slightly higher, an arbitrageur is able to generate a marginal profit. When done in high volumes, arbitrage can be extremely profitable.

Below, we identify a few common types of trading strategies:

  1. Buy and hold: Users will buy a cryptocurrency and hold it for an extended period of time, based on the belief that the assets value will increase over time.

  2. Swing trading: By taking advantage of price movements during days of weeks, users will buy and sell cryptocurrencies based on short-term price swings.

  3. Day trading: Traders buy and sell positions within the same trading day, using technical analysis to identify short-term price movements.

  4. Scalping: Profit is generated from small price movements within a few seconds or minutes.

If you’re interested in learning more about decentralized finance— including exchanges, stablecoins, derivatives, MEV and more… stay tuned for Blockchain at Berkeley’s Fundamentals of DeFi article series!

In the next week, we’ll go into a deep dive on other decentralized exchanges and discuss different type of DEXs in the industry!

This series is based off Blockchain at Berkeley’s DeFi lecture series. Credits to Tiffany Liu, Riteka Murugesh, Aditya Bhandari, Nate Pola, Daniela Fajardo, Jaylem Brar, and other previous contributors.

Subscribe to Blockchain at Berkeley
Receive the latest updates directly to your inbox.
Mint this entry as an NFT to add it to your collection.
Verification
This entry has been permanently stored onchain and signed by its creator.