- Krishna's Newsletter
- Posts
- Building your own blockchain
Building your own blockchain
Digging into dYdX's decision to launch their own blockchain
Last week, dYdX announced that they were moving away from Ethereum and building their own chain. Here’s their announcement.
In this week’s deep-dive, we’re going to dive into their decision and the motivations for building your own chain. We’ll look at:
Decentralised vs. centralised exchanges
Order books vs. automated market making
dYdX: a decentralised exchange focussed on perp trading
Incentives for an independent chain
Pros and cons of launching your own chain
Decentralised vs. centralised exchanges
Centralised exchanges (Coinbase, FTX) act as the intermediary between buyers and sellers. They make money by taking a percentage of trading fees.
Decentralised exchanges (Uniswap, dYdX) facilitate trades directly between buyers and sellers. There is no intermediary.
There are 3 key advantages of a decentralised exchange:
No intermediary → lower fees
Usually have a native token → allows users to govern & own a part of the exchange
Non-custodial → users retain control of their assets (e.g. no one can freeze your account)
Order books vs. automated market making
Market making is the process of facilitating the buying and selling of an asset. Decentralised exchanges use two approaches for market making:
Order books
An order book is a list of prices that participants are willing to buy and sell at. The screenshot below is the order book for Bitcoin in GBP terms from Coinbase’s platform.
The market price is determined based on this data. In the example above, it is £17k for 1 BTC.
Automated market making
Automated market making involves aggregating liquidity for the two assets being traded and determining a price using a formula. Decentralised exchanges run this calculation on smart contracts.
In the example above, I’m trying to swap two assets: 1 ETH (Ethereum’s native token) for 1 UNI token (native token for the Uniswap exchange). Uniswap maintains a pool of ETH, a pool of UNI and determines a price using a formula based on the quantity of those two pools. Participants who provide liquidity for either the ETH or UNI pools are rewarded.
Key call outs
Order books and automated market making have their respective pros and cons. The most relevant ones for this discussion are:
Order books require a constant flow of buy and sell prices. There is a large amount of data that needs to be stored and processed in order to arrive at the final price.
Automated market making requires large liquidity pools. If the liquidity pool is not big enough, small trades can end up affecting the price and cause excess volatility.
If you’re interested in learning more about these approaches, I recommend reading this article.
dYdX: a decentralised, perp trading exchange
dYdX is a decentralised exchange focussed on perp trading. Perp trading involves using debt to make leveraged trades. The debt does not have a fixed term — hence the name “perp” (stands for perpetual). Here’s a quick example to explain how it works:
You buy BTC at $100 using 10x leverage
Your total trade is worth $100 x 10 = $1,000
There are the 3 outcomes:
Price goes up by 10%: you make $100 in profit (100% of your initial investment)
Price goes down by 10%: you lose $100 (100% of your initial investment)
Price goes down by 20%: you lose $100 (100% of your initial investment + an additional $100 to pay back debt)
As you can see, you can lose more than you invest. This is why I strongly recommend against leveraged bets unless you know what you’re doing. Read last week’s deep-dive on the curse of leverage for more info.
dYdX has to use an order book model because of its business model.
Due to its focus on perp trading, dYdX will always have fewer traders than other platforms — perp trading isn’t for everyone.
If dYdX used an automated market making method, the price of assets are likely fluctuate a lot because of limited liquidity pools. Given its focus on leveraged trading, this could lead to margin calls (i.e. when the price of a security hits a threshold, the lender asks for their money back). Therefore, dYdX has to rely on an order book method.
Incentives for an independent chain
dYdX is moving from Starkware, an L2 on Ethereum, to its own chain.
An order book requires a lot of data storage. Given prices are determined constantly quotes, there is a need to save a lot of data on a continuous basis. Blockchains are not great for data storage.
dYdX’s current solution uses Starkware. Starkware is an L2 solution on Ethereum. L2’s aggregate data off the main blockchain (Ethereum), process it and then submit an aggregate transaction to the main blockchain (Ethereum). They trade some amount of decentralisation for the ability to process large amounts of data.
dYdX’s L2 approach allows it to store large amounts of data and significantly reduce gas fees (transaction fees when you interact with a blockchain).
If a system is working, why change it? The move is motivated by:
A requirement to store large amounts of data whilst remaining complete decentralised.
We discussed the data requirements, let’s look at the requirements for decentralisation.
One of dYdX’s core objectives is decentralisation. I’ve always said, and will continue to say, that decentralisation means nothing to users. It’s a tool that could unlock benefits for users.
In the case of dYdX, I believe this benefit is regulation. The current approach requires that dYdX aggregate transactions and then submit them to Ethereum. Authorities like the Bank of International Settlements and the CFTC have often said DeFi protocols are not as decentralised as they seem. dYdX doesn’t operate in the US at all, likely because of this.
The move to an independent chain might help achieve the level of decentralisation it needs to satisfy authorities and the requirements for processing large amounts of data. They’re building the chain on the the Cosmos ecosystem, an ecosystem that allows people to easily spin up their own blockchain.
Pros and cons
Using dYdX’s example, let’s look at the pros and cons of building your own chain:
Pros
Sovereignty: your own blockchain gives you flexibility. For example, if you prefer your transaction data to be private this is possible.
Less competition: a blockchain for your app and your app alone means there is less competition. Transaction costs are less volatile, or at least only as volatile as usage of your app or service.
Decentralisation: an independent blockchain allows for a greater degree of decentralisation.
Cons
Security: An independent blockchain needs to be secure and resilient. On the contrary, L2’s use networks like Ethereum that have stood the test of time.
Bridging assets: Moving assets across chains is not easy and remain a big risk. The biggest crypto exploits have taken place on cross-chain bridges.
Personally, I understand the reasons for dYdX’s move to build its own chain. I hope they can do it, but remain cautious because of concerns around security and cross-chain bridges.
To summarise
Decentralised exchanges facilitate transactions between buyers and sellers without an intermediary.
Order books and automated market makers are the 2 types of trading models for decentralised exchanges.
dYdX focusses on leveraged trades. Due to limited liquidity, it uses an order book approach.
Order books need to store large amounts of data.
To solve this, dYdX uses Starkware, an L2 on Ethereum.
In order to achieve a greater degree of decentralisation and scalability, dYdX is building its own chain using the Cosmos ecosystem.
The million dollar question: does their desire for decentralisation warrant an independent chain, which needs to build security from the ground up?