Introducing Hyleoof, a trustless and non-custodial zkAMM demo
Automated Market Makers (AMMs) are at the core of DeFi. These tools, which power token swaps and liquidity provisions, can seem straightforward, but building them is a real challenge!
We wanted to create a demo that would be immediately useful, so we decided to build Hyleoof, a zkAMM for Hylé. To quote our website homepage, « We are drowning in terrible UX, slow finality, or high fees. Bridges are painful. We must do better. » This is our attempt.
Introducing Hyleoof
The AMM currently supports the following actions:
- Register an account using our native
hydentity
contract (login and password) - Get
Hyllar
andHyllar2
tokens from the faucet - Transfer or swap tokens.
Hyleoof: introducing a new era for AMMs
The user experience is seamless: instead of signing at every step, Alice only needs to perform her swap in a single signed action. It’s fast and intuitive like DeFi should always be. The swap is controlled by you, not by the AMM’s backend − and the entire transaction is cryptographically guaranteed to be valid before it settles.
On traditional blockchains, every step of a swap requires a separate transaction, which comes with its base gas fees. Hyleoof consolidates all these steps into a single transaction, which means you only pay fees once; you can even make several swaps in a single transaction if you want to.
Not only that, but traditional blockchains are very far from efficient since every single node must execute each step of the transaction! Even ZK rollups need to verify the proofs in an EVM at every step. Because Hylé uses zero-knowledge proofs to verify the transaction instead of executing it ad nauseam, the entire process is more efficient and requires fewer onchain resources: everything is executed offchain!
For developers, the swap actions being in a single transaction means they’ll settle simultaneously, making the process simpler and more secure.
Swap tokens in one single transaction
On a traditional blockchain, using an AMM means doing many different transactions: you need to approve several token contracts and swaps.
On Hylé, thanks to our cross-contract composition, everything fits into a single blob transaction, which includes five blobs. Our pipelined proving means that each of these five blobs will then need to be proven, and the ZK proofs will be required to settle the final swap all at once.
Let’s take a closer look at the anatomy of a Hyleoof swap.
Thanks to our native proof verification, we allow for native proof and cross-contract composition. Thanks to pipelined proving, Hylé transactions always use the same process: create a blob transaction for sequencing, send proof of all the blobs in the transaction, and once Hylé verifies all the proofs, it will settle the entire blob transaction at once.
A token swap on Hyleoof involves five blobs.
- Identity: as always, the identity of the person initiating the transaction.
- Hyllar contract with an approve action.
- AMM contract with a swap action. This blob:
- checks that the swap is legitimate, with the right amount of tokens on both sides to respect the AMM’s constant;
- checks that the callees inputs are correct, ie., that the tokens are flowing in the right direction.
- Hyllar2 contract with a transfer action, from the AMM to the user.
- Hyllar contract with a transferFrom action from the user to the AMM.
Of course, these blobs interact with each other. Let’s see how:
As you can see, a lot is going on!
First, we have an identity blob, as is always the case with Hylé transactions. For simplicity, our demo only supports our native hydentity
contract, but Hylé actually supports any custom identity contract − more on this in a later blog post.
Then, a blob on the hyllar
contract (that’s our first token) says that Alice will allow AMM
to transfer hyllar
on her behalf; don’t pay too much attention to this one; we’ll come back to it.
The third blob is a swap on the AMM
contract. Its two main goals are to check that the transfer is technically correct (the money goes from the right account to the right account in the right currencies at the right exchange rate) and to serve as a transitory identity for the rest of this transaction.
The final two blobs are the actual transfers. In the first one, the AMM transfers Hyllar2 to Alice; in the other, the AMM uses its permission from the early approve
blob to take the correct amount of Hyllar from Alice with her permission.
While we’ve designed the blobs in chronological order for clarity, everything will settle at once. There are two state transitions, with Hyllar and Hyllar2 balances changing for Alice and the AMM; both will be updated onchain at once. Since the swap blob calls the transfer blobs, they can only be successfully proven if the swap itself is proven to be valid!
All this added to the true trustlessness of the system and the seamless user experience, means that Hyleoof takes everything we’ve come to expect from AMMs and does it better. Hylé’s lean blockchain allows for new use cases, but it also allows us to rebuild what exists − just better.
If you want to build on Hylé, you can get started already: check out our quickstart guide and our grant program!