Sub topic 2
Liquidity Risk, Leverage, Custody, Counterparty and Protocol Risk
This chapter assumes you know how to buy and sell crypto on an exchange, how a blockchain records transactions, and how to read simple Python. It covers five risks that sit on top of price volatility.
Liquidity risk: thin order books and slippage
An order book lists the prices buyers and sellers will accept, along with the quantity at each price. When a token has few orders, a large trade consumes several price levels. The average fill price then moves away from the quoted price. This movement is called slippage.
Illiquid tokens can also become impossible to sell at any reasonable price during a panic. Check order book depth before trading.
asks = [(101.0, 2), (102.0, 3), (105.0, 5)] # (price, quantity) for sellers
def average_buy_price(asks, qty):
cost = 0.0
remaining = qty
for price, size in asks:
take = min(size, remaining)
cost += take * price
remaining -= take
if remaining == 0:
break
if remaining > 0:
raise ValueError("Not enough liquidity")
return cost / qty
best = asks[0][0]
avg = average_buy_price(asks, 6)
print(f"Average price: {avg:.2f}")
print(f"Slippage: {avg / best - 1:.2%}")Leverage and liquidation
Leverage borrows money to hold a larger position. A 10x long position on a 1,000 deposit controls 10,000 of an asset. A 10% price fall wipes out the deposit, ignoring fees and maintenance margin. The exchange then liquidates the position, which means it sells your holdings automatically, often at the worst price.
Custody risk: keys and self-custody
Whoever controls the private key controls the funds. On an exchange, the platform holds the keys. In self-custody, you hold them. A seed phrase, a list of 12 or 24 words, can recreate the keys. Anyone who sees the seed phrase can take the funds, and a lost phrase means the funds are gone.
Counterparty risk
Exchanges and lenders can freeze withdrawals, become insolvent or misuse customer assets. Holding assets on a platform means trusting that platform.
Smart contract and protocol risk
DeFi protocols run on smart contracts, which are programs on a blockchain. A bug or exploit can drain a protocol. Audits reduce this risk but do not remove it.
Exercise
A token's order book has 1,000 units offered at 2.00 and nothing above that. You want to buy 1,500 units. What happens to your average price?
Show answer
You fill 1,000 units at 2.00 and then no sellers remain for the other 500 units, so the order cannot complete in full. Any further fill would need higher asks, which would raise the average price above 2.00.