DeversiFi helps you invest, swap, and send tokens quickly, easily and without paying Ethereum network fees. It uses a 'Validium' scaling solution to inherit security from Ethereum but with hugely reduced cost.
This week DeversiFi enabled super-fast withdrawals from L2 to any other address on Ethereum:
Whilst it may seem like a simple feature, under the hood this was not as trivial to achieve! We collaborated with StarkWare to use for the first time a new type of L2 transaction known as a 'conditional transfer', which makes possible interoperability between L2 and Ethereum L1.
We believe that conditional transfers will become one of the most important building blocks over the next year as DeFi begins to migrate over to L2s. The Ethereum community is rightly excited at the moment about L2s, but whether we are speaking about zk roll-ups, validiums, or optimistic roll-ups, interoperability between different applications and with Layer 1 is still a challenge that the ecosystem will need to overcome in order for DeFi to migrate.
This post will explain how DeversiFi's fast withdrawals functionality works, and reflect on how the underlying building block that is used is a step towards connecting together the growing constellation of L2s.
Why do we need fast withdrawals?
One of the major challenges that L2 solutions today face is that there is an exit time to remove funds from the system.
On DeversiFi, which is a 'Validium', this is because transactions are batched together into cryptographic proofs, and then submitted to Ethereum to be verified. The gas cost for a proof scales sub-linearly with the number of included transactions, and so for Validiums as well as ZK-rollups, the real benefits are only gained when batches start to be very large. Withdrawals of funds only happen therefore after a batch proof is generated and verified on-chain, which could mean waiting several hours.
In the cases of optimistic roll-ups there is an even more significant time for withdrawals, which could be multiple days. The reason this is required is due to the security model of optimistic roll-ups, which relies on a time window to allow for challenges to be submitted in the case of invalid state transitions instead of a cryptographic guarantee.
Fast withdrawals, as recently implemented by DeversiFi, are a remedy to this for end users. Using this mechanism we can allow for close to instant exit of funds.
How do fast withdrawals work?
We enable close to instant withdrawals using two components:
- A new 'conditional transfer' transaction type that is verified as part of the proof
- A liquidity provider (which in this case is the same as the operator but in future could be a pool of users earning fees)
Alice wants to withdraw 1 ETH from her L2 account directly to one of her Ethereum addresses without waiting several hours for the next batch to be processed.
The withdrawal is facilitated by the Operator using conditional transfers to avoid the need for Alice to trust the operator.
The Operator acts as a liquidity provider, accepting Alice's funds on L2, and sending back its own funds to Alice on L1.
This occurs as follows:
- On L2 Alice signs a transfer of 1 ETH to the Operator. The transfer is 'conditional', and therefore will only be valid if a specified transfer to her on L1 can be verified to exist at the time when the next proof is submitted on-chain.
- Transfer facts are recorded on a 'Transfer Registry Contract'. This fact can be considered an on-chain record of any L1 transfers occurring.
- Alice now sends her signed conditional transfer to the Operator. She knows that there is no risk to her funds yet since unless the operator completes the corresponding L1 transfer her signed transfer will be invalid.
- On receiving the conditional transfer the Operator checks the signature and the conditions attached.
- The Operator prepares a transfer of 1 ETH on L1 to the address specified by Alice's conditions. Instead of making the transfer directly to Alice, the operator sends the funds via the Transfer Registry contract to ensure a fact is recorded.
- The fact is now known to be present and the Operator can therefore safely include the conditional transfer in the next proof, allowing the Operator to receive Alice's 1 ETH on L2.
What else could the conditional transfer building block be used for?
The most obvious use case for conditional transfers is to send funds directly to a regular Ethereum address on L1.
However ultimately the 'fact' that is being registered on-chain in the Registry contract we mentioned can attest to ANY type of transaction. The StarkEx verifier contract is able to therefore check any range of conditions attached to transfers.
Some of the most exciting examples include:
- Deposits directly into Tornado Cash
- Deposits into Compound or Aave
- Arbitrage trades on L1 DEXes - note this enables aggregation and no-risk arbitrage between DeversiFi liquidity and i.e. Uniswap liquidity
- Direct transfers between different L2s, i.e. Loopring and DeversiFi
- Staking into ETH2
Connecting Ethereum L2s together
Ethereum's strength has always been its open community of developers and environment where innovation can take place without needing anyone's permission.
DeFi first flourished on Ethereum because it was a petri-dish where multiple protocols could start to interoperate and amplify each other to create an ecosystem that is bigger than any one team or idea.
L2 scaling has emerged in the same way. Teams didn’t sit around waiting for Ethereum 2.0, but instead made use of the incredible potential for innovation that a truly decentralised and open Layer 1 blockchain unleashes. A wide variety of the earliest L2 scaling solutions (such as zkSync, Hermez, Loopring, Optimism, DeversiFi, dYdX) have already emerged today and are evolving independently to each other.
Originally seen as bolt-ons to Ethereum, these L2 solutions are now considered an essential part of Ethereum 2.0’s vision for scaling, and offer a community driven approach to sharding which can multiply up Ethereum’s transaction capacity by many orders of magnitude.
Preventing fragmentation is the next challenge and conditional transfers may become one of the most important components.
Are you working on Layer 2? Interested in getting involved?
DeversiFi established L2² in order to help connect multiple L2 projects designed to collaborate closely on helping the Ethereum ecosystem to solve these pressing issues and accelerate the transition to Layer-2.
Read the announcement post here: https://blog.deversifi.com/loopring-deversifi-announce-layer2-squared/
Reach out over in our Discord to find out how to participate.