Original source: Four Pillars

Original author: Steve

原文标题:Why did dYdX choose to launch its own chain instead of continuing with a Layer 2 solution?

Compiled by: Azuma, Odaily Planet Daily

Introduction and background

1.1 Purpose of this article: Why did you choose to study dYdX?

Many people believe that dYdX is one of the most successful decentralized exchanges (DEX). Although this is also true, from a researcher's perspective, dYdX is eye-catching for two main reasons: First, it passes Practice has proved that the current trend of building Rollup in the blockchain industry is not the only correct answer; secondly, it provides an important case study for the fierce debate in the industry about whether infrastructure or application is more important. We will explore these reasons in detail.

1.1.1 A direct refutation of Rollup maximalism

The blockchain industry in 2023 can be described as the Rollup era, with many Rollup solutions springing up like mushrooms after a rain. After the fall of Terra (it was once a strong competitor of Ethereum), Solana suffered a heavy setback due to the FTX crisis, and it was generally believed that "Ethereum has won." Therefore, many projects stopped developing their own Layer 1 blockchains and instead became Rollups of Ethereum, trying to borrow the security of Ethereum while maintaining a certain degree of autonomy.

However, this does not spell the end of Layer 1. Some derivative projects from the Meta blockchain project Diem bring new concepts in many fields such as consensus mechanisms (such as Bullshark, Narwal, etc.). What is particularly interesting is that some projects have started from Rollup and transformed to build their own Layer 1 blockchain. What is particularly curious is why a project that has achieved success in Layer 2 would give up its original achievements and launch its own chain. dYdX is such a case, and its changes directly challenge the so-called "Rollup maximalism." At the beginning, dYdX was not Layer 1, and it was also quite popular as a Layer 1 project. As dYdX transforms into an independent Layer 1, this has also triggered thinking that Layer 1 solutions are not a foolproof solution to all problems.

1.1.2 A notable case of infrastructure vs applications

Second, dYdX provides an important case in the debate about infrastructure versus applications. As discussed later, dYdX’s product quality has improved significantly as the infrastructure it builds has progressed. Essentially, the idea that a solid infrastructure is critical to product development has been proven throughout dYdX’s history. The project has benefited greatly in terms of scalability and user-friendliness through two major infrastructure updates. Therefore, in this debate, dYdX becomes a tangible example of the importance of supporting infrastructure.

1.1.3 Let’s take a closer look at dYdX

In addition to the above reasons, dYdX is an extremely attractive project in many aspects. It had previously migrated from the Ethereum main chain to Layer 2, but unexpectedly encountered an existential crisis during the boom period of DeFi. The struggles dYdX faced and the strategies it used to overcome them are not only amazing, but also provide valuable lessons for those building on-chain products.

Therefore, with this article, I hope to provide an overview of the history of dYdX and explain in detail why it is launching its own blockchain. I’ll compare the original version of dYdX to the new version, and ultimately discuss what dYdX’s path forward means for the industry. This analysis will be of reference value to those considering launching or transforming products in this area.

1.2 Interpretation of Perpetual Contract Agreement

First, dYdX is a decentralized exchange (DEX) focused on derivatives trading, specifically perpetual futures contracts, although its initial services were margin trading and options trading. In order to understand dYdX, we first need to understand the cryptocurrency perpetual contract protocol. The operating model of decentralized exchanges is different from traditional centralized exchanges. Unlike centralized entities that process transactions, decentralized exchanges use blockchain and smart contracts to manage transactions in a decentralized manner. Perpetual futures contracts are similar to regular futures contracts and involve trading an asset or commodity at a specific price at a predetermined time, but they do not have a fixed expiration date. This means traders can hold their positions indefinitely.

Therefore, as a DEX that handles perpetual futures contracts involving crypto-assets, dYdX is significantly different from traditional exchanges. It leverages blockchain and smart contracts to facilitate transactions in a highly decentralized environment.

Now that we have a basic understanding of the decentralized perpetual futures exchange, let’s further explore dYdX and its history.

1.3 A brief background history of dYdX: from CEX to DEX

Antonio Juliano, the founder of dYdX, already had extensive career experience in the blockchain industry before founding dYdX. His crypto/blockchain career journey began at Coinbase – one of the largest cryptocurrency exchanges in the world. During his time at Coinbase, Antonio gained deep experience with blockchain and cryptocurrencies, which undoubtedly laid the foundation for his conception of dYdX. When Antonio conceived of dYdX, margin trading was becoming increasingly popular in the crypto space, with many investors using leverage to pursue bold investment strategies. Antonio envisioned implementing these leveraged trading strategies on the blockchain, an idea that eventually gave birth to dYdX.

Subsequently, dYdX received approximately $2 million in investment and was valued at $10 million with the support of well-known institutions such as a16z and Polychain. Then dYdX gradually grew and began to show its products to the world.

dYdX was very different then than it is today. It was not originally built on Layer 2 (surprisingly, it was initially deployed on the Ethereum mainnet) and did not have an autonomous trading system (it used a third-party DEX). What’s more important to point out is that dYdX did not support perpetual futures trading at the beginning. So how did dYdX as we know it today come to be?

1.3.1 gas, gas, gas! DeFi Summer “Catastrophe”

To understand why dYdX chose to transition from Ethereum mainnet to Layer 2, we need to look back at the events that occurred before the beginning of 2020. Perhaps contrary to what many people know, dYdX was one of the highest-volume decentralized exchanges at the time, accounting for approximately half of all decentralized exchanges’ trading volume. However, everything changed during the so-called DeFi Summer, a change triggered by Compound’s launch of its governance token COMP and the introduction of the concept of liquidity mining.

During DeFi Summer, DeFi tokens experienced an explosive rise (although many tokens were created haphazardly to encourage liquidity supply and had no real value support). New DeFi tokens are emerging rapidly and can be traded on Uniswap immediately, which has caused many traders to switch to Uniswap. This shift also caused dYdX’s trading volume to drop rapidly from 50% to a paltry 0.5%.

DeFi Summer brings more than just market share challenges. During this period, Ethereum’s gas fees skyrocketed, posing a near-catastrophe to dYdX because dYdX has been bearing users’ gas fees to improve user experience. Before DeFi Summer, gas fees were low enough to be covered by dYdX’s transaction fee income. However, as Ethereum’s gas fees surged approximately 100 to 1000 times, dYdX faced serious financial losses. They took some measures, such as setting a minimum transaction amount (for example, $10,000), but in the end, dYdX had to introduce transaction fees that matched the actual gas situation, which resulted in users' transactions facing high fee thresholds (transaction fees are often over $100 per transaction).

Ironically, just as DeFi's popularity is rising, dYdX has encountered the most difficult challenges. What is less known is that at this time, dYdX was on the verge of bankruptcy. Due to limited funds and existing investors' unwillingness to invest additional money, dYdX is facing a serious financial crisis. Additionally, the company faces the challenge of communicating its differentiation to the market. Interestingly, bankrupt Three Arrows Capital was one of the firms that provided funding to dYdX during this period.

Ultimately, in order to escape this unstable situation, dYdX decided to make fundamental changes, which led to it choosing to leave the Ethereum mainnet. This transition also created the dYdX we were familiar with - a decentralized derivatives exchange built on StarkEx, a STARK-powered scalability engine owned by Starkware.

dYdX meets Starkware, a turning point is coming!

2.1 Why choose Layer 2?

dYdX’s adoption of a Layer 2 solution is not only a strategic choice when it encounters setbacks in competition with Uniswap, but more importantly, it is a necessary response to unsustainable transaction fees on Ethereum. Layer 2 offers a viable alternative that is not only capable of handling dYdX’s transaction throughput, but also significantly reduces transaction fees.

The Ethereum Layer 2 solutions at the time—especially Starkware (StarkEx)—were designed to solve the problem of migrating Ethereum mainnet services. Starkware offers massive scalability while leveraging the security of Ethereum, making it an ideal solution for dYdX. This scalability also allows dYdX to experiment with different product innovations, significantly driving the overall advancement of the platform. I think this strategic transition of dYdX and subsequent product upgrades are a great example of the “infrastructure first vs. applications first” debate.

As I will explain later, dYdX relies heavily on Starkware for its core functionality. With its Layer 2 approach, dYdX has entered a new phase of prosperity. Let’s analyze in detail the performance of dYdX after migrating to Layer 2.

2.2 Why was Starkware (StarkEx) selected?

In fact, when dYdX selected Starkware, people had raised questions - why was it chosen among the many Layer 2 solutions? If Starkware didn't stand out, dYdX would have no reason to choose it in particular. So, how does Starkware compare to other Rollup solutions, especially other Zero-Knowledge Proof (ZK) schemes?

First, as a Layer 2 solution, Starkware is particularly suitable for applications that need to process large volumes of transactions quickly, such as dYdX. Starkware can package multiple transactions and process them together, but this is not a feature of Starkware. Other ZK solutions also have similar capabilities. The real advantage of Starkware is that it supports a wider variety of transactions. Although we are seeing the maturity of technologies such as zkEVM today, when dYdX began exploring Layer 2, most ZK solutions could only be optimized for simple transactions such as token transfers. Therefore, dYdX was looking for a solution that could process transactions in batches and be compatible with its own smart contracts. At the time, Starkware's StarkEx met these needs. Although Starkware does not support EVM, which means developing applications on Starkware requires learning its own language (Cairo), this seems to be a surmountable challenge for dYdX.

In addition, according to Antonio Juliano, at that time Starkware provided the most convenient access solution for Ethereum-based applications and was fully prepared for product launch.

2.3 dYdX after the introduction of Starkware: growth and growth

Leveraging Starkware's infrastructure, dYdX introduced cross-margin functionality, a trading method that allows multiple positions to be operated using a single margin account, and combined with significantly improved scalability, dYdX attracted increasing liquidity. In addition, as dYdX supports more assets, it has successfully attracted more traders. With its new engine, dYdX has seen a huge jump in trading volume by five times compared to before.

2.3.1 DYDX is online and its strategic position is consolidated

In the summer of 2021, the dYdX Foundation launched the DYDX token in conjunction with StarkEx, which further established its market position. DYDX, as the governance token of dYdX, aims to enable the protocol to be driven by the community and operate autonomously, while encouraging protocol users to participate more actively in transactions. While there has been significant growth since the move to Layer 2, the launch of the token is an important step towards “consolidation” development. Let’s take a closer look at the DYDX token distribution plan.

The distribution model of DYDX tokens is different from other tokens, especially in terms of retroactive mining, transaction incentives, and liquidity incentives. Next we explore these parts in detail.

  • Retroactive mining

dYdX has not issued tokens before. If it launches tokens now to only reward new users, it may be unfair to long-term users, potentially leading to the loss of this part of users. To balance this issue, dYdX has introduced a so-called “retroactive mining” system. As the name suggests, retroactive mining aims to reward users with tokens who have transacted on the platform in the past. As long as users have deposited and made at least one transaction in the past, they are eligible to receive retroactively mined tokens. However, the requirements to obtain tokens are not limited to previous trading activity, users must also continue trading on dYdX that switched to Layer 2 and achieve certain goals in order to receive rewards. This approach not only rewards old users, but also attracts them to continue using the new Layer 2 platform. The tokens allocated to this strategy represent approximately 5% of the total supply.

  • Transaction incentives

The so-called transaction incentives are rewards set for users who trade on Layer 2’s dYdX. This part of the token accounts for about 20% of the total supply. These rewards are calculated based on the fees paid by users to complete transactions on dYdX. More details can be found in the official documentation of dYdX.

  • Liquidity incentives

Liquidity incentives are actually a complementary form of transaction incentives, aiming to reward liquidity providers with tokens, which is similar to token incentives provided by other DeFi projects. This reward strategy aims to improve liquidity conditions for buyers and sellers in the market, with approximately 5.2% of the total supply of tokens being distributed to liquidity providers. For the specific reward distribution mechanism, please refer to the documents provided by dYdX.

  • Impact of DYDX Token

The launch of the DYDX token has achieved significant results. The daily trading volume of dYdX’s perpetual contract product on Layer 2 started out as only $30 million, and after the token was launched, it suddenly increased to about $2 billion, showing an astonishing growth curve. This highlights the huge utility of token issuance.

2.4 The constraints of Layer 2 begin to appear

All in all, dYdX’s move to Layer 2 has been a major success. The move to Layer 2 not only saved the product's fate but also helped it become one of the high-profile projects on the market. With the launch of the token, dYdX has established its unique position in the decentralized exchange market.

However, when thinking more deeply about product positioning, Antonio Juliano, the founder of dYdX, pointed out another question: “If we can never be completely decentralized, what is our advantage over Binance and FTX? What could we do ten times better than them? Frankly, I didn't really have a solid answer at the time."

Although dYdX on Layer 2 has achieved significant success, it still faces a lot of uncertainty. First of all, it is not a completely decentralized exchange. dYdX on Layer 2 is actually a hybrid decentralized exchange whose order book and matching engine operate in a centralized manner; in addition, despite its scalability There have been improvements, but dYdX needs to process more transactions to grow further (which also shows that infrastructure still plays a key role in product development); in addition, dYdX needs an infrastructure tailored for its products, although Layer 2 provides a degree of customization of the environment, but dYdX needed to go one step further and make the development environment match its product in every aspect. For this reason, continuing to rely on existing networks as a Layer 2 solution is not the ideal answer.

In order to evolve into a better product, dYdX not only needs to handle more transaction volume, but also solidifies its positioning as a decentralized exchange and adds features that match a complete decentralized exchange. Therefore, dYdX decided to transform its blockchain infrastructure again.

V4 version is coming, dYdX transforms into Layer 1

3.1 Why choose to chain independently? The road to complete decentralization

As mentioned earlier, dYdX founder Antonio Juliano has been thinking about how to distinguish dYdX from other centralized exchanges (CEX)? Can dYdX see its pursuit of complete decentralization as a unique selling point? Among the many reasons for independent chaining, a core goal that dYdX has repeatedly emphasized is to "achieve comprehensive decentralization."

Advocates of Ethereum may question how breaking away from the most decentralized Layer 1 network, Ethereum, to launch a dedicated chain can lead to decentralization. However, given that dYdX does not handle all of its product’s operations on-chain, Ethereum’s decentralization benefits appear less critical here. Perhaps, Ethereum proponents and dYdX have different definitions of decentralization.

What dYdX is really looking to do is not to leverage a decentralized network to some extent, but to approach every aspect of their product in a completely decentralized manner, which inevitably means launching their own blockchain. This means that simply operating on the most decentralized network does not automatically guarantee that its product is fully decentralized.

By launching its own blockchain, dYdX has successfully managed all operations, including the order book, in a decentralized manner. dYdX Trading, the operating entity of dYdX, is no longer involved in any business aspects of the dYdX blockchain.

Another key point is scalability. By launching its own chain, dYdX not only achieves complete decentralization at the product level, but also solves the scalability problem it has faced before. Although dYdX's processing speed at Layer 1 can already reach 100 transactions per second, its autonomously running blockchain has now achieved significant performance improvements and can process approximately 2,000 transactions per second, a performance improvement of 20 times. . This huge leap in performance could have as significant an impact on dYdx’s product itself as the migration of its Ethereum mainnet to Layer 2. In the future, dYdX is likely to launch a more friendly and faster trading experience for global users.

3.2 Why choose Cosmos?

In the process of migrating to a private chain, dYdX has chosen the Cosmos SDK as its blockchain framework. Just like StarkEx, which used Starkware before, dYdX prefers to choose a mature framework and adjust it appropriately according to the needs and characteristics of its own products, rather than building a blockchain from scratch. Therefore, they chose the Cosmos SDK - one of the most commonly used blockchain development toolkits in the industry.

So, why the Cosmos SDK specifically? Although dYdX did not elaborate on the reasons for their choice, the industry generally believes that the flexibility of the Cosmos SDK (many protocols have adapted and improved the Cosmos SDK according to their own needs), as well as the advantages of leveraging the well-established ecosystem that the Cosmos community has built, are the influencing factors. important factor in their decision-making. In fact, immediately after launching its dedicated chain, dYdX partnered with Noble, another Cosmos-based chain, to easily migrate USDC. Utilizing the "Inter-Chain Communication" (IBC) mechanism of the Cosmos ecosystem to achieve smooth data flow between chains is also a major convenience for dYdX.

3.3 In-depth analysis of architecture

The basic architecture of dYdX is based on the Cosmos SDK and is similar to other Cosmos-based blockchains. However, there are differences between them, such as the existence of indexers and frontends, and validators on dYdX have more responsibilities than validators on the standard Cosmos chain. Let’s learn more about these differences.

3.3.1 Verification node

Although the dYdX chain is built on the basis of the Cosmos SDK, its role as a validator node is different from that of other Cosmos application chain nodes. The verification nodes of the ordinary Cosmos application chain are mainly responsible for propagating transactions, verifying blocks and reaching consensus. However, on dYdX, each verification node must maintain an order book and store orders by itself (these orders are not reflected at the consensus level). Validation nodes manage the order book off-chain, meaning there are no transaction fees when users place or cancel orders.

Among all validating nodes, the proposer node is responsible for proposing the content of the next block. This way, when users place orders, proposer nodes match these orders and include them in proposed blocks, while participating in the consensus process.

In addition, full nodes play a vital role in dYdX, assisting the operation of indexers, which is crucial to the dYdX service (of course full nodes are equally important in traditional blockchains).

3.3.2 Indexer

As shown in the diagram above, indexers are responsible for reading data from full nodes of the dYdX chain, storing it, and then delivering this information to end users in a Web 2.0-compatible manner. While the protocol itself can fill this role, dYdX’s validators and full nodes are not specifically optimized for this service, which can result in slow and inefficient processing. Additionally, too many direct queries may interfere with the main job of validators (participating in validating the consensus process), so having a dedicated indexer system is crucial.

Postgres, Redis and Kafka on the right side of the figure are used to store on-chain data, off-chain data and transmit data to the indexer service respectively.

3.3.3 Front-end

Front-end design aims to simplify the end-to-end application development process. A web front-end based on JavaScript and React fetches order book information from indexers via an API and sends transaction data directly to the chain. dYdX has made the front-end code open source, so anyone can use dYdX’s front-end interface. The mobile terminal, like the web terminal, can interact with the indexer to obtain information and record transaction information directly on the chain. It is also open source, allowing anyone to deploy and use it.

3.3.4 How are orders processed?

Let’s take a look at how orders on the dYdX chain are processed collaboratively through the above entities.

  • Users submit orders through the API or front-end.

  • Orders are sent to a validator, which then broadcasts the transaction to other validators and full nodes and updates their order books.

  • Like other Cosmos SDK-based blockchains, a proposer node is selected through a consensus process, and this node will match and add the order to the next block.

  • The proposed block enters the consensus process. If it is confirmed and voted by more than two-thirds of the verification nodes, it will be recorded and submitted, and then stored in the on-chain database (and full nodes).

  • If the block fails to receive the votes of more than two-thirds of the validating nodes, it will be rejected.

  • Once the block is recorded and committed, the data will be transmitted to the full node and indexer, who will feed the data back to the front end through API and Websocket technology.

3.4 Changes in Token Utility

Obviously, the launch of a dedicated chain will also lead to changes in the utility of tokens.

As mentioned earlier, the primary goal of the dYdX blockchain is “complete decentralization.” Previously, dYdX had limited scope of governance, whereas on the dYdX chain, every aspect of the product will be determined by DYDX token holders. Another important change is that whereas in the past all earnings generated by dYdX were owned by dYdX Trading, on the dYdX chain these earnings will be distributed to DYDX token holders. This is expected to increase demand for the dYdX token - the development of the protocol will bring more revenue, which will lead to higher expected returns, increasing the attractiveness of the asset itself, ultimately increasing the demand in the market and the value of the asset.

3.5 Changes in governance

Governance on the dYdX chain may determine the following:

  • Add or remove new assets;

  • Change protocol parameters;

  • Modify the list of third parties that provide pricing information;

  • adjust rates;

  • Modify the transaction reward mechanism. ;

  • Adjust the parameters of the x/distribution module (which determines how rewards from Cosmos are distributed);

  • Adjust parameters of the x/staking module (related to staking settings in Cosmos).

  • Change the funding rate calculation formula;

  • Manage insurance funds...

As previously stated, dYdX Trading, the company that created dYdX, or the dYdX Foundation will not lead any governance proposals or discussions. Decision-making power regarding dYdX services now rests with DYDX token holders. This shift is a key difference between the dYdX chain and its previous versions. It also addresses the differentiation issue that Antonio Juliano pondered – how dYdX differentiates itself from other centralized exchanges (CEXs).

The significance of dYdX evolution

So far, we have explored the evolution of dYdX from its early days, all the way to having its own dYdX chain. Given that the dYdX chain has only just started functioning, it’s too early to declare the project’s success. However, dYdX's trajectory over the past five years is enough to allow us to draw some lessons.

4.1 Infrastructure development remains critical

dYdX's product development has gone through several stages of development: starting from the Ethereum mainnet, transforming to Layer 1, and finally launching its own chain. Although blockchain infrastructure continues to evolve and will continue to develop in the future, dYdX’s journey proves that the development of blockchain infrastructure has a significant impact on improving product quality. The fact that dYdX switched from Rollup to a self-generated chain is enough to prove that Rollup alone cannot completely solve the scalability problem. Both Rollup and Layer 1 need to continue to evolve before they can truly become a fully scalable "universal blockchain". The construction of blockchain infrastructure remains critical. I often liken infrastructure to the "boundary of imagination." If scalability limitations are considered before building a product, this will actually lead to a natural disadvantage in the product compared to existing (centralized) services. Although I don't think blockchain will always have to compete with existing services. But for those products that need to compete (like dYdX), infrastructure development is crucial.

4.2 Rollup is not a panacea

Considering the many Rollups that have emerged on the market in the past year or two, it can be said that we are in the "Rollup Era". Currently, Rollup, "Rollup as a Service" (RaaS), Rollup Software Development Kit (SDK), etc. are everywhere, and industry experts often recommend using Rollup to build products. However, Rollup is not a one-size-fits-all solution to all problems. For dYdX, the project only achieved true decentralization after launching its own blockchain, which reflects the limitations of Layer 2 Rollup. Although some people have criticized dYdX for launching the chain on its own as the "worst decision", this article has detailed that dYdX's decision was carefully considered, not hasty or irrational (of course, this decision was not just to raise prices). price of the token).

Leveraging Ethereum’s security features is indeed critical to establishing the product’s legitimacy, but without the ability to implement truly decentralized services through Rollup, the impact of this advantage may be limited. Some may prefer to stick to Ethereum even if there are some centralized components in the business process, while others (such as dYdX) may prioritize complete decentralization of the process. The bottom line is that neither approach can be said to be “more decentralized than the other” and the choice should be based on the nature of the product and personal preference. Keep in mind that Rollup is not always the ideal solution.

4.3 Flexibility is crucial

dYdX not only survived but became a leading project in the DEX space by making fundamental changes in response to changes in the market and industry. Although many people have always regarded dYdX as a successful product, if you look back at history, you will find that dYdX was once on the verge of bankruptcy. However, dYdX nimbly adapted to market and industry changes and ultimately succeeded. If dYdX sticks to the Ethereum mainnet, it may gradually withdraw from the stage of history. The key lesson here is that the ability to continually monitor market trends and make adjustments based on your own circumstances is critical.

Therefore, dYdX is a valuable case study for those struggling with product development. Sometimes, the problem may not be with the product itself, but with the infrastructure it relies on.

Conclusion: What does the future hold for dYdX?

Since the dYdX chain has just been launched and transactions on dYdX V4 have just started, it is still too early to judge its success as an independent blockchain. However, over the past five years or so, dYdX has established credibility among many traders and has been continuously improving its product. I think the dYdX brand already has considerable intrinsic value.

I insist that many products still need to rely on independent Layer 1 operations. Although many researchers are currently focusing on Rollup and modular blockchains, I still think Layer 1 is essential. Although the narrative of the Cosmos Application Chain does not conflict with the modular blockchain, the fact that dYdX has developed into an independent Layer 1 is iconic, and its independent development has become an important case that I am paying attention to.

Therefore, the success or failure of the dYdX chain is also very critical to me. Frankly, I hope it succeeds because it will provide reference and encouragement for more projects currently "stuck" in Rollup to launch their own independent blockchains.