We know Lyra V2 is coming. We know it’s made for pro traders. And we know it’s the most scalable derivatives protocol yet. But how did we build it all onchain? It’s time to find out how we leveraged the OP Stack to build Lyra Chain and make us
Harder
Better
Faster
Stronger
Lyra chain has increased the scope of our project by 100x, but before we can join the Superchain, let’s go back to basics.
Define harder:
Adjective: Solid, firm, and rigid: not easily broken, bent or pierced.
Adverb: With a great deal of effort
I wish we could have the former without the latter, but the definition has two parts for a reason. So how did we make Lyra both harder (adjective: resilient) and also harder (adverb: more work)?
What’s a rollup?
First, we need to understand what a rollup is. I know there are a lot of great explainers out there and I don’t plan on bastardizing them… much. If you want to actually learn about rollups, there are plenty of people who do a better job than me and who all seem to name their articles the same:
An Incomplete Guide to Rollups by Vitalik
The Complete Guide to Rollups by Jon Charbonneau
(Almost) Everything you need to know about Optimistic Rollup by Georgios Konstantopoulos
Here is my 1-paragraph TLDR - A rollup or “layer 2” is a system that scales the performance of a blockchain (i.e. makes transactions cheaper and faster) without sacrificing its magical trust properties. This is done by moving computation off the blockchain to a centralised operator and using a proof mechanism to hold them accountable. Proofs can be optimistic in that they assume correct operation unless challenged, or they can be cryptographic (zk), in that a proof of correct computation is provided when the state is updated.
The important part is that rollups are the only way we know how to scale Ethereum without compromising its values (i.e. trust, decentralisation & self-custody).
When did Lyra find the time to build one?
Unless you’ve been living under a rock, you’ve been hearing about rollups for quite literally years. You know they’re technical marvels and you probably know they’re very hard to build. So how did we find time to build one all on our own?
Well, we didn't. Enter the OP Stack.
The Optimism team has been working on scaling Ethereum for over five years. First with plasma, then with OP mainnet and most recently the introduction of the OP Stack and the vision for the Superchain. So what’s the OP Stack? In Optimism’s words, it’s “an open-source, shared and standardized framework” for building Ethereum rollups. From our perspective, it is three things:
Time Saver: 99% reduction in development time (it may actually be infinity% because I doubt it’s possible for most teams to build a rollup on their own)
Battle Tested: This is the same codebase that has been powering OP Mainnet for years and securing billions in TVL without incident.
Ethereum Aligned: Optimism is the most Ethereum-aligned team I’ve ever seen, perhaps to their own detriment at times. But if you can be sure of one thing, it’s that Optimism will continue to embed the core ethos of Ethereum into the OP Stack.
We’re not the only ones who think this way, with the likes of Base, Zora and Gitcoin all launching OP Stack Chains recently. Going from impossibly hard to definitely doable is pretty great, but let’s not stop there. We want launching our own rollup to be easy, an afterthought. That’s where Conduit comes in. Even when you have the whole stack designed, built and tested, securely operating the infrastructure for a sequencer is a huge task, and not one that protocol teams are set up for. With Conduit, that issue is eliminated, and the Lyra DAO can focus almost exclusively on building the protocol.
Ok so the OP Stack is great and all, enabling rapid deployment of fully functional Ethereum rollups, but we were already live on Optimism and Arbitrum, why not just build Lyra V2 there? What makes Lyra Chain better than the status quo? It’s part quantitative (performance) and part qualitative (new features). Let’s tackle the new stuff first.
Sustainability
Just like any rollup, Lyra Chain has an economic structure that fundamentally involves selling blockspace to its users (Lyra traders) and purchasing it from Ethereum to ensure that there is sufficient data available on L1. This activity accrues fees to the owner of the rollup, Lyra DAO, who incurs costs when posting the data to L1. If Lyra V2 is successful and the Lyra DAO can govern the rollup effectively, it will be able to capture a sustainable margin of ETH-denominated transaction fees. This structure is visualised below.
Usability
With different paradigms and standards for accounts on EVM, it’s hard for users to find the right setup for the right app. But a new chain is a blank canvas; when users bridge to Lyra Chain, we can give them an account setup tailored for trading.
Users deposit from an EOA on Ethereum mainnet to a smart contract account on the rollup. By leveraging the latest and greatest in account abstraction, we unlock the bleeding edge of transaction UX, blurring the line between protocols and accounts:
Trade without gas: You only ever need USDC on Lyra Chain. Using bundlers and paymasters from EIP-4337 we unlock native gasless transactions.
Trade everywhere: You can easily authorize all of your devices to trade on one account using session keys. Session keys are a smart contract module that give a device authority to make a limited amount of trades over a limited amount of time. One-click, no MetaMask popups, with maximum security and control from your signer.
We can also proactively integrate chain-level features and do things like running the ERC-4337 bundler alongside the sequencer, which helps devs who want to build AA-native dapps.
The Superchain
The further out we look, the more excited we get. The Superchain is coming. A network of OP Stack Chains that share security and a communication layer. It’s designed to bring internet-level scale to Ethereum. Why is this great for Lyra? Well for one, all chains in the Superchain will have atomic composability with each other. This means composability with Base, Zora and Gitcoin, just to name a few. If Base can bring a billion people onchain (or even a million), Lyra’s universe of potential traders has increased by several orders of magnitude. These users could access Lyra without even needing to bridge. The opportunity for Lyra is to become the foundational derivatives liquidity for the Superchain.
More than just an App-chain
At launch, Lyra Chain will only house one protocol - Lyra V2- meaning it will be an “app-chain”. This is a similar situation to what we see with DyDx and most of the OP Stack Chains launched to date (excluding Base). However, there is no constraint here. We know derivatives liquidity is a foundational component of the financial system and if Lyra V2 can succeed, it’s only natural to imagine dozens of protocols built on Lyra Chain that directly integrate with that liquidity. We’ve already seen this on a small scale with Lyra V1 - Polynomial, Brahma, dHedge, Strands. Who will be the first to integrate and build on top of Lyra V2? I for one am very excited to see what else gets built on Lyra Chain.
If you’re still reading you may actually care about the performance of Lyra V2 and why we built our own chain instead of using OP mainnet or (god forbid) Ethereum L1. Being transparent and decentralized come at a cost. In contrast to many other projects, in Lyra V2 all the margin calculation logic is onchain, even while supporting advanced features like portfolio and cross margin. This makes Lyra v2 very gas intensive, for example, an account with 32 positions will take roughly 1~2 million gas to trade; and this number goes up to 5 million for 64 positions. While it’s obviously impossible to do on L1 (5m gas will take 180 USD to trade given gas price of 20gwei), with the help of rollups like Optimism, this number can be under 1 USD. But using a shared rollup like Optimism would mean sharing the throughput with other protocols too; on average, Optimism process 3m gas of computation every block, which jumps up to 20m when the network is busy. With the 30m gas cap and 2 second-block time, this leaves very limited resources to maximise usability for traders, we will likely need to cap the max positions size at a number under 30. Using a custom rollup makes it easy for us to double the performance by setting the block time to 1 second and lower the tx cost during peak hours by having a higher target block gas. With these parameters, we can settle up to 10 trades between huge accounts per second, around 30 trades per second with average traders, and up to 80 trades for perp traders, while allowing up to 100 positions per account.
Lyra Chain has made us harder, better and faster and as a result, we will become stronger. But with great strength comes great responsibility. The DAO must take on the role of governing Lyra Chain, fostering its growth and ensuring its reliability and security. This task will not be shouldered alone, we expect to work closely with Optimism, Conduit and all teams building OP Stack Chains to bring the Superchain to life. This effort has already begun with the law of chains, which lays out a vision for a unified collective of chains committed to open and decentralised blockspace. As we move forward, the DAO will need to contribute to the Law of Chains to ensure that we build the best possible future.