Simplifying the Whitepaper: LayerZero
This is the first part of a series called simplifying the whitepaper. Today we will take a closer look at an interoperability solution in LayerZero.
The Problem
The current DeFi landscape is crowded by Layer 1s. It started off with Ethereum and the creation of DeFi, and has now blossomed into multiple different Layer 1s that solve specific problems or allow specific applications. This has resulted in the space being extremely fragmented. Users & developers have to keep shifting their focus and their money across different chains because they exist in silos. This can become extremely tedious in terms of experience making it a hurdle to adoption. Hence, in a multi-chain world the only way forward is interoperability. The team at LayerZero points out that there are many interoperability options available right now but they do not meet the mark because you require some level of trust in a third party. Currently, you can use a centralized exchange such as binance.com to move or hold your tokens but this means you have to trust a centralized third party which fundamentally goes against the reasons for using a blockchain. The other option is to use a Decentralized Exchange or a cross-chain bridge to move tokens from one chain to another. Even though this is decentralized and the activity is tracked on chain, there are still some problems. The bridged asset is just a wrapped version of the real asset on another chain rather than being the actual token, you have to trust the sidechain that you are using (many of them have been hacked frequently), and it takes multiple transactions to successfully move assets from one chain to another. All in all, we do not have a cheap, efficient, and trustless interoperability solution. Until now.
The proposed solution
The LayerZero whitepaper proposes a general communication layer. A messaging protocol wherein the transactions and the assets are native to each chain. Rather than having to use a middleman or having to wrap and bridge assets, each chain simply has to support something called the ‘LayerZero Endpoint’ and through this, cross-chain transfers can be made seamlessly in a single transaction as the protocol simply facilitates communication. The complexities are removed. So essentially, you have Layer 1 chains that maintain the ledger and layer 2 chains which are used as scaling solutions and now you have LayerZero which allows seamless communication between any chain.
How it works
The design goes like this. The LayerZero endpoint is a smart contract that is on each chain. There are two independent entities that are involved, the Oracle and the Relayer. The oracle is responsible for reading the block header (the unique identifier for each block) and sending it to the other chain while the relayer is responsible for fetching the proof of a specific transaction. The underlying premise is that if two independent entities can agree on the state/validity of a transaction then it can be assumed to be true. The overarching aim is to achieve something they call valid delivery. Valid delivery is when a cross-chain transfer is enabled by the following guarantees; every message is coupled with a transaction on the sender chain (the chain on which the initial transaction is created), the message is only delivered to the receiving chain (the chain that will receive the transferred assets) if the coupled transaction is deemed valid/verified. So now that you have understood the overall design let’s look at how it would work in practice.
You have chain A and chain B. Both these chains support the LayerZero endpoint. If you want to do a cross-chain transaction from A to B, you first create a transaction on chain A and only when that transaction is validated through chain A’s consensus mechanism will it be coupled with the message. This message is then sent to chain B and the transfer is complete in one single cross-chain transaction. The message that is coupled with transaction consists of data about the ID of the transaction and the proof of the transactions validity which is fetched from oracle and the relayer. As mentioned earlier, it is essential that the oracle and relayer are independent because collusion amongst these two entities could lead the network to be compromised. If you would like a highly-technical and in-detail step by step overview of this process then I would direct you to section 4.2 of the whitepaper.
LayerZero vs Other solutions
As mentioned earlier, there are many existing decentralized interoperability solutions. So lets go over how they compare to LayerZero.
· LayerZero vs Ethereum/Ethereum 2.0 –
Everyone knows that Ethereum has a major scalability issue which spurred on developers to create Layer 2 solutions and other inter-chain communication techniques to fix this bottleneck. LayerZero improves this designs efficiency by allowing you to cheaply and trustlessly transact between L1, L2s, and other chains. Even with ETH 2.0 LayerZero still has use because even though the scalability issue is solved, the cross-chain communication issue will remain.
· LayerZero vs Polkadot –
Polkadot has the design of multiple parallel chains that run alongside the main relay chain. Tokens and data can be transferred across these parallel chains but every transaction has to go through the main relay chain which means there is additional costs involved. LayerZero facilitates this communication without the additional costs as it is simply one direct transfer.
· LayerZero vs THORchain –
THORchain is a DEX which essentially facilitates transfers by pairing a third-party token to their native token RUNE which acts as a common interchange medium currency. This makes the process extremely inefficient and not to mention that the protocol has been hacked/exploited on 3 occasions. LayerZero essentially avoids the complexities by not adding so many layers to an easy operation.
· LayerZero vs Anyswap –
Anyswap is similar to THORchain except for they have a different way of using their intermediary token ANY. However, the problems presented by Anyswap remain the same as THORchain.
· LayerZero vs Cosmos –
This one is interesting because Cosmos is also a Layer 0 protocol which uses the architecture of hubs and zones to connect many application specific blockchains through the cosmos hub. The drawdowns for cosmos are that it uses a single chain which all the transactions have to go through, and blockchains either have to directly build on cosmos or port over. LayerZero instead just provides a general communication where any chain can connect to any other chain by simply supporting the smart contract. No extra complexities or added costs.
Possible use cases unlocked by LayerZero
One possible application is a Cross-Chain DEX, but not a DEX that uses bridging, wrapping, or intermediary tokens. This DEX is built using LayerZero such that liquidity pools exist on both chains and the protocol can leverage the messaging feature to allow users to simply deposit assets on one chain and withdraw them on another. No extra complexities. Straightforward swap where you have the real tokens that can be used on two different blockchains.
Another possibility, is Cross-Chain Yield Aggregators. Currently, yield aggregators are limited to accessing and formulating yield strategies around the chain they are based on which means they are missing out on huge potential yield on other chains. The simple messaging of LayerZero can now allow yield aggregators to access liquidity and yield across the entire DeFi landscape which is beneficial for everyone involved. A product like popsicle finance which aims to create many different yield aggregation and cross-chain liquidity strategies can greatly benefit from using LayerZero because they can execute their strategies through one simple transaction.
Lastly, Multi-Chain Lending. Currently users cannot access lending pools on different chains with much ease. They either have to move all their assets to another chain and swap it for the desired currency or swap it on the chain they are on and then bridge the assets to the new chain. Through LayerZero, all the nuisance is taken away because you can simply have your entire asset base on one chain and then directly lend it out or use it to borrow on another chain in one transaction.
These are just 3 possible applications, but given how innovative the DeFi community is I am sure that we will see some crazy and ingenious ways to use the seamless communication and interoperability that LayerZero enables.
I hope you enjoyed, please leave me some feedback and let me know if you would like me to breakdown more whitepapers.
Please consider following the medium and subscribing to my substack for more articles (ITS FREE)
Follow me on twitter @LeftsideEmiri
Thank You for reading.